Spaces:
Runtime error
Runtime error
Shrikrishna
commited on
Commit
•
edcd422
1
Parent(s):
7fe2560
Update app.py
Browse files
app.py
CHANGED
@@ -14,28 +14,26 @@ __class_name_to_number = {}
|
|
14 |
__class_number_to_name = {}
|
15 |
__model = None
|
16 |
|
17 |
-
st.header("Welcome to
|
18 |
-
col1,col2,col3,col4,col5 = st.columns(
|
19 |
with col1:
|
20 |
-
|
21 |
-
|
22 |
-
st.image(messi,width=150, caption='Lionel Messi')
|
23 |
with col2:
|
24 |
-
|
25 |
-
|
26 |
-
st.image(maria,width=150, caption='Maria Sharapova')
|
27 |
with col3:
|
28 |
-
|
29 |
-
|
30 |
-
st.image(roger,width=150, caption='Roger Federer')
|
31 |
with col4:
|
32 |
-
|
33 |
-
|
34 |
-
st.image(serena,width=150, caption='Serena Williams')
|
35 |
with col5:
|
36 |
virat = cv2.imread("virat.jpeg")
|
37 |
-
|
38 |
-
|
|
|
|
|
39 |
|
40 |
|
41 |
|
@@ -119,17 +117,17 @@ def get_cv2_image_from_base64_string(b64str):
|
|
119 |
return img
|
120 |
|
121 |
def load_saved_artifacts():
|
122 |
-
print("loading saved artifacts...start")
|
123 |
global __class_name_to_number
|
124 |
global __class_number_to_name
|
125 |
|
126 |
-
with open("
|
127 |
__class_name_to_number = json.load(f)
|
128 |
__class_number_to_name = {v:k for k,v in __class_name_to_number.items()}
|
129 |
|
130 |
global __model
|
131 |
if __model is None:
|
132 |
-
__model = joblib.load('
|
133 |
#st.text("loading saved artifacts...done")
|
134 |
return True
|
135 |
|
@@ -163,30 +161,9 @@ if uploaded_image is not None:
|
|
163 |
img = cv2.resize(img, (130, 130))
|
164 |
|
165 |
result = classify_image(get_b64_test_image_for_virat(), display_image)
|
166 |
-
|
|
|
167 |
|
168 |
-
col6,col7 = st.columns(2)
|
169 |
-
with col6:
|
170 |
-
st.header("Uploded Image: ")
|
171 |
-
st.image(img,width=130, caption='Uploaded Image')
|
172 |
-
with col7:
|
173 |
-
celeb = result[0]['class']
|
174 |
-
st.header("Predicted Image: ")
|
175 |
-
if celeb == "lionel_messi":
|
176 |
-
messi = cv2.imread("messi.jpeg")
|
177 |
-
st.image(messi,width=150, caption='Lionel Messi')
|
178 |
-
elif celeb == "maria_sharapova":
|
179 |
-
maria = cv2.imread("sharapova.jpeg")
|
180 |
-
st.image(maria,width=150, caption='Maria Sharapova')
|
181 |
-
elif celeb == "roger_federer":
|
182 |
-
roger = cv2.imread("federer.jpeg")
|
183 |
-
st.image(roger,width=150, caption='Roger Federer')
|
184 |
-
elif celeb == "serena_williams":
|
185 |
-
serena = cv2.imread("serena.jpeg")
|
186 |
-
st.image(serena,width=150, caption='Serena Williams')
|
187 |
-
elif celeb == "virat_kohli":
|
188 |
-
virat = cv2.imread("virat.jpeg")
|
189 |
-
st.image(virat,width=150, caption='Virat Kohli')
|
190 |
|
191 |
|
192 |
|
|
|
14 |
__class_number_to_name = {}
|
15 |
__model = None
|
16 |
|
17 |
+
st.header("Welcome to Indian Cricketers Classifier!")
|
18 |
+
col1,col2,col3,col4,col5,col6 = st.columns(6)
|
19 |
with col1:
|
20 |
+
dhoni = cv2.imread("messi.jpeg")
|
21 |
+
st.image(dhoni,width=100, caption='MS Dhoni')
|
|
|
22 |
with col2:
|
23 |
+
dravid = cv2.imread("sharapova.jpeg")
|
24 |
+
st.image(dravid,width=100, caption='Rahul Dravid')
|
|
|
25 |
with col3:
|
26 |
+
sachin = cv2.imread("federer.jpeg")
|
27 |
+
st.image(sachin,width=100, caption='Sachin Tendulkar')
|
|
|
28 |
with col4:
|
29 |
+
ganguly = cv2.imread("serena.jpeg")
|
30 |
+
st.image(ganguly,width=100, caption='Saurav Ganguly')
|
|
|
31 |
with col5:
|
32 |
virat = cv2.imread("virat.jpeg")
|
33 |
+
st.image(virat,width=100, caption='Virat Kohli')
|
34 |
+
with col5:
|
35 |
+
sehwag = cv2.imread("virat.jpeg")
|
36 |
+
st.image(sehwag,width=100, caption='Virendra Sehwag')
|
37 |
|
38 |
|
39 |
|
|
|
117 |
return img
|
118 |
|
119 |
def load_saved_artifacts():
|
120 |
+
#print("loading saved artifacts...start")
|
121 |
global __class_name_to_number
|
122 |
global __class_number_to_name
|
123 |
|
124 |
+
with open("class_cri_dictionary.json", "r") as f:
|
125 |
__class_name_to_number = json.load(f)
|
126 |
__class_number_to_name = {v:k for k,v in __class_name_to_number.items()}
|
127 |
|
128 |
global __model
|
129 |
if __model is None:
|
130 |
+
__model = joblib.load('cri_saved_model.pkl')
|
131 |
#st.text("loading saved artifacts...done")
|
132 |
return True
|
133 |
|
|
|
161 |
img = cv2.resize(img, (130, 130))
|
162 |
|
163 |
result = classify_image(get_b64_test_image_for_virat(), display_image)
|
164 |
+
st.text(result[0])
|
165 |
+
|
166 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
|
168 |
|
169 |
|