nampham1106 commited on
Commit
ab9b7a8
1 Parent(s): 496dcb6

first commit

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ /data filter=lfs diff=lfs merge=lfs -text
37
+ /data/. filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import torch
3
+ import os
4
+
5
+ from PIL import Image
6
+ from utils.search import search_images
7
+
8
+ device = "cuda" if torch.cuda.is_available() else "cpu"
9
+ st.set_page_config(layout="wide")
10
+
11
+ search_path = None
12
+
13
+ def show_image(result):
14
+ col1, col2, col3 = st.columns(3)
15
+
16
+ image_folder2 = "./data/images_mr"
17
+ for idx, image_name in enumerate(result.ids):
18
+ if idx % 3 == 0:
19
+ with col1:
20
+ file_name = str(image_name) + ".jpg"
21
+ image_path = os.path.join(image_folder2, file_name)
22
+ st.image(image_path, caption=image_name, width=200)
23
+ elif idx % 3 == 1:
24
+ with col2:
25
+ file_name = str(image_name) + ".jpg"
26
+ image_path = os.path.join(image_folder2, file_name)
27
+ st.image(image_path, caption=image_name, width=200)
28
+ else:
29
+ with col3:
30
+ file_name = str(image_name) + ".jpg"
31
+ image_path = os.path.join(image_folder2, file_name)
32
+ st.image(image_path, caption=image_name, width=200)
33
+
34
+ image_folder1 = "./examples"
35
+ image_paths = []
36
+ for file_name in os.listdir(image_folder1):
37
+ image_paths.append(os.path.join(image_folder1, file_name))
38
+ # st.write(image_paths)
39
+
40
+ with st.sidebar:
41
+ if st.sidebar.button("Choose a examples"):
42
+ search_path = image_paths[0]
43
+ st.image(image_paths[0], caption="example", width=150)
44
+
45
+ search_term = st.file_uploader(label="Chose a file", type=["jpg", "png"])
46
+ if search_term is None:
47
+ st.text("Please upload a image!")
48
+ else:
49
+ image = Image.open(search_term).convert('RGB')
50
+ st.image(image, width=300)
51
+ if search_term:
52
+ button = st.sidebar.button("Search")
53
+ if button:
54
+ search_path = search_term
55
+
56
+
57
+ st.header("Image Retrieval")
58
+ st.write("This is a simple app for image retrieval using Resnet18 and Vector Database")
59
+
60
+
61
+
62
+ if search_path is not None:
63
+ result = search_images(search_path)
64
+ show_image(result)
65
+
66
+
data/images_mr/0.jpg ADDED
data/images_mr/1.jpg ADDED
data/images_mr/10.jpg ADDED
data/images_mr/100.jpg ADDED
data/images_mr/1000.jpg ADDED
data/images_mr/1001.jpg ADDED
data/images_mr/1002.jpg ADDED
data/images_mr/1003.jpg ADDED
data/images_mr/1004.jpg ADDED
data/images_mr/1005.jpg ADDED
data/images_mr/1006.jpg ADDED
data/images_mr/1007.jpg ADDED
data/images_mr/1008.jpg ADDED
data/images_mr/1009.jpg ADDED
data/images_mr/101.jpg ADDED
data/images_mr/1010.jpg ADDED
data/images_mr/1011.jpg ADDED
data/images_mr/1012.jpg ADDED
data/images_mr/1013.jpg ADDED
data/images_mr/1014.jpg ADDED
data/images_mr/1015.jpg ADDED
data/images_mr/1016.jpg ADDED
data/images_mr/1017.jpg ADDED
data/images_mr/1018.jpg ADDED
data/images_mr/1019.jpg ADDED
data/images_mr/102.jpg ADDED
data/images_mr/1020.jpg ADDED
data/images_mr/1021.jpg ADDED
data/images_mr/1022.jpg ADDED
data/images_mr/1023.jpg ADDED
data/images_mr/1024.jpg ADDED
data/images_mr/1025.jpg ADDED
data/images_mr/1026.jpg ADDED
data/images_mr/1027.jpg ADDED
data/images_mr/1028.jpg ADDED
data/images_mr/1029.jpg ADDED
data/images_mr/103.jpg ADDED
data/images_mr/1030.jpg ADDED
data/images_mr/1031.jpg ADDED
data/images_mr/1032.jpg ADDED
data/images_mr/1033.jpg ADDED
data/images_mr/1034.jpg ADDED
data/images_mr/1035.jpg ADDED
data/images_mr/1036.jpg ADDED
data/images_mr/1037.jpg ADDED
data/images_mr/1038.jpg ADDED
data/images_mr/1039.jpg ADDED
data/images_mr/104.jpg ADDED