Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -34,7 +34,7 @@ pipe.to("cuda")
|
|
34 |
|
35 |
#pipe.enable_model_cpu_offload()
|
36 |
|
37 |
-
def infer(use_custom_model, model_name, custom_lora_weight, image_in, prompt, negative_prompt, preprocessor, controlnet_conditioning_scale, guidance_scale,
|
38 |
prompt = prompt
|
39 |
negative_prompt = negative_prompt
|
40 |
generator = torch.Generator(device="cuda").manual_seed(seed)
|
@@ -61,9 +61,9 @@ def infer(use_custom_model, model_name, custom_lora_weight, image_in, prompt, ne
|
|
61 |
prompt,
|
62 |
negative_prompt=negative_prompt,
|
63 |
image=image,
|
64 |
-
controlnet_conditioning_scale=controlnet_conditioning_scale,
|
65 |
-
guidance_scale = guidance_scale,
|
66 |
-
num_inference_steps=
|
67 |
generator=generator,
|
68 |
cross_attention_kwargs={"scale": lora_scale}
|
69 |
).images
|
@@ -72,9 +72,9 @@ def infer(use_custom_model, model_name, custom_lora_weight, image_in, prompt, ne
|
|
72 |
prompt,
|
73 |
negative_prompt=negative_prompt,
|
74 |
image=image,
|
75 |
-
controlnet_conditioning_scale=controlnet_conditioning_scale,
|
76 |
-
guidance_scale = guidance_scale,
|
77 |
-
num_inference_steps=
|
78 |
generator=generator,
|
79 |
).images
|
80 |
|
@@ -103,10 +103,10 @@ with gr.Blocks(css=css) as demo:
|
|
103 |
prompt = gr.Textbox(label="Prompt")
|
104 |
negative_prompt = gr.Textbox(label="Negative prompt", value="extra digit, fewer digits, cropped, worst quality, low quality, glitch, deformed, mutated, ugly, disfigured")
|
105 |
guidance_scale = gr.Slider(label="Guidance Scale", minimum=1.0, maximum=10.0, step=0.1, value=7.5)
|
106 |
-
|
107 |
with gr.Column():
|
108 |
preprocessor = gr.Dropdown(label="Preprocessor", choices=["canny"], value="canny", interactive=False, info="For the moment, only canny is available")
|
109 |
-
controlnet_conditioning_scale = gr.Slider(label="Controlnet conditioning Scale", minimum=0.1, maximum=0.9, step=0.01, value=0.5
|
110 |
seed = gr.Slider(label="seed", minimum=0, maximum=500000, step=1, value=42)
|
111 |
use_custom_model = gr.Checkbox(label="Use a public custom model ?(optional)", value=False, info="To use a private model, you'll prefer to duplicate the space with your own access token.")
|
112 |
with gr.Row():
|
@@ -117,7 +117,7 @@ with gr.Blocks(css=css) as demo:
|
|
117 |
|
118 |
submit_btn.click(
|
119 |
fn = infer,
|
120 |
-
inputs = [use_custom_model, model_name, custom_lora_weight, image_in, prompt, negative_prompt, preprocessor, controlnet_conditioning_scale, guidance_scale,
|
121 |
outputs = [result]
|
122 |
)
|
123 |
|
|
|
34 |
|
35 |
#pipe.enable_model_cpu_offload()
|
36 |
|
37 |
+
def infer(use_custom_model, model_name, custom_lora_weight, image_in, prompt, negative_prompt, preprocessor, controlnet_conditioning_scale, guidance_scale, inf_steps, seed, progress=gr.Progress(track_tqdm=True)):
|
38 |
prompt = prompt
|
39 |
negative_prompt = negative_prompt
|
40 |
generator = torch.Generator(device="cuda").manual_seed(seed)
|
|
|
61 |
prompt,
|
62 |
negative_prompt=negative_prompt,
|
63 |
image=image,
|
64 |
+
controlnet_conditioning_scale=float(controlnet_conditioning_scale),
|
65 |
+
guidance_scale = float(guidance_scale),
|
66 |
+
num_inference_steps=inf_steps,
|
67 |
generator=generator,
|
68 |
cross_attention_kwargs={"scale": lora_scale}
|
69 |
).images
|
|
|
72 |
prompt,
|
73 |
negative_prompt=negative_prompt,
|
74 |
image=image,
|
75 |
+
controlnet_conditioning_scale=float(controlnet_conditioning_scale),
|
76 |
+
guidance_scale = float(guidance_scale),
|
77 |
+
num_inference_steps=inf_steps,
|
78 |
generator=generator,
|
79 |
).images
|
80 |
|
|
|
103 |
prompt = gr.Textbox(label="Prompt")
|
104 |
negative_prompt = gr.Textbox(label="Negative prompt", value="extra digit, fewer digits, cropped, worst quality, low quality, glitch, deformed, mutated, ugly, disfigured")
|
105 |
guidance_scale = gr.Slider(label="Guidance Scale", minimum=1.0, maximum=10.0, step=0.1, value=7.5)
|
106 |
+
inf_steps = gr.Slider(label="Inference Steps", minimum="25", maximum="50", step=1, value=25)
|
107 |
with gr.Column():
|
108 |
preprocessor = gr.Dropdown(label="Preprocessor", choices=["canny"], value="canny", interactive=False, info="For the moment, only canny is available")
|
109 |
+
controlnet_conditioning_scale = gr.Slider(label="Controlnet conditioning Scale", minimum=0.1, maximum=0.9, step=0.01, value=0.5)
|
110 |
seed = gr.Slider(label="seed", minimum=0, maximum=500000, step=1, value=42)
|
111 |
use_custom_model = gr.Checkbox(label="Use a public custom model ?(optional)", value=False, info="To use a private model, you'll prefer to duplicate the space with your own access token.")
|
112 |
with gr.Row():
|
|
|
117 |
|
118 |
submit_btn.click(
|
119 |
fn = infer,
|
120 |
+
inputs = [use_custom_model, model_name, custom_lora_weight, image_in, prompt, negative_prompt, preprocessor, controlnet_conditioning_scale, guidance_scale, inf_steps, seed],
|
121 |
outputs = [result]
|
122 |
)
|
123 |
|