Skip to content

Commit 767f45f

Browse files
Angelogebbeabevi
andcommitted
Added multiple boxes highlighting in query image
Co-authored-by: beabevi <[email protected]>
1 parent e8f13a6 commit 767f45f

File tree

4 files changed

+21
-49
lines changed

4 files changed

+21
-49
lines changed

create_retrieval_db.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ def best_bbox(instance, n=1):
2323
sorted(enumerate(instance[1]), key=lambda t: t[1][0], reverse=True),
2424
)
2525
)
26-
if n == 1:
26+
if not n:
27+
return result
28+
elif n == 1:
2729
return result[0]
2830
return result[:n]
2931

dist/index.html

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,4 @@
11
<html>
2-
3-
<head>
4-
<style>
5-
.grid {
6-
-webkit-columns: 4;
7-
columns: 4;
8-
-webkit-column-gap: 1em;
9-
column-gap: 1em;
10-
}
11-
.grid__item {
12-
margin-bottom: 1em;
13-
}
14-
.grid__item img {
15-
width: 100%;
16-
}
17-
18-
.dropzone {
19-
background: white;
20-
border-radius: 5px;
21-
border: 2px dashed rgb(0, 135, 247);
22-
border-image: none;
23-
max-width: 500px;
24-
margin-left: auto;
25-
margin-right: auto;
26-
height: 30%;
27-
}
28-
29-
</style>
30-
</head>
31-
322
<body>
333
<form action="/search" method="POST" enctype="multipart/form-data">
344
<input type=file name=file></input>

query.py

100755100644
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#!/usr/bin/env python3
2-
31
import pickle
42

53
import numpy as np

server.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,25 @@ def search():
3939
)
4040

4141
instance = result[str(up_name)]
42-
best_i = best_bbox(instance)
43-
claz = instance[1][best_i][1]
44-
45-
(x1, y1, x2, y2) = instance[0][best_i]
46-
42+
best_is = best_bbox(instance, n=None)
4743
img = cv2.imread(str(up_name))
48-
cv2.rectangle(
49-
img,
50-
(x1, y1),
51-
(x2, y2),
52-
(
53-
int(class_to_color[claz][0]),
54-
int(class_to_color[claz][1]),
55-
int(class_to_color[claz][2]),
56-
),
57-
4,
58-
)
44+
45+
for best_i in best_is:
46+
claz = instance[1][best_i][1]
47+
48+
(x1, y1, x2, y2) = instance[0][best_i]
49+
50+
cv2.rectangle(
51+
img,
52+
(x1, y1),
53+
(x2, y2),
54+
(
55+
int(class_to_color[claz][0]),
56+
int(class_to_color[claz][1]),
57+
int(class_to_color[claz][2]),
58+
),
59+
4,
60+
)
5961
cv2.imwrite(str(up_name), img)
6062
return render_template(
6163
"result.html", qimg=str(up_name.relative_to("dist")), imgs=sim_images

0 commit comments

Comments
 (0)