davidlee1102 commited on
Commit
455e6c5
1 Parent(s): 4e203e3
.DS_Store ADDED
Binary file (6.15 kB). View file
 
.idea/.gitignore ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
4
+ # Editor-based HTTP Client requests
5
+ /httpRequests/
6
+ # Datasource local storage ignored files
7
+ /dataSources/
8
+ /dataSources.local.xml
.idea/hungle_image_retrieval_surrey2023.iml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="PYTHON_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$" />
5
+ <orderEntry type="jdk" jdkName="Python 3.10 (diabetes_grading_surreyaml_2023) (2)" jdkType="Python SDK" />
6
+ <orderEntry type="sourceFolder" forTests="false" />
7
+ </component>
8
+ </module>
.idea/inspectionProfiles/profiles_settings.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <component name="InspectionProjectProfileManager">
2
+ <settings>
3
+ <option name="USE_PROJECT_PROFILE" value="false" />
4
+ <version value="1.0" />
5
+ </settings>
6
+ </component>
.idea/misc.xml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (diabetes_grading_surreyaml_2023) (2)" project-jdk-type="Python SDK" />
4
+ </project>
.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/hungle_image_retrieval_surrey2023.iml" filepath="$PROJECT_DIR$/.idea/hungle_image_retrieval_surrey2023.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
app.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import streamlit as st
3
+ import tensorflow as tf
4
+
5
+ from PIL import Image
6
+ from scipy.spatial.distance import euclidean
7
+
8
+ st.title("Surrey 2023 - Image Retrieval")
9
+ # # Load your TensorFlow model
10
+ # model = tf.keras.models.load_model("model/adcv_model")
11
+
12
+
13
+ def preprocess_image(image, target_size=(128, 128)):
14
+ image = image.resize(target_size)
15
+ image_array = np.array(image) # / 255.0
16
+ return np.expand_dims(image_array, axis=0)
17
+
18
+
19
+ def distance_quadruplet(result):
20
+ distance_list = []
21
+ for i in range(1, len(result)):
22
+ distance = euclidean(result[0], result[i])
23
+ distance_list.append(1 / (1 + distance))
24
+ return distance_list
25
+
26
+
27
+ col1, col2 = st.columns(2)
28
+
29
+ image_list = st.file_uploader("Choose List Image You Want To Search - No More Than 10 Images", type=["jpg", "jpeg", "png"], accept_multiple_files=True)
30
+ image_query = st.file_uploader("Choose Images For Querying", type=["jpg", "jpeg", "png"], accept_multiple_files=False)
31
+
32
+
33
+ image_process_list = []
34
+ image_query_process = []
35
+ if image_list is not None:
36
+ if len(image_list) >= 10:
37
+ col1.write("Your list image have problem - Try to refresh and upload again")
38
+ else:
39
+ count = 0
40
+ columns = st.columns(10)
41
+ for i, uploaded_file in enumerate(image_list):
42
+ img = Image.open(uploaded_file).convert('RGB')
43
+ img = img.resize((128, 128))
44
+ image_process_list.append(img)
45
+ if count <= 10:
46
+ count += 1
47
+ columns[i].image(img, caption=f"Uploaded image: {uploaded_file.name}", width=64)
48
+ else:
49
+ col1.write("Upload Image")
50
+
51
+ if image_query is not None:
52
+ img_qr = Image.open(uploaded_file).convert('RGB')
53
+ img_qr = img_qr.resize((128, 128))
54
+ image_query_process.append(img_qr)
55
+ col1.image(img_qr, caption="Query Image", use_column_width=True, width=98)
56
+ else:
57
+ col1.write("Upload Image")
58
+
59
+ image_pr = []
60
+ if st.button("Classify"):
61
+ image_pr = image_process_list + image_query_process
62
+ image_pr = np.stack(image_pr)
63
+
64
+ col2.write(f"len image: {type(image_pr[0])}, {len(image_pr)}")
requirements.txt ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ absl-py==1.3.0
2
+ aiohttp==3.8.3
3
+ aiosignal==1.2.0
4
+ altair
5
+ appdirs==1.4.4
6
+ appnope==0.1.2
7
+ asttokens==2.0.5
8
+ astunparse==1.6.3
9
+ async-timeout==4.0.2
10
+ attrs==22.1.0
11
+ backcall==0.2.0
12
+ blinker==1.4
13
+ Bottleneck
14
+ brotlipy==0.7.0
15
+ cachetools==4.2.2
16
+ certifi==2022.12.7
17
+ cffi==1.15.1
18
+ charset-normalizer==2.0.4
19
+ click==8.0.4
20
+ comm==0.1.2
21
+ commonmark==0.9.1
22
+ cryptography==39.0.1
23
+ debugpy==1.5.1
24
+ decorator==5.1.1
25
+ entrypoints==0.4
26
+ executing==0.8.3
27
+ flatbuffers==2.0
28
+ frozenlist==1.3.3
29
+ future==0.18.3
30
+ gast==0.4.0
31
+ gitdb==4.0.7
32
+ GitPython==3.1.30
33
+ google-auth==2.6.0
34
+ google-auth-oauthlib==0.4.4
35
+ google-pasta==0.2.0
36
+ grpcio==1.42.0
37
+ h5py
38
+ idna==3.4
39
+ importlib-metadata==6.0.0
40
+ ipykernel==6.19.2
41
+ ipython==8.12.0
42
+ ipywidgets==8.0.4
43
+ jedi==0.18.1
44
+ Jinja2==3.1.2
45
+ jsonschema==4.17.3
46
+ jupyter_client==8.1.0
47
+ jupyter_core==5.3.0
48
+ jupyterlab-widgets==3.0.5
49
+ keras==2.10.0
50
+ Keras-Preprocessing
51
+ Markdown==3.4.1
52
+ MarkupSafe==2.1.1
53
+ matplotlib-inline==0.1.6
54
+ mkl-fft
55
+ mkl-random==1.2.2
56
+ mkl-service==2.4.0
57
+ multidict==6.0.2
58
+ nest-asyncio==1.5.6
59
+ numexpr==2.8.4
60
+ numpy
61
+ oauthlib==3.2.2
62
+ opt-einsum==3.3.0
63
+ packaging==23.0
64
+ pandas==1.5.3
65
+ parso==0.8.3
66
+ pexpect==4.8.0
67
+ pickleshare==0.7.5
68
+ Pillow==9.4.0
69
+ pip==23.0.1
70
+ platformdirs==2.5.2
71
+ pooch==1.4.0
72
+ prompt-toolkit==3.0.36
73
+ protobuf
74
+ psutil==5.9.0
75
+ ptyprocess==0.7.0
76
+ pure-eval==0.2.2
77
+ pyarrow==11.0.0
78
+ pyasn1==0.4.8
79
+ pyasn1-modules==0.2.8
80
+ pycparser==2.21
81
+ pydeck==0.7.1
82
+ Pygments==2.11.2
83
+ PyJWT==2.4.0
84
+ Pympler==0.9
85
+ pyOpenSSL==23.0.0
86
+ pyrsistent==0.18.0
87
+ PySocks==1.7.1
88
+ python-dateutil==2.8.2
89
+ pytz==2022.7
90
+ pyzmq==23.2.0
91
+ requests==2.28.1
92
+ requests-oauthlib==1.3.0
93
+ rich==12.5.1
94
+ rsa==4.7.2
95
+ scipy==1.10.0
96
+ semver==2.13.0
97
+ setuptools==66.0.0
98
+ six==1.16.0
99
+ smmap==4.0.0
100
+ stack-data==0.2.0
101
+ streamlit==1.16.0
102
+ tensorboard==2.10.0
103
+ tensorboard-data-server==0.6.1
104
+ tensorboard-plugin-wit==1.7.0
105
+ tensorflow==2.10.0
106
+ tensorflow-estimator==2.10.0
107
+ termcolor==2.1.0
108
+ toml==0.10.2
109
+ toolz==0.12.0
110
+ tornado==6.2
111
+ traitlets==5.7.1
112
+ typing_extensions==4.5.0
113
+ tzlocal==2.1
114
+ urllib3==1.26.15
115
+ validators==0.18.2
116
+ wcwidth==0.2.5
117
+ Werkzeug==2.2.3
118
+ wheel==0.35.1
119
+ widgetsnbextension==4.0.5
120
+ wrapt==1.14.1
121
+ yarl==1.8.1
122
+ zipp==3.11.0