hotchpotch
commited on
Commit
•
2a47dd7
1
Parent(s):
90f3fab
Update image display in app.py
Browse files
app.py
CHANGED
@@ -84,11 +84,13 @@ def app():
|
|
84 |
search_results = qdrant_client.search(
|
85 |
collection_name="images-clip",
|
86 |
query_vector=text_features,
|
87 |
-
limit=
|
88 |
)
|
89 |
elapsed = time() - start
|
90 |
st.write(f"elapsed: {elapsed:.2f} sec")
|
91 |
st.write(f"total: {len(search_results)}")
|
|
|
|
|
92 |
for r in search_results:
|
93 |
score = r.score
|
94 |
if payload := r.payload:
|
@@ -96,9 +98,17 @@ def app():
|
|
96 |
else:
|
97 |
name = "unknown"
|
98 |
image_url = get_image_url(name, image_type="xsmall")
|
99 |
-
|
100 |
-
|
101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
|
103 |
|
104 |
if __name__ == "__main__":
|
|
|
84 |
search_results = qdrant_client.search(
|
85 |
collection_name="images-clip",
|
86 |
query_vector=text_features,
|
87 |
+
limit=50,
|
88 |
)
|
89 |
elapsed = time() - start
|
90 |
st.write(f"elapsed: {elapsed:.2f} sec")
|
91 |
st.write(f"total: {len(search_results)}")
|
92 |
+
images = []
|
93 |
+
captions = []
|
94 |
for r in search_results:
|
95 |
score = r.score
|
96 |
if payload := r.payload:
|
|
|
98 |
else:
|
99 |
name = "unknown"
|
100 |
image_url = get_image_url(name, image_type="xsmall")
|
101 |
+
images.append(image_url)
|
102 |
+
captions.append(f"{name} ({score:.4f})")
|
103 |
+
image_group_n = 6
|
104 |
+
for i in range(0, len(images), image_group_n):
|
105 |
+
target_images = images[i : i + image_group_n]
|
106 |
+
target_captions = captions[i : i + image_group_n]
|
107 |
+
st.image(
|
108 |
+
target_images,
|
109 |
+
caption=target_captions,
|
110 |
+
width=160,
|
111 |
+
)
|
112 |
|
113 |
|
114 |
if __name__ == "__main__":
|