Update app.py
Browse files
app.py
CHANGED
@@ -115,8 +115,8 @@ def realesrgan(img, model_name, denoise_strength, face_enhance, outscale, ext):
|
|
115 |
|
116 |
#out_filename = f"output_{rnd_string(8)}.{extension}"
|
117 |
out_filename = f"output_{rnd_string(8)}." + ext
|
118 |
-
metadata = PngInfo()
|
119 |
if parameters != '':
|
|
|
120 |
metadata.add_text("parameters", parameters)
|
121 |
cv2.imwrite(out_filename, output, [int(cv2.IMWRITE_PNG_COMPRESSION), 0], pnginfo=metadata)
|
122 |
else:
|
@@ -183,6 +183,9 @@ def image_properties(img):
|
|
183 |
properties = f"Width: {img.size[0]}, Height: {img.size[1]} | Color Mode: {img_mode}"
|
184 |
return properties
|
185 |
|
|
|
|
|
|
|
186 |
|
187 |
def main():
|
188 |
# Gradio Interface
|
@@ -212,12 +215,14 @@ def main():
|
|
212 |
with gr.Group():
|
213 |
input_image = gr.Image(label="Source Image", type="pil", image_mode="RGBA")
|
214 |
input_image_properties = gr.Textbox(label="Image Properties", max_lines=1)
|
|
|
215 |
output_image = gr.Image(label="Restored Image", image_mode="RGBA", show_share_button=False)
|
216 |
with gr.Row():
|
217 |
restore_btn = gr.Button("Upscale")
|
218 |
|
219 |
# Event listeners:
|
220 |
input_image.change(fn=image_properties, inputs=input_image, outputs=input_image_properties)
|
|
|
221 |
restore_btn.click(fn=realesrgan,
|
222 |
inputs=[input_image, model_name, denoise_strength, face_enhance, outscale, ext],
|
223 |
outputs=output_image,
|
|
|
115 |
|
116 |
#out_filename = f"output_{rnd_string(8)}.{extension}"
|
117 |
out_filename = f"output_{rnd_string(8)}." + ext
|
|
|
118 |
if parameters != '':
|
119 |
+
metadata = PngInfo()
|
120 |
metadata.add_text("parameters", parameters)
|
121 |
cv2.imwrite(out_filename, output, [int(cv2.IMWRITE_PNG_COMPRESSION), 0], pnginfo=metadata)
|
122 |
else:
|
|
|
183 |
properties = f"Width: {img.size[0]}, Height: {img.size[1]} | Color Mode: {img_mode}"
|
184 |
return properties
|
185 |
|
186 |
+
def image_metadata(img):
|
187 |
+
return img.text['parameters']
|
188 |
+
|
189 |
|
190 |
def main():
|
191 |
# Gradio Interface
|
|
|
215 |
with gr.Group():
|
216 |
input_image = gr.Image(label="Source Image", type="pil", image_mode="RGBA")
|
217 |
input_image_properties = gr.Textbox(label="Image Properties", max_lines=1)
|
218 |
+
input_image_metadata = gr.Textbox(label="Image Metadata", max_lines=1)
|
219 |
output_image = gr.Image(label="Restored Image", image_mode="RGBA", show_share_button=False)
|
220 |
with gr.Row():
|
221 |
restore_btn = gr.Button("Upscale")
|
222 |
|
223 |
# Event listeners:
|
224 |
input_image.change(fn=image_properties, inputs=input_image, outputs=input_image_properties)
|
225 |
+
input_image.change(fn=image_metadata, inputs=input_image, outputs=input_image_metadata)
|
226 |
restore_btn.click(fn=realesrgan,
|
227 |
inputs=[input_image, model_name, denoise_strength, face_enhance, outscale, ext],
|
228 |
outputs=output_image,
|