Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -16,7 +16,6 @@ import zipfile
|
|
16 |
with zipfile.ZipFile("Vegetable Images.zip", 'r') as zip_ref:
|
17 |
zip_ref.extractall('.')
|
18 |
|
19 |
-
placeholder = st.empty()
|
20 |
|
21 |
class ImageVectorizer:
|
22 |
'''
|
@@ -119,27 +118,22 @@ def process_input_image(img_url):
|
|
119 |
vectorizer = ImageVectorizer()
|
120 |
collection = get_milvus_collection()
|
121 |
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
st.error(f'An unexpected error occured: \n{e}')
|
142 |
-
|
143 |
-
|
144 |
-
if __name__ == "__main__":
|
145 |
-
main()
|
|
|
16 |
with zipfile.ZipFile("Vegetable Images.zip", 'r') as zip_ref:
|
17 |
zip_ref.extractall('.')
|
18 |
|
|
|
19 |
|
20 |
class ImageVectorizer:
|
21 |
'''
|
|
|
118 |
vectorizer = ImageVectorizer()
|
119 |
collection = get_milvus_collection()
|
120 |
|
121 |
+
try:
|
122 |
+
st.markdown("<h3>Find Similar Vegetable Images</h3>", unsafe_allow_html=True)
|
123 |
+
desc = '''<p style="font-size: 15px;">Allowed Vegetables: Broad Bean, Bitter Gourd, Bottle Gourd,
|
124 |
+
Green Round Brinjal, Broccoli, Cabbage, Capsicum, Carrot, Cauliflower, Cucumber,
|
125 |
+
Raw Papaya, Potato, Green Pumpkin, Radish, Tomato.
|
126 |
+
</p>
|
127 |
+
<p style="font-size: 13px;">Image embeddings are extracted from a fine-tuned VGG model. The model is fine-tuned on <a href="https://www.kaggle.com/datasets/misrakahmed/vegetable-image-dataset" target="_blank">images</a> clicked using a mobile phone camera.
|
128 |
+
Embeddings of 20,000 vegetable images are stored in Milvus vector database. Embeddings of the input image are computed and 15 most similar images (based on L2 distance) are displayed.</p>
|
129 |
+
'''
|
130 |
+
st.markdown(desc, unsafe_allow_html=True)
|
131 |
+
img_url = st.text_input("Paste the image URL of a vegetable and hit Enter:", "")
|
132 |
+
placeholder = st.empty()
|
133 |
+
if img_url:
|
134 |
+
placeholder.empty()
|
135 |
+
img_path = process_input_image(img_url)
|
136 |
+
find_similar_images(img_path, 15)
|
137 |
+
delete_file(os.path.dirname(img_path))
|
138 |
+
except Exception as e:
|
139 |
+
st.error(f'An unexpected error occured: \n{e}')
|
|
|
|
|
|
|
|
|
|