Fabrice-TIERCELIN commited on
Commit
35c63ae
1 Parent(s): 1785567

Improve interface

Browse files
Files changed (1) hide show
  1. gradio_demo.py +22 -18
gradio_demo.py CHANGED
@@ -165,7 +165,6 @@ def stage2_process(input_image, prompt, a_prompt, n_prompt, num_samples, upscale
165
  Image.fromarray(result).save(f'./history/{event_id[:5]}/{event_id[5:]}/HQ_{i}.png')
166
  return [input_image] + results, event_id, 3, ''
167
 
168
- @spaces.GPU(duration=120)
169
  def load_and_reset(param_setting):
170
  if torch.cuda.device_count() == 0:
171
  gr.Warning('Set this space to GPU config to make it work.')
@@ -226,6 +225,7 @@ else:
226
  ⚠️SUPIR is still a research project under tested and is not yet a stable commercial product.
227
 
228
  <a href="https://arxiv.org/abs/2401.13627">Paper</a> &emsp; <a href="http://supir.xpixel.group/">Project Page</a> &emsp; <a href="https://github.com/Fanghua-Yu/SUPIR/blob/master/assets/DemoGuide.png">How to play</a>
 
229
  """
230
 
231
 
@@ -252,34 +252,38 @@ with gr.Blocks(title='SUPIR') as interface:
252
  with gr.Column():
253
  gr.Markdown("<center>Stage1 Output</center>")
254
  denoise_image = gr.Image(type="numpy", elem_id="image-s1", height=400, width=400)
255
- prompt = gr.Textbox(label="Prompt", value="")
 
256
  with gr.Accordion("Stage1 options", open=False):
257
  gamma_correction = gr.Slider(label="Gamma Correction", minimum=0.1, maximum=2.0, value=1.0, step=0.1)
 
258
  with gr.Accordion("LLaVA options", open=False):
259
- temperature = gr.Slider(label="Temperature", minimum=0., maximum=1.0, value=0.2, step=0.1)
260
- top_p = gr.Slider(label="Top P", minimum=0., maximum=1.0, value=0.7, step=0.1)
261
- qs = gr.Textbox(label="Question", value="Describe this image and its style in a very detailed manner. "
262
- "The image is a realistic photography, not an art painting.")
263
  with gr.Accordion("Stage2 options", open=False):
264
- num_samples = gr.Slider(label="Num Samples", minimum=1, maximum=4 if not args.use_image_slider else 1
265
  , value=1, step=1)
266
- upscale = gr.Slider(label="Upscale", minimum=1, maximum=8, value=1, step=1)
267
- edm_steps = gr.Slider(label="Steps", minimum=1, maximum=200, value=default_setting.edm_steps if torch.cuda.device_count() > 0 else 1, step=1)
268
- s_cfg = gr.Slider(label="Text Guidance Scale", minimum=1.0, maximum=15.0,
269
  value=default_setting.s_cfg_Quality if torch.cuda.device_count() > 0 else 1.0, step=0.1)
270
  s_stage2 = gr.Slider(label="Stage2 Guidance Strength", minimum=0., maximum=1., value=1., step=0.05)
271
  s_stage1 = gr.Slider(label="Stage1 Guidance Strength", minimum=-1.0, maximum=6.0, value=-1.0, step=1.0)
272
- seed = gr.Slider(label="Seed", minimum=-1, maximum=2147483647, step=1, randomize=True)
273
  s_churn = gr.Slider(label="S-Churn", minimum=0, maximum=40, value=5, step=1)
274
  s_noise = gr.Slider(label="S-Noise", minimum=1.0, maximum=1.1, value=1.003, step=0.001)
275
  a_prompt = gr.Textbox(label="Default Positive Prompt",
 
276
  value='Cinematic, High Contrast, highly detailed, taken using a Canon EOS R '
277
  'camera, hyper detailed photo - realistic maximum detail, 32k, Color '
278
  'Grading, ultra HD, extreme meticulous detailing, skin pore detailing, '
279
  'hyper sharpness, perfect without deformations.')
280
  n_prompt = gr.Textbox(label="Default Negative Prompt",
281
- value='painting, oil painting, illustration, drawing, art, sketch, oil painting, '
282
- 'cartoon, CG Style, 3D render, unreal engine, blurring, dirty, messy, '
 
283
  'worst quality, low quality, frames, watermark, signature, jpeg artifacts, '
284
  'deformed, lowres, over-smooth')
285
  with gr.Row():
@@ -313,17 +317,17 @@ with gr.Blocks(title='SUPIR') as interface:
313
  result_gallery = ImageSlider(label='Output', show_label=False, elem_id="gallery1")
314
  with gr.Row():
315
  with gr.Column():
316
- denoise_button = gr.Button(value="Stage1 Run")
317
  with gr.Column():
318
  llave_button = gr.Button(value="LlaVa Run")
319
  with gr.Column():
320
- diffusion_button = gr.Button(value="Stage2 Run")
321
  with gr.Row():
322
  with gr.Column():
323
- param_setting = gr.Dropdown(["Quality", "Fidelity"], interactive=True, label="Param Setting",
324
- value="Quality")
325
  with gr.Column():
326
- restart_button = gr.Button(value="Reset Param", scale=2)
 
327
  with gr.Accordion("Feedback", open=True):
328
  fb_score = gr.Slider(label="Feedback Score", minimum=1, maximum=5, value=3, step=1,
329
  interactive=True)
 
165
  Image.fromarray(result).save(f'./history/{event_id[:5]}/{event_id[5:]}/HQ_{i}.png')
166
  return [input_image] + results, event_id, 3, ''
167
 
 
168
  def load_and_reset(param_setting):
169
  if torch.cuda.device_count() == 0:
170
  gr.Warning('Set this space to GPU config to make it work.')
 
225
  ⚠️SUPIR is still a research project under tested and is not yet a stable commercial product.
226
 
227
  <a href="https://arxiv.org/abs/2401.13627">Paper</a> &emsp; <a href="http://supir.xpixel.group/">Project Page</a> &emsp; <a href="https://github.com/Fanghua-Yu/SUPIR/blob/master/assets/DemoGuide.png">How to play</a>
228
+ <p style="background-color: orange;">For now, only the stage 2 is working (the most important one). The stage 1 and LLaVa are failing. LLaVa is disabled.</p>
229
  """
230
 
231
 
 
252
  with gr.Column():
253
  gr.Markdown("<center>Stage1 Output</center>")
254
  denoise_image = gr.Image(type="numpy", elem_id="image-s1", height=400, width=400)
255
+ prompt = gr.Textbox(label="Prompt", value="", placeholder="A person, walking, in a town, Summer, photorealistic")
256
+
257
  with gr.Accordion("Stage1 options", open=False):
258
  gamma_correction = gr.Slider(label="Gamma Correction", minimum=0.1, maximum=2.0, value=1.0, step=0.1)
259
+
260
  with gr.Accordion("LLaVA options", open=False):
261
+ temperature = gr.Slider(label="Temperature", info = "lower=Always similar, higher=More creative", minimum=0., maximum=1.0, value=0.2, step=0.1)
262
+ top_p = gr.Slider(label="Top P", info = "Percent of tokens shortlisted", minimum=0., maximum=1.0, value=0.7, step=0.1)
263
+ qs = gr.Textbox(label="Question", info="Describe the image and its style in a very detailed manner", placeholder="The image is a realistic photography, not an art painting.")
264
+
265
  with gr.Accordion("Stage2 options", open=False):
266
+ num_samples = gr.Slider(label="Num Samples", info="Number of generated results; I discourage to increase because the process is limited to 2 min", minimum=1, maximum=4 if not args.use_image_slider else 1
267
  , value=1, step=1)
268
+ upscale = gr.Slider(label="Upscale", info="The resolution increase factor", minimum=1, maximum=8, value=1, step=1)
269
+ edm_steps = gr.Slider(label="Steps", info="lower=faster, higher=more details", minimum=1, maximum=200, value=default_setting.edm_steps if torch.cuda.device_count() > 0 else 1, step=1)
270
+ s_cfg = gr.Slider(label="Text Guidance Scale", info="lower=follow the image, higher=follow the prompt", minimum=1.0, maximum=15.0,
271
  value=default_setting.s_cfg_Quality if torch.cuda.device_count() > 0 else 1.0, step=0.1)
272
  s_stage2 = gr.Slider(label="Stage2 Guidance Strength", minimum=0., maximum=1., value=1., step=0.05)
273
  s_stage1 = gr.Slider(label="Stage1 Guidance Strength", minimum=-1.0, maximum=6.0, value=-1.0, step=1.0)
274
+ seed = gr.Slider(label="Seed", info="-1=Different each time, other=Reproducible", minimum=-1, maximum=2147483647, step=1, randomize=True)
275
  s_churn = gr.Slider(label="S-Churn", minimum=0, maximum=40, value=5, step=1)
276
  s_noise = gr.Slider(label="S-Noise", minimum=1.0, maximum=1.1, value=1.003, step=0.001)
277
  a_prompt = gr.Textbox(label="Default Positive Prompt",
278
+ info="Describe what the image represents",
279
  value='Cinematic, High Contrast, highly detailed, taken using a Canon EOS R '
280
  'camera, hyper detailed photo - realistic maximum detail, 32k, Color '
281
  'Grading, ultra HD, extreme meticulous detailing, skin pore detailing, '
282
  'hyper sharpness, perfect without deformations.')
283
  n_prompt = gr.Textbox(label="Default Negative Prompt",
284
+ info="List what the image does NOT represent",
285
+ value='painting, oil painting, illustration, drawing, art, sketch, anime, '
286
+ 'cartoon, CG Style, 3D render, unreal engine, blurring, bokeh, ugly, dirty, messy, '
287
  'worst quality, low quality, frames, watermark, signature, jpeg artifacts, '
288
  'deformed, lowres, over-smooth')
289
  with gr.Row():
 
317
  result_gallery = ImageSlider(label='Output', show_label=False, elem_id="gallery1")
318
  with gr.Row():
319
  with gr.Column():
320
+ denoise_button = gr.Button(value="Stage1 Run (out of work)")
321
  with gr.Column():
322
  llave_button = gr.Button(value="LlaVa Run")
323
  with gr.Column():
324
+ diffusion_button = gr.Button(value="Stage2 Run (actual upscaling)", variant = "primary")
325
  with gr.Row():
326
  with gr.Column():
327
+ param_setting = gr.Radio(["Quality", "Fidelity"], interactive=True, label="Param Setting", value="Quality")
 
328
  with gr.Column():
329
+ restart_button = gr.Button(value="Reset Param", scale=2, variant="stop")
330
+
331
  with gr.Accordion("Feedback", open=True):
332
  fb_score = gr.Slider(label="Feedback Score", minimum=1, maximum=5, value=3, step=1,
333
  interactive=True)