NightRaven109 commited on
Commit
c480747
·
verified ·
1 Parent(s): 7a73662

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -30
app.py CHANGED
@@ -191,13 +191,15 @@ DEFAULT_VALUES = {
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,
@@ -206,19 +208,10 @@ def process_example(example_data):
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")
224
  gr.Markdown("Upload an image to enhance its resolution using CCSR.")
@@ -309,18 +302,21 @@ with gr.Blocks(title="Controllable Conditional Super-Resolution") as demo:
309
  ]
310
 
311
  # Add gallery of examples
312
- with gr.Row():
313
- gr.Examples(
314
- examples=examples,
315
- inputs=[
316
- input_image, prompt, negative_prompt, guidance_scale,
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
326
  submit_btn.click(
@@ -370,4 +366,5 @@ with gr.Blocks(title="Controllable Conditional Super-Resolution") as demo:
370
  )
371
 
372
  if __name__ == "__main__":
373
- demo.launch()
 
 
191
  "color_fix_method": "adain"
192
  }
193
 
194
+ def process_example(img_path, prompt_text, neg_prompt, guid_scale, cond_scale, steps, seed_val, up_factor, color_method):
195
+ # Update UI components and process image
196
+ output = process_image(
197
+ img_path, prompt_text, neg_prompt, guid_scale,
198
+ cond_scale, steps, seed_val, up_factor, color_method
199
+ )
200
 
201
+ return [
202
+ img_path, # input_image
 
203
  prompt_text,
204
  neg_prompt,
205
  guid_scale,
 
208
  seed_val,
209
  up_factor,
210
  color_method,
211
+ img_path, # preview_input
212
+ output # output_image
213
  ]
 
 
 
 
 
 
 
 
214
 
 
215
  with gr.Blocks(title="Controllable Conditional Super-Resolution") as demo:
216
  gr.Markdown("## Controllable Conditional Super-Resolution")
217
  gr.Markdown("Upload an image to enhance its resolution using CCSR.")
 
302
  ]
303
 
304
  # Add gallery of examples
305
+ gr.Examples(
306
+ examples=examples,
307
+ inputs=[
308
+ input_image, prompt, negative_prompt, guidance_scale,
309
+ conditioning_scale, num_steps, seed, upscale_factor,
310
+ color_fix_method
311
+ ],
312
+ outputs=[
313
+ input_image, prompt, negative_prompt, guidance_scale,
314
+ conditioning_scale, num_steps, seed, upscale_factor,
315
+ color_fix_method, preview_input, output_image
316
+ ],
317
+ fn=process_example,
318
+ cache_examples=True,
319
+ )
320
 
321
  # Define submit action
322
  submit_btn.click(
 
366
  )
367
 
368
  if __name__ == "__main__":
369
+ demo.launch()
370
+