SoDa12321's picture
Update app.py
62c216e verified
import gradio as gr
import subprocess
def deblur_image(input_image_path, angle_model_path, length_model_path):
command = [
"python3",
"deblur_img.py",
"--image",
input_image_path,
"--angle_model",
angle_model_path,
"--length_model",
length_model_path
]
result = subprocess.run(command, capture_output=True, text=True)
return result.stdout
def deblur_and_display(input_image, angle_model_path, length_model_path):
output = deblur_image(input_image.name, angle_model_path, length_model_path)
return output
iface = gr.Interface(
fn=deblur_and_display,
inputs=[
gr.inputs.Image(label="Upload Image"),
gr.inputs.Textbox(label="Angle Model Path", default="/app/pretrained_models/angle_model.hdf5"),
gr.inputs.Textbox(label="Length Model Path", default="/app/pretrained_models/length_model.hdf5")
],
outputs="text",
title="Image Deblurring App",
description="Upload an image to deblur it."
)
if __name__ == "__main__":
iface.launch(server_name="0.0.0.0", server_port=7860)