Fabrice-TIERCELIN commited on
Commit
0c309b6
1 Parent(s): 9744f65

Square root

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -201,11 +201,17 @@ def restore_in_Xmin(
201
  print("GPU time allocation: " + str(allocation) + " min")
202
  print("output_format: " + str(output_format))
203
 
 
 
 
 
 
 
204
  if output_format == "input":
205
  if noisy_image is None:
206
  output_format = "png"
207
  else:
208
- output_format = re.sub(r"^.*\.([^\.]+)$", r"\1", noisy_image)
209
  print("final output_format: " + str(output_format))
210
 
211
  if prompt is None:
@@ -417,7 +423,8 @@ def restore(
417
  print("Final resolution: " + str(result_width * result_height))
418
  print("edm_steps: " + str(edm_steps))
419
  print("num_samples: " + str(num_samples))
420
- print("Estimated minutes: " + str(math.log(result_width * result_height * input_width * input_height * edm_steps * num_samples) / 10))
 
421
  except Exception as e:
422
  print('Exception of Estimation')
423
 
@@ -515,7 +522,7 @@ with gr.Blocks() as interface:
515
  """)
516
  gr.HTML(title_html)
517
 
518
- input_image = gr.Image(label="Input (*.png, *.webp, *.jpeg, *.gif, *.bmp)", show_label=True, type="filepath", height=600, elem_id="image-input")
519
  rotation = gr.Radio([["No rotation", 0], ["⤵ Rotate +90°", 90], ["↩ Return 180°", 180], ["⤴ Rotate -90°", -90]], label="Orientation correction", info="Will apply the following rotation before restoring the image; the AI needs a good orientation to understand the content", value=0, interactive=True, visible=False)
520
  with gr.Group():
521
  prompt = gr.Textbox(label="Image description", info="Help the AI understand what the image represents; describe as much as possible, especially the details we can't see on the original image; you can write in any language", value="", placeholder="A 33 years old man, walking, in the street, Santiago, morning, Summer, photorealistic", lines=3)
 
201
  print("GPU time allocation: " + str(allocation) + " min")
202
  print("output_format: " + str(output_format))
203
 
204
+ input_format = re.sub(r"^.*\.([^\.]+)$", r"\1", noisy_image)
205
+
206
+ if input_format not in ['png', 'webp', 'jpg', 'jpeg', 'bmp']:
207
+ gr.Warning('Invalid image format. Please first convert into *.png, *.webp, *.jpg, *.jpeg or *.bmp.')
208
+ return None, None, None, None
209
+
210
  if output_format == "input":
211
  if noisy_image is None:
212
  output_format = "png"
213
  else:
214
+ output_format = input_format
215
  print("final output_format: " + str(output_format))
216
 
217
  if prompt is None:
 
423
  print("Final resolution: " + str(result_width * result_height))
424
  print("edm_steps: " + str(edm_steps))
425
  print("num_samples: " + str(num_samples))
426
+ print("downscale: " + str(downscale))
427
+ print("Estimated minutes: " + str((result_width * result_height * input_width * input_height * edm_steps * num_samples)**(1/2)))
428
  except Exception as e:
429
  print('Exception of Estimation')
430
 
 
522
  """)
523
  gr.HTML(title_html)
524
 
525
+ input_image = gr.Image(label="Input (*.png, *.webp, *.jpeg, *.jpg, *.bmp)", show_label=True, type="filepath", height=600, elem_id="image-input")
526
  rotation = gr.Radio([["No rotation", 0], ["⤵ Rotate +90°", 90], ["↩ Return 180°", 180], ["⤴ Rotate -90°", -90]], label="Orientation correction", info="Will apply the following rotation before restoring the image; the AI needs a good orientation to understand the content", value=0, interactive=True, visible=False)
527
  with gr.Group():
528
  prompt = gr.Textbox(label="Image description", info="Help the AI understand what the image represents; describe as much as possible, especially the details we can't see on the original image; you can write in any language", value="", placeholder="A 33 years old man, walking, in the street, Santiago, morning, Summer, photorealistic", lines=3)