Update app.py
Browse files
app.py
CHANGED
@@ -71,6 +71,23 @@ def unified_matching_plot2(image0, image1, kpts0, kpts1, mkpts0, mkpts1, color,
|
|
71 |
|
72 |
return img
|
73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
# Main functions
|
75 |
def detect_and_crop(target_image, query_image, threshold=0.5, nms_threshold=0.3):
|
76 |
target_sizes = torch.Tensor([target_image.size[::-1]])
|
@@ -187,20 +204,21 @@ iface = gr.Interface(
|
|
187 |
gr.Image(type="pil", label="Upload a Query Image (Poster)"),
|
188 |
gr.Image(type="pil", label="Upload a Target Image (Media)"),
|
189 |
gr.Slider(minimum=0, maximum=100, step=1, value=50, label="Threshold"),
|
190 |
-
gr.CheckboxGroup(choices=[0.33, 0.66, 1.0], value=[0.33, 0.66, 1.0], label="Scale Factors")
|
191 |
],
|
192 |
outputs=[
|
193 |
-
gr.
|
|
|
194 |
],
|
195 |
-
title="Object Detection in
|
196 |
description="""
|
197 |
-
|
198 |
-
|
199 |
-
1.
|
200 |
-
2.
|
201 |
-
3.
|
202 |
-
4.
|
203 |
-
5.
|
204 |
"""
|
205 |
)
|
206 |
|
|
|
71 |
|
72 |
return img
|
73 |
|
74 |
+
def stitch_images(images):
|
75 |
+
"""Stitches a list of images vertically."""
|
76 |
+
if not images:
|
77 |
+
return Image.new('RGB', (100, 100), color='gray')
|
78 |
+
|
79 |
+
max_width = max([img.width for img in images])
|
80 |
+
total_height = sum(img.height for img in images)
|
81 |
+
|
82 |
+
composite = Image.new('RGB', (max_width, total_height))
|
83 |
+
|
84 |
+
y_offset = 0
|
85 |
+
for img in images:
|
86 |
+
composite.paste(img, (0, y_offset))
|
87 |
+
y_offset += img.height
|
88 |
+
|
89 |
+
return composite
|
90 |
+
|
91 |
# Main functions
|
92 |
def detect_and_crop(target_image, query_image, threshold=0.5, nms_threshold=0.3):
|
93 |
target_sizes = torch.Tensor([target_image.size[::-1]])
|
|
|
204 |
gr.Image(type="pil", label="Upload a Query Image (Poster)"),
|
205 |
gr.Image(type="pil", label="Upload a Target Image (Media)"),
|
206 |
gr.Slider(minimum=0, maximum=100, step=1, value=50, label="Threshold"),
|
207 |
+
gr.CheckboxGroup(choices=["0.33", "0.66", "1.0"], value=["0.33", "0.66", "1.0"], label="Scale Factors"),
|
208 |
],
|
209 |
outputs=[
|
210 |
+
gr.Label(label="Object Presence"),
|
211 |
+
gr.Image(type="pil", label="Detected Bounding Boxes"),
|
212 |
],
|
213 |
+
title="Object Detection in Images",
|
214 |
description="""
|
215 |
+
This application allows you to check if an object in a query image (poster) is present in a target image (media).
|
216 |
+
Steps:
|
217 |
+
1. Upload a Query Image (Poster)
|
218 |
+
2. Upload a Target Image (Media)
|
219 |
+
3. Set Threshold
|
220 |
+
4. Set Scale Factors
|
221 |
+
5. View Results
|
222 |
"""
|
223 |
)
|
224 |
|