Spaces:
Running
on
Zero
Running
on
Zero
Alexander Bagus
commited on
Commit
·
9a7c5de
1
Parent(s):
9d639bc
22
Browse files
app.py
CHANGED
|
@@ -91,7 +91,7 @@ def inference(
|
|
| 91 |
negative_prompt,
|
| 92 |
edit_dict,
|
| 93 |
# image_scale=1.0,
|
| 94 |
-
control_mode='Canny',
|
| 95 |
control_context_scale = 0.75,
|
| 96 |
seed=42,
|
| 97 |
randomize_seed=True,
|
|
@@ -108,21 +108,21 @@ def inference(
|
|
| 108 |
print("Error: edit_dict is empty.")
|
| 109 |
return None
|
| 110 |
|
| 111 |
-
print(edit_dict)
|
| 112 |
# input_image, width, height = scale_image(input_image, image_scale)
|
| 113 |
# control_mode='HED'
|
| 114 |
-
processor_id = 'canny'
|
| 115 |
-
if control_mode == 'HED':
|
| 116 |
-
|
| 117 |
-
if control_mode =='Depth':
|
| 118 |
-
|
| 119 |
-
if control_mode =='MLSD':
|
| 120 |
-
|
| 121 |
-
if control_mode =='Pose':
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
print(f"DEBUG: processor_id={processor_id}")
|
| 125 |
-
processor = Processor(processor_id)
|
| 126 |
|
| 127 |
# Width must be divisible by 16
|
| 128 |
|
|
@@ -206,15 +206,14 @@ with gr.Blocks() as demo:
|
|
| 206 |
placeholder="Enter your prompt",
|
| 207 |
# container=False,
|
| 208 |
)
|
| 209 |
-
is_polish_prompt = gr.Checkbox(label="Polish prompt", value=True)
|
| 210 |
-
control_mode = gr.Radio(
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
)
|
| 215 |
run_button = gr.Button("Generate", variant="primary")
|
| 216 |
with gr.Accordion("Advanced Settings", open=False):
|
| 217 |
-
|
| 218 |
negative_prompt = gr.Textbox(
|
| 219 |
label="Negative prompt",
|
| 220 |
lines=2,
|
|
@@ -222,21 +221,21 @@ with gr.Blocks() as demo:
|
|
| 222 |
placeholder="Enter your negative prompt",
|
| 223 |
value="blurry ugly bad"
|
| 224 |
)
|
| 225 |
-
with gr.Row():
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
guidance_scale = gr.Slider(
|
| 241 |
label="Guidance scale",
|
| 242 |
minimum=0.0,
|
|
@@ -244,16 +243,6 @@ with gr.Blocks() as demo:
|
|
| 244 |
step=0.1,
|
| 245 |
value=1.0,
|
| 246 |
)
|
| 247 |
-
# with gr.Row():
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
# image_scale = gr.Slider(
|
| 251 |
-
# label="Image scale",
|
| 252 |
-
# minimum=0.5,
|
| 253 |
-
# maximum=2.0,
|
| 254 |
-
# step=0.1,
|
| 255 |
-
# value=1.0,
|
| 256 |
-
# )
|
| 257 |
|
| 258 |
seed = gr.Slider(
|
| 259 |
label="Seed",
|
|
@@ -266,27 +255,28 @@ with gr.Blocks() as demo:
|
|
| 266 |
|
| 267 |
with gr.Column():
|
| 268 |
output_image = gr.Image(label="Generated image", show_label=False)
|
| 269 |
-
polished_prompt = gr.Textbox(label="Polished prompt", interactive=False)
|
| 270 |
|
| 271 |
-
with gr.Accordion("Preprocessor
|
| 272 |
mask_image = gr.Image(label="Mask image", show_label=False)
|
| 273 |
|
| 274 |
gr.Examples(examples=examples, inputs=[edit_dict, prompt, control_mode])
|
| 275 |
gr.Markdown(read_file("static/footer.md"))
|
| 276 |
|
|
|
|
| 277 |
run_button.click(
|
| 278 |
-
fn=
|
| 279 |
-
inputs=[
|
| 280 |
-
outputs=[
|
| 281 |
# outputs=gr.State(), # Pass to the next function, not to UI at this step
|
| 282 |
).then(
|
| 283 |
fn=inference,
|
| 284 |
inputs=[
|
| 285 |
-
|
| 286 |
negative_prompt,
|
| 287 |
edit_dict,
|
| 288 |
# image_scale,
|
| 289 |
-
control_mode,
|
| 290 |
control_context_scale,
|
| 291 |
seed,
|
| 292 |
randomize_seed,
|
|
|
|
| 91 |
negative_prompt,
|
| 92 |
edit_dict,
|
| 93 |
# image_scale=1.0,
|
| 94 |
+
# control_mode='Canny',
|
| 95 |
control_context_scale = 0.75,
|
| 96 |
seed=42,
|
| 97 |
randomize_seed=True,
|
|
|
|
| 108 |
print("Error: edit_dict is empty.")
|
| 109 |
return None
|
| 110 |
|
| 111 |
+
# print(edit_dict)
|
| 112 |
# input_image, width, height = scale_image(input_image, image_scale)
|
| 113 |
# control_mode='HED'
|
| 114 |
+
# processor_id = 'canny'
|
| 115 |
+
# if control_mode == 'HED':
|
| 116 |
+
# processor_id = 'softedge_hed'
|
| 117 |
+
# if control_mode =='Depth':
|
| 118 |
+
# processor_id = 'depth_midas'
|
| 119 |
+
# if control_mode =='MLSD':
|
| 120 |
+
# processor_id = 'mlsd'
|
| 121 |
+
# if control_mode =='Pose':
|
| 122 |
+
# processor_id = 'openpose_full'
|
| 123 |
+
|
| 124 |
+
# print(f"DEBUG: processor_id={processor_id}")
|
| 125 |
+
# processor = Processor(processor_id)
|
| 126 |
|
| 127 |
# Width must be divisible by 16
|
| 128 |
|
|
|
|
| 206 |
placeholder="Enter your prompt",
|
| 207 |
# container=False,
|
| 208 |
)
|
| 209 |
+
# is_polish_prompt = gr.Checkbox(label="Polish prompt", value=True)
|
| 210 |
+
# control_mode = gr.Radio(
|
| 211 |
+
# choices=["Canny", "Depth", "HED", "MLSD", "Pose"],
|
| 212 |
+
# value="Canny",
|
| 213 |
+
# label="Control Mode"
|
| 214 |
+
# )
|
| 215 |
run_button = gr.Button("Generate", variant="primary")
|
| 216 |
with gr.Accordion("Advanced Settings", open=False):
|
|
|
|
| 217 |
negative_prompt = gr.Textbox(
|
| 218 |
label="Negative prompt",
|
| 219 |
lines=2,
|
|
|
|
| 221 |
placeholder="Enter your negative prompt",
|
| 222 |
value="blurry ugly bad"
|
| 223 |
)
|
| 224 |
+
# with gr.Row():
|
| 225 |
+
num_inference_steps = gr.Slider(
|
| 226 |
+
label="Steps",
|
| 227 |
+
minimum=1,
|
| 228 |
+
maximum=30,
|
| 229 |
+
step=1,
|
| 230 |
+
value=9,
|
| 231 |
+
)
|
| 232 |
+
control_context_scale = gr.Slider(
|
| 233 |
+
label="Context scale",
|
| 234 |
+
minimum=0.0,
|
| 235 |
+
maximum=1.0,
|
| 236 |
+
step=0.01,
|
| 237 |
+
value=0.75,
|
| 238 |
+
)
|
| 239 |
guidance_scale = gr.Slider(
|
| 240 |
label="Guidance scale",
|
| 241 |
minimum=0.0,
|
|
|
|
| 243 |
step=0.1,
|
| 244 |
value=1.0,
|
| 245 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 246 |
|
| 247 |
seed = gr.Slider(
|
| 248 |
label="Seed",
|
|
|
|
| 255 |
|
| 256 |
with gr.Column():
|
| 257 |
output_image = gr.Image(label="Generated image", show_label=False)
|
| 258 |
+
# polished_prompt = gr.Textbox(label="Polished prompt", interactive=False)
|
| 259 |
|
| 260 |
+
with gr.Accordion("Preprocessor data", open=False):
|
| 261 |
mask_image = gr.Image(label="Mask image", show_label=False)
|
| 262 |
|
| 263 |
gr.Examples(examples=examples, inputs=[edit_dict, prompt, control_mode])
|
| 264 |
gr.Markdown(read_file("static/footer.md"))
|
| 265 |
|
| 266 |
+
# edit_dict.upload(fn=lambda x: x, inputs=[mask_image], outputs=[input_image])
|
| 267 |
run_button.click(
|
| 268 |
+
fn=lambda x: x,
|
| 269 |
+
inputs=[mask_image['composition']],
|
| 270 |
+
outputs=[mask_image]
|
| 271 |
# outputs=gr.State(), # Pass to the next function, not to UI at this step
|
| 272 |
).then(
|
| 273 |
fn=inference,
|
| 274 |
inputs=[
|
| 275 |
+
prompt,
|
| 276 |
negative_prompt,
|
| 277 |
edit_dict,
|
| 278 |
# image_scale,
|
| 279 |
+
# control_mode,
|
| 280 |
control_context_scale,
|
| 281 |
seed,
|
| 282 |
randomize_seed,
|