Spaces:
Runtime error
Runtime error
Commit
·
4a66a1a
1
Parent(s):
480d9cd
Update app.py
Browse files
app.py
CHANGED
|
@@ -130,7 +130,8 @@ def load_saved_artifacts():
|
|
| 130 |
global __model
|
| 131 |
if __model is None:
|
| 132 |
__model = joblib.load('saved_model.pkl')
|
| 133 |
-
st.text("loading saved artifacts...done")
|
|
|
|
| 134 |
|
| 135 |
def class_number_to_name(class_num):
|
| 136 |
return __class_number_to_name[class_num]
|
|
@@ -157,36 +158,33 @@ if uploaded_image is not None:
|
|
| 157 |
if image_dict["complete"]:
|
| 158 |
display_image = image_dict["filename"]
|
| 159 |
st.header("Image Uploded!, Processing...")
|
| 160 |
-
load_saved_artifacts()
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
elif celeb == "virat_kohli":
|
| 188 |
-
virat = cv2.imread("virat.jpeg")
|
| 189 |
-
st.image(virat,width=150, caption='Virat Kohli')
|
| 190 |
|
| 191 |
|
| 192 |
|
|
|
|
| 130 |
global __model
|
| 131 |
if __model is None:
|
| 132 |
__model = joblib.load('saved_model.pkl')
|
| 133 |
+
#st.text("loading saved artifacts...done")
|
| 134 |
+
return True
|
| 135 |
|
| 136 |
def class_number_to_name(class_num):
|
| 137 |
return __class_number_to_name[class_num]
|
|
|
|
| 158 |
if image_dict["complete"]:
|
| 159 |
display_image = image_dict["filename"]
|
| 160 |
st.header("Image Uploded!, Processing...")
|
| 161 |
+
if load_saved_artifacts():
|
| 162 |
+
img = cv2.imread(display_image)
|
| 163 |
+
|
| 164 |
+
result = classify_image(get_b64_test_image_for_virat(), display_image)
|
| 165 |
+
#st.text(result[0])
|
| 166 |
+
|
| 167 |
+
col6,col7 = st.columns(2)
|
| 168 |
+
with col6:
|
| 169 |
+
st.image(img,width=130, caption='Uploaded Image')
|
| 170 |
+
with col7:
|
| 171 |
+
celeb = result[0]['class']
|
| 172 |
+
st.text("Your Predicted Sports Person is: " + result[0]['class'])
|
| 173 |
+
if celeb == "lionel_messi":
|
| 174 |
+
messi = cv2.imread("messi.jpeg")
|
| 175 |
+
st.image(messi,width=150, caption='Lionel Messi')
|
| 176 |
+
elif celeb == "maria_sharapova":
|
| 177 |
+
maria = cv2.imread("sharapova.jpeg")
|
| 178 |
+
st.image(maria,width=150, caption='Maria Sharapova')
|
| 179 |
+
elif celeb == "roger_federer":
|
| 180 |
+
roger = cv2.imread("federer.jpeg")
|
| 181 |
+
st.image(roger,width=150, caption='Roger Federer')
|
| 182 |
+
elif celeb == "serena_williams":
|
| 183 |
+
serena = cv2.imread("serena.jpeg")
|
| 184 |
+
st.image(serena,width=150, caption='Serena Williams')
|
| 185 |
+
elif celeb == "virat_kohli":
|
| 186 |
+
virat = cv2.imread("virat.jpeg")
|
| 187 |
+
st.image(virat,width=150, caption='Virat Kohli')
|
|
|
|
|
|
|
|
|
|
| 188 |
|
| 189 |
|
| 190 |
|