aryrk commited on
Commit
b8a1b3c
·
1 Parent(s): 220be7c

[feat] make a preprocess an option

Browse files
Files changed (1) hide show
  1. app.py +18 -11
app.py CHANGED
@@ -80,16 +80,23 @@ sample_images = [
80
  if file.endswith((".jpg", ".jpeg", ".png"))
81
  ]
82
 
83
- def gradio_interface():
84
- preprocess_options = ["resize_and_crop", "crop", "scale_width", "scale_width_and_crop", "none"]
85
- gr.Interface(
86
- fn=reflection_removal,
87
- inputs=[
88
- gr.inputs.Image(type="file", label="Input Image"),
89
- gr.inputs.Dropdown(preprocess_options, label="Preprocess Type")
90
- ],
91
- outputs=gr.outputs.Image(type="pil", label="Output Image")
92
- ).launch()
 
 
 
 
 
 
 
93
 
94
  if __name__ == "__main__":
95
- gradio_interface()
 
80
  if file.endswith((".jpg", ".jpeg", ".png"))
81
  ]
82
 
83
+ preprocess_options = [
84
+ "resize_and_crop", "crop", "scale_width", "scale_width_and_crop", "none"
85
+ ]
86
+
87
+ iface = gr.Interface(
88
+ fn=reflection_removal,
89
+ inputs=[
90
+ gr.Image(type="filepath", label="Upload Image (JPG/PNG)"),
91
+ gr.Dropdown(choices=preprocess_options, label="Preprocessing Type", default="resize_and_crop")
92
+ ],
93
+ outputs=gr.Gallery(label="Results after Reflection Removal"),
94
+ examples=[
95
+ os.path.join("sample_images", img) for img in os.listdir("sample_images") if img.endswith((".jpg", ".jpeg", ".png"))
96
+ ],
97
+ title="Reflection Remover with Pix2Pix",
98
+ description="Upload images to remove reflections using a Pix2Pix model. You can also try the sample images below."
99
+ )
100
 
101
  if __name__ == "__main__":
102
+ iface.launch()