Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,9 @@
|
|
| 1 |
-
import
|
| 2 |
import numpy as np
|
| 3 |
import similarSearch
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
# Function to find similar image IDs for a newly updated image
|
| 6 |
def find_similar_images(new_image):
|
|
@@ -9,14 +12,24 @@ def find_similar_images(new_image):
|
|
| 9 |
print(similar_ids)
|
| 10 |
return similar_ids
|
| 11 |
|
| 12 |
-
#
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
import numpy as np
|
| 3 |
import similarSearch
|
| 4 |
+
from PIL import Image
|
| 5 |
+
|
| 6 |
+
df = pd.read_csv('./gallery.csv')
|
| 7 |
|
| 8 |
# Function to find similar image IDs for a newly updated image
|
| 9 |
def find_similar_images(new_image):
|
|
|
|
| 12 |
print(similar_ids)
|
| 13 |
return similar_ids
|
| 14 |
|
| 15 |
+
# Function to display images from their paths
|
| 16 |
+
def display_images(image_ids):
|
| 17 |
+
for img_id in image_ids:
|
| 18 |
+
image_path = df.loc[df['seller_img_id'] == img_id, 'img_path'].values[0]
|
| 19 |
+
image = Image.open(image_path)
|
| 20 |
+
st.image(image, caption=img_id, use_column_width=True)
|
| 21 |
+
|
| 22 |
+
def main():
|
| 23 |
+
st.title('Image Similarity Finder')
|
| 24 |
+
st.write('Upload an image to find similar image IDs in the database.')
|
| 25 |
+
|
| 26 |
+
uploaded_image_id = st.text_input('Enter Image ID', value='')
|
| 27 |
+
|
| 28 |
+
if st.button('Find Similar Images'):
|
| 29 |
+
similar_image_ids = find_similar_images(uploaded_image_id)
|
| 30 |
+
st.write('Similar Image IDs:', similar_image_ids)
|
| 31 |
+
st.write('Similar Images:')
|
| 32 |
+
display_images(similar_image_ids)
|
| 33 |
|
| 34 |
+
if __name__ == '__main__':
|
| 35 |
+
main()
|