Spaces:
Running
on
Zero
Running
on
Zero
NightRaven109
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -191,6 +191,33 @@ DEFAULT_VALUES = {
|
|
191 |
"color_fix_method": "adain"
|
192 |
}
|
193 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
# Create interface components
|
195 |
with gr.Blocks(title="Controllable Conditional Super-Resolution") as demo:
|
196 |
gr.Markdown("## Controllable Conditional Super-Resolution")
|
@@ -219,6 +246,7 @@ with gr.Blocks(title="Controllable Conditional Super-Resolution") as demo:
|
|
219 |
submit_btn = gr.Button("Submit", variant="primary")
|
220 |
|
221 |
with gr.Column():
|
|
|
222 |
output_image = gr.Image(label="Generated Image")
|
223 |
|
224 |
# Define example data
|
@@ -257,7 +285,7 @@ with gr.Blocks(title="Controllable Conditional Super-Resolution") as demo:
|
|
257 |
"wavelet"
|
258 |
],
|
259 |
[
|
260 |
-
"examples/9D03D7F206775949.png
|
261 |
"clean, texture, high-resolution, 8k",
|
262 |
"blurry, dotted, noise, raster lines, unclear, lowres, over-smoothed",
|
263 |
3.0,
|
@@ -268,7 +296,7 @@ with gr.Blocks(title="Controllable Conditional Super-Resolution") as demo:
|
|
268 |
"wavelet"
|
269 |
],
|
270 |
[
|
271 |
-
"examples/3.
|
272 |
"clean, texture, high-resolution, 8k",
|
273 |
"blurry, dotted, noise, raster lines, unclear, lowres, over-smoothed",
|
274 |
2.5,
|
@@ -289,9 +317,9 @@ with gr.Blocks(title="Controllable Conditional Super-Resolution") as demo:
|
|
289 |
conditioning_scale, num_steps, seed, upscale_factor,
|
290 |
color_fix_method
|
291 |
],
|
292 |
-
outputs=output_image,
|
293 |
-
fn=
|
294 |
-
|
295 |
)
|
296 |
|
297 |
# Define submit action
|
@@ -306,14 +334,13 @@ with gr.Blocks(title="Controllable Conditional Super-Resolution") as demo:
|
|
306 |
)
|
307 |
|
308 |
# Add event handler for input image change
|
|
|
|
|
|
|
309 |
input_image.change(
|
310 |
-
fn=
|
311 |
-
inputs=
|
312 |
-
|
313 |
-
conditioning_scale, num_steps, seed, upscale_factor,
|
314 |
-
color_fix_method
|
315 |
-
],
|
316 |
-
outputs=output_image
|
317 |
)
|
318 |
|
319 |
# Define clear action that resets to default values
|
@@ -327,7 +354,9 @@ with gr.Blocks(title="Controllable Conditional Super-Resolution") as demo:
|
|
327 |
DEFAULT_VALUES["num_steps"],
|
328 |
DEFAULT_VALUES["seed"],
|
329 |
DEFAULT_VALUES["upscale_factor"],
|
330 |
-
DEFAULT_VALUES["color_fix_method"]
|
|
|
|
|
331 |
]
|
332 |
|
333 |
clear_btn.click(
|
@@ -336,7 +365,7 @@ with gr.Blocks(title="Controllable Conditional Super-Resolution") as demo:
|
|
336 |
outputs=[
|
337 |
input_image, prompt, negative_prompt, guidance_scale,
|
338 |
conditioning_scale, num_steps, seed, upscale_factor,
|
339 |
-
color_fix_method
|
340 |
]
|
341 |
)
|
342 |
|
|
|
191 |
"color_fix_method": "adain"
|
192 |
}
|
193 |
|
194 |
+
def process_example(example_data):
|
195 |
+
# Unpack example data
|
196 |
+
input_img, prompt_text, neg_prompt, guid_scale, cond_scale, steps, seed_val, up_factor, color_method = example_data
|
197 |
+
|
198 |
+
# First update the input image and parameters
|
199 |
+
results = [
|
200 |
+
input_img, # input_image
|
201 |
+
prompt_text,
|
202 |
+
neg_prompt,
|
203 |
+
guid_scale,
|
204 |
+
cond_scale,
|
205 |
+
steps,
|
206 |
+
seed_val,
|
207 |
+
up_factor,
|
208 |
+
color_method,
|
209 |
+
input_img, # Show input image in preview
|
210 |
+
gr.update(value=None) # Clear previous output while processing
|
211 |
+
]
|
212 |
+
|
213 |
+
# Then process the image
|
214 |
+
output = process_image(
|
215 |
+
input_img, prompt_text, neg_prompt, guid_scale,
|
216 |
+
cond_scale, steps, seed_val, up_factor, color_method
|
217 |
+
)
|
218 |
+
|
219 |
+
return results[:-2] + [input_img, output] # Return all updated values plus input/output images
|
220 |
+
|
221 |
# Create interface components
|
222 |
with gr.Blocks(title="Controllable Conditional Super-Resolution") as demo:
|
223 |
gr.Markdown("## Controllable Conditional Super-Resolution")
|
|
|
246 |
submit_btn = gr.Button("Submit", variant="primary")
|
247 |
|
248 |
with gr.Column():
|
249 |
+
preview_input = gr.Image(label="Preview Input")
|
250 |
output_image = gr.Image(label="Generated Image")
|
251 |
|
252 |
# Define example data
|
|
|
285 |
"wavelet"
|
286 |
],
|
287 |
[
|
288 |
+
"examples/9D03D7F206775949.png",
|
289 |
"clean, texture, high-resolution, 8k",
|
290 |
"blurry, dotted, noise, raster lines, unclear, lowres, over-smoothed",
|
291 |
3.0,
|
|
|
296 |
"wavelet"
|
297 |
],
|
298 |
[
|
299 |
+
"examples/3.jpeg",
|
300 |
"clean, texture, high-resolution, 8k",
|
301 |
"blurry, dotted, noise, raster lines, unclear, lowres, over-smoothed",
|
302 |
2.5,
|
|
|
317 |
conditioning_scale, num_steps, seed, upscale_factor,
|
318 |
color_fix_method
|
319 |
],
|
320 |
+
outputs=[preview_input, output_image],
|
321 |
+
fn=process_example,
|
322 |
+
cache_examples=True,
|
323 |
)
|
324 |
|
325 |
# Define submit action
|
|
|
334 |
)
|
335 |
|
336 |
# Add event handler for input image change
|
337 |
+
def update_preview(img):
|
338 |
+
return img
|
339 |
+
|
340 |
input_image.change(
|
341 |
+
fn=update_preview,
|
342 |
+
inputs=input_image,
|
343 |
+
outputs=preview_input
|
|
|
|
|
|
|
|
|
344 |
)
|
345 |
|
346 |
# Define clear action that resets to default values
|
|
|
354 |
DEFAULT_VALUES["num_steps"],
|
355 |
DEFAULT_VALUES["seed"],
|
356 |
DEFAULT_VALUES["upscale_factor"],
|
357 |
+
DEFAULT_VALUES["color_fix_method"],
|
358 |
+
None, # preview_input
|
359 |
+
None # output_image
|
360 |
]
|
361 |
|
362 |
clear_btn.click(
|
|
|
365 |
outputs=[
|
366 |
input_image, prompt, negative_prompt, guidance_scale,
|
367 |
conditioning_scale, num_steps, seed, upscale_factor,
|
368 |
+
color_fix_method, preview_input, output_image
|
369 |
]
|
370 |
)
|
371 |
|