Fabrice-TIERCELIN
commited on
Commit
•
ef77056
1
Parent(s):
0c309b6
Allow gif
Browse files
app.py
CHANGED
@@ -203,8 +203,8 @@ def restore_in_Xmin(
|
|
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":
|
@@ -229,7 +229,7 @@ def restore_in_Xmin(
|
|
229 |
a_prompt = prompt + a_prompt
|
230 |
print("Final prompt: " + str(a_prompt))
|
231 |
|
232 |
-
denoise_image = Image.open(noisy_image if denoise_image is None else denoise_image)
|
233 |
|
234 |
if rotation == 90:
|
235 |
denoise_image = np.array(list(zip(*denoise_image[::-1])))
|
@@ -241,9 +241,9 @@ def restore_in_Xmin(
|
|
241 |
|
242 |
if 1 < downscale:
|
243 |
input_height, input_width, input_channel = denoise_image.shape
|
244 |
-
denoise_image = denoise_image.resize((input_width // downscale, input_height // downscale), Image.LANCZOS)
|
245 |
|
246 |
-
denoise_image = HWC3(
|
247 |
|
248 |
if torch.cuda.device_count() == 0:
|
249 |
gr.Warning('Set this space to GPU config to make it work.')
|
@@ -522,7 +522,7 @@ with gr.Blocks() as interface:
|
|
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)
|
|
|
203 |
|
204 |
input_format = re.sub(r"^.*\.([^\.]+)$", r"\1", noisy_image)
|
205 |
|
206 |
+
if input_format not in ['png', 'webp', 'jpg', 'jpeg', 'gif', 'bmp']:
|
207 |
+
gr.Warning('Invalid image format. Please first convert into *.png, *.webp, *.jpg, *.jpeg, *.gif or *.bmp.')
|
208 |
return None, None, None, None
|
209 |
|
210 |
if output_format == "input":
|
|
|
229 |
a_prompt = prompt + a_prompt
|
230 |
print("Final prompt: " + str(a_prompt))
|
231 |
|
232 |
+
denoise_image = np.array(Image.open(noisy_image if denoise_image is None else denoise_image))
|
233 |
|
234 |
if rotation == 90:
|
235 |
denoise_image = np.array(list(zip(*denoise_image[::-1])))
|
|
|
241 |
|
242 |
if 1 < downscale:
|
243 |
input_height, input_width, input_channel = denoise_image.shape
|
244 |
+
denoise_image = np.array(Image.fromarray(denoise_image).resize((input_width // downscale, input_height // downscale), Image.LANCZOS))
|
245 |
|
246 |
+
denoise_image = HWC3(denoise_image)
|
247 |
|
248 |
if torch.cuda.device_count() == 0:
|
249 |
gr.Warning('Set this space to GPU config to make it work.')
|
|
|
522 |
""")
|
523 |
gr.HTML(title_html)
|
524 |
|
525 |
+
input_image = gr.Image(label="Input (*.png, *.webp, *.jpeg, *.jpg, *.gif, *.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)
|