SoDa12321 commited on
Commit
48e3983
·
verified ·
1 Parent(s): 3814240

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -0
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import subprocess
3
+
4
+ def deblur_image(input_image_path, angle_model_path, length_model_path):
5
+ command = [
6
+ "python",
7
+ "deblur_img.py",
8
+ "--image",
9
+ input_image_path,
10
+ "--angle_model",
11
+ angle_model_path,
12
+ "--length_model",
13
+ length_model_path
14
+ ]
15
+ result = subprocess.run(command, capture_output=True, text=True)
16
+ return result.stdout
17
+
18
+ def deblur_and_display(input_image, angle_model_path, length_model_path):
19
+ output = deblur_image(input_image.name, angle_model_path, length_model_path)
20
+ return output
21
+
22
+ iface = gr.Interface(
23
+ fn=deblur_and_display,
24
+ inputs=[
25
+ gr.inputs.Image(label="Upload Image"),
26
+ gr.inputs.Textbox(label="Angle Model Path", default="/app/pretrained_models/angle_model.hdf5"),
27
+ gr.inputs.Textbox(label="Length Model Path", default="/app/pretrained_models/length_model.hdf5")
28
+ ],
29
+ outputs="text",
30
+ title="Image Deblurring App",
31
+ description="Upload an image to deblur it."
32
+ )
33
+
34
+ if __name__ == "__main__":
35
+ iface.launch()
36
+