Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -72,9 +72,11 @@ def compare_images(image1, image2, blur_value, technique, threshold_value, metho
|
|
72 |
diff_colored[:, :, 1] = 0
|
73 |
diff_colored[:, :, 2] = thresh
|
74 |
overlayed = cv2.addWeighted(image1, 0.7, diff_colored, 0.6, 0)
|
75 |
-
unchanged = cv2.bitwise_and(image1, image1, mask=255 - thresh)
|
76 |
|
77 |
-
|
|
|
|
|
|
|
78 |
|
79 |
def update_threshold_visibility(technique):
|
80 |
return gr.update(visible=(technique == "Simple Binary"))
|
@@ -86,7 +88,7 @@ with gr.Blocks() as demo:
|
|
86 |
img1 = gr.Image(type="numpy", label="Image Without Object")
|
87 |
img2 = gr.Image(type="numpy", label="Image With Object")
|
88 |
|
89 |
-
blur_slider = gr.Slider(minimum=1, maximum=15, step=
|
90 |
technique_dropdown = gr.Dropdown(["Adaptive Threshold", "Otsu's Threshold", "Simple Binary"], label="Thresholding Technique", value="Adaptive Threshold", interactive=True)
|
91 |
threshold_slider = gr.Slider(minimum=0, maximum=255, step=1, value=50, label="Threshold Value", visible=False)
|
92 |
method_dropdown = gr.Dropdown(["SSIM", "Background Subtraction", "Optical Flow", "Feature Matching"], label="Comparison Method", value="SSIM", interactive=True)
|
@@ -98,9 +100,10 @@ with gr.Blocks() as demo:
|
|
98 |
output2 = gr.Image(type="numpy", label="Raw Difference Overlay (Magenta)")
|
99 |
|
100 |
with gr.Row():
|
101 |
-
output3 = gr.Image(type="numpy", label="
|
|
|
102 |
|
103 |
btn = gr.Button("Process")
|
104 |
-
btn.click(compare_images, inputs=[img1, img2, blur_slider, technique_dropdown, threshold_slider, method_dropdown], outputs=[output1, output2, output3])
|
105 |
|
106 |
demo.launch()
|
|
|
72 |
diff_colored[:, :, 1] = 0
|
73 |
diff_colored[:, :, 2] = thresh
|
74 |
overlayed = cv2.addWeighted(image1, 0.7, diff_colored, 0.6, 0)
|
|
|
75 |
|
76 |
+
blended_with_object = cv2.addWeighted(image1, 0.4, image2, 0.6, 0)
|
77 |
+
blended_without_object = cv2.addWeighted(image1, 0.6, image2, 0.4, 0)
|
78 |
+
|
79 |
+
return highlighted, overlayed, blended_with_object, blended_without_object
|
80 |
|
81 |
def update_threshold_visibility(technique):
|
82 |
return gr.update(visible=(technique == "Simple Binary"))
|
|
|
88 |
img1 = gr.Image(type="numpy", label="Image Without Object")
|
89 |
img2 = gr.Image(type="numpy", label="Image With Object")
|
90 |
|
91 |
+
blur_slider = gr.Slider(minimum=1, maximum=15, step=2, value=5, label="Gaussian Blur")
|
92 |
technique_dropdown = gr.Dropdown(["Adaptive Threshold", "Otsu's Threshold", "Simple Binary"], label="Thresholding Technique", value="Adaptive Threshold", interactive=True)
|
93 |
threshold_slider = gr.Slider(minimum=0, maximum=255, step=1, value=50, label="Threshold Value", visible=False)
|
94 |
method_dropdown = gr.Dropdown(["SSIM", "Background Subtraction", "Optical Flow", "Feature Matching"], label="Comparison Method", value="SSIM", interactive=True)
|
|
|
100 |
output2 = gr.Image(type="numpy", label="Raw Difference Overlay (Magenta)")
|
101 |
|
102 |
with gr.Row():
|
103 |
+
output3 = gr.Image(type="numpy", label="Blended with Object")
|
104 |
+
output4 = gr.Image(type="numpy", label="Blended without Object")
|
105 |
|
106 |
btn = gr.Button("Process")
|
107 |
+
btn.click(compare_images, inputs=[img1, img2, blur_slider, technique_dropdown, threshold_slider, method_dropdown], outputs=[output1, output2, output3, output4])
|
108 |
|
109 |
demo.launch()
|