Spaces:
Sleeping
Sleeping
aryrk commited on
Commit ·
220be7c
1
Parent(s): c55e3ef
[feat] make a preprocess an option
Browse files
app.py
CHANGED
|
@@ -33,7 +33,7 @@ def clear_uploaded_images():
|
|
| 33 |
if os.path.isfile(file_path):
|
| 34 |
os.remove(file_path)
|
| 35 |
|
| 36 |
-
def reflection_removal(input_image):
|
| 37 |
if not input_image.lower().endswith((".jpg", ".jpeg", ".png")):
|
| 38 |
return ["File is not supported (only .jpg, .jpeg, .png)."]
|
| 39 |
|
|
@@ -52,7 +52,7 @@ def reflection_removal(input_image):
|
|
| 52 |
"--norm", "batch", "--epoch", "310",
|
| 53 |
"--num_test", str(count_files(UPLOAD_DIR)),
|
| 54 |
"--gpu_ids", "-1",
|
| 55 |
-
"--preprocess",
|
| 56 |
]
|
| 57 |
subprocess.run(cmd, check=True)
|
| 58 |
|
|
@@ -80,16 +80,16 @@ sample_images = [
|
|
| 80 |
if file.endswith((".jpg", ".jpeg", ".png"))
|
| 81 |
]
|
| 82 |
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
)
|
| 93 |
|
| 94 |
if __name__ == "__main__":
|
| 95 |
-
|
|
|
|
| 33 |
if os.path.isfile(file_path):
|
| 34 |
os.remove(file_path)
|
| 35 |
|
| 36 |
+
def reflection_removal(input_image, preprocess_type="resize_and_crop"):
|
| 37 |
if not input_image.lower().endswith((".jpg", ".jpeg", ".png")):
|
| 38 |
return ["File is not supported (only .jpg, .jpeg, .png)."]
|
| 39 |
|
|
|
|
| 52 |
"--norm", "batch", "--epoch", "310",
|
| 53 |
"--num_test", str(count_files(UPLOAD_DIR)),
|
| 54 |
"--gpu_ids", "-1",
|
| 55 |
+
"--preprocess", preprocess_type
|
| 56 |
]
|
| 57 |
subprocess.run(cmd, check=True)
|
| 58 |
|
|
|
|
| 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()
|