Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -49,24 +49,23 @@ def compare_images(image1, image2, blur_value, technique, threshold_value):
|
|
49 |
def update_threshold_visibility(technique):
|
50 |
return gr.update(visible=(technique == "Simple Binary"))
|
51 |
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
gr.Image(type="numpy", label="Image
|
57 |
-
gr.
|
58 |
-
|
59 |
-
|
60 |
-
],
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
)
|
69 |
-
|
70 |
-
demo.load(update_threshold_visibility, inputs=["Thresholding Technique"], outputs=["Threshold Value"])
|
71 |
|
72 |
-
demo.launch()
|
|
|
49 |
def update_threshold_visibility(technique):
|
50 |
return gr.update(visible=(technique == "Simple Binary"))
|
51 |
|
52 |
+
with gr.Blocks() as demo:
|
53 |
+
gr.Markdown("# Object Difference Highlighter\nUpload two images: one without an object and one with an object. The app will highlight only the newly added object and show the real differences in magenta overlayed on the original image.")
|
54 |
+
|
55 |
+
with gr.Row():
|
56 |
+
img1 = gr.Image(type="numpy", label="Image Without Object")
|
57 |
+
img2 = gr.Image(type="numpy", label="Image With Object")
|
58 |
+
|
59 |
+
blur_slider = gr.Slider(minimum=1, maximum=15, step=2, value=5, label="Gaussian Blur")
|
60 |
+
technique_dropdown = gr.Dropdown(["Adaptive Threshold", "Otsu's Threshold", "Simple Binary"], label="Thresholding Technique", value="Adaptive Threshold", interactive=True)
|
61 |
+
threshold_slider = gr.Slider(minimum=0, maximum=255, step=1, value=50, label="Threshold Value", visible=False)
|
62 |
+
|
63 |
+
technique_dropdown.change(update_threshold_visibility, inputs=[technique_dropdown], outputs=[threshold_slider])
|
64 |
+
|
65 |
+
output1 = gr.Image(type="numpy", label="Highlighted Differences")
|
66 |
+
output2 = gr.Image(type="numpy", label="Raw Difference Overlay (Magenta)")
|
67 |
+
|
68 |
+
btn = gr.Button("Process")
|
69 |
+
btn.click(compare_images, inputs=[img1, img2, blur_slider, technique_dropdown, threshold_slider], outputs=[output1, output2])
|
|
|
70 |
|
71 |
+
demo.launch()
|