NightRaven109 commited on
Commit
0f15bd0
·
verified ·
1 Parent(s): 08e62df

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -37
app.py CHANGED
@@ -191,6 +191,36 @@ DEFAULT_VALUES = {
191
  "color_fix_method": "adain"
192
  }
193
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
  # Define example data
195
  EXAMPLES = [
196
  [
@@ -250,51 +280,33 @@ EXAMPLES = [
250
  ]
251
  ]
252
 
253
- # Create interface components
254
- with gr.Blocks(title="Controllable Conditional Super-Resolution") as demo:
255
- gr.Markdown("## Controllable Conditional Super-Resolution")
256
- gr.Markdown("Upload an image to enhance its resolution using CCSR.")
257
-
258
  with gr.Row():
259
- with gr.Column():
260
- input_image = gr.Image(label="Input Image")
261
-
262
- with gr.Accordion("Advanced Options", open=False):
263
- prompt = gr.Textbox(label="Prompt", value=DEFAULT_VALUES["prompt"])
264
- negative_prompt = gr.Textbox(label="Negative Prompt", value=DEFAULT_VALUES["negative_prompt"])
265
- guidance_scale = gr.Slider(minimum=1.0, maximum=20.0, value=DEFAULT_VALUES["guidance_scale"], label="Guidance Scale")
266
- conditioning_scale = gr.Slider(minimum=0.1, maximum=2.0, value=DEFAULT_VALUES["conditioning_scale"], label="Conditioning Scale")
267
- num_steps = gr.Slider(minimum=1, maximum=50, value=DEFAULT_VALUES["num_steps"], step=1, label="Number of Steps")
268
- seed = gr.Number(label="Seed", value=DEFAULT_VALUES["seed"])
269
- upscale_factor = gr.Slider(minimum=1, maximum=8, value=DEFAULT_VALUES["upscale_factor"], step=1, label="Upscale Factor")
270
- color_fix_method = gr.Dropdown(
271
- choices=["none", "wavelet", "adain"],
272
- label="Color Fix Method",
273
- value=DEFAULT_VALUES["color_fix_method"]
274
- )
275
-
276
- with gr.Row():
277
- clear_btn = gr.Button("Clear")
278
- submit_btn = gr.Button("Submit", variant="primary")
279
-
280
- with gr.Column():
281
- output_image = gr.Image(label="Generated Image")
282
 
283
- # Add examples
284
- gr.Examples(
285
- examples=EXAMPLES,
286
  inputs=[
287
  input_image, prompt, negative_prompt, guidance_scale,
288
  conditioning_scale, num_steps, seed, upscale_factor,
289
  color_fix_method
290
  ],
291
- outputs=output_image,
292
- fn=process_image,
293
- cache_examples=True # Cache the results for faster loading
294
  )
295
 
296
- # Define submit action
297
- submit_btn.click(
298
  fn=process_image,
299
  inputs=[
300
  input_image, prompt, negative_prompt, guidance_scale,
@@ -329,4 +341,4 @@ with gr.Blocks(title="Controllable Conditional Super-Resolution") as demo:
329
  )
330
 
331
  if __name__ == "__main__":
332
- demo.launch()
 
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")
197
+ gr.Markdown("Upload an image to enhance its resolution using CCSR.")
198
+
199
+ with gr.Row():
200
+ with gr.Column():
201
+ input_image = gr.Image(label="Input Image")
202
+
203
+ with gr.Accordion("Advanced Options", open=False):
204
+ prompt = gr.Textbox(label="Prompt", value=DEFAULT_VALUES["prompt"])
205
+ negative_prompt = gr.Textbox(label="Negative Prompt", value=DEFAULT_VALUES["negative_prompt"])
206
+ guidance_scale = gr.Slider(minimum=1.0, maximum=20.0, value=DEFAULT_VALUES["guidance_scale"], label="Guidance Scale")
207
+ conditioning_scale = gr.Slider(minimum=0.1, maximum=2.0, value=DEFAULT_VALUES["conditioning_scale"], label="Conditioning Scale")
208
+ num_steps = gr.Slider(minimum=1, maximum=50, value=DEFAULT_VALUES["num_steps"], step=1, label="Number of Steps")
209
+ seed = gr.Number(label="Seed", value=DEFAULT_VALUES["seed"])
210
+ upscale_factor = gr.Slider(minimum=1, maximum=8, value=DEFAULT_VALUES["upscale_factor"], step=1, label="Upscale Factor")
211
+ color_fix_method = gr.Dropdown(
212
+ choices=["none", "wavelet", "adain"],
213
+ label="Color Fix Method",
214
+ value=DEFAULT_VALUES["color_fix_method"]
215
+ )
216
+
217
+ with gr.Row():
218
+ clear_btn = gr.Button("Clear")
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
225
  EXAMPLES = [
226
  [
 
280
  ]
281
  ]
282
 
283
+ # Add gallery of examples
 
 
 
 
284
  with gr.Row():
285
+ gr.Examples(
286
+ examples=examples,
287
+ inputs=[
288
+ input_image, prompt, negative_prompt, guidance_scale,
289
+ conditioning_scale, num_steps, seed, upscale_factor,
290
+ color_fix_method
291
+ ],
292
+ outputs=output_image,
293
+ fn=process_image,
294
+ run_on_click=True # This makes it run inference automatically when clicked
295
+ )
 
 
 
 
 
 
 
 
 
 
 
 
296
 
297
+ # Define submit action
298
+ submit_btn.click(
299
+ fn=process_image,
300
  inputs=[
301
  input_image, prompt, negative_prompt, guidance_scale,
302
  conditioning_scale, num_steps, seed, upscale_factor,
303
  color_fix_method
304
  ],
305
+ outputs=output_image
 
 
306
  )
307
 
308
+ # Add event handler for input image change
309
+ input_image.change(
310
  fn=process_image,
311
  inputs=[
312
  input_image, prompt, negative_prompt, guidance_scale,
 
341
  )
342
 
343
  if __name__ == "__main__":
344
+ demo.launch()