Spaces:
No application file
No application file
Commit
•
47ba5f2
1
Parent(s):
9223988
Update app.py
Browse files
app.py
CHANGED
@@ -1,25 +1,25 @@
|
|
1 |
# -*- coding: utf-8 -*-
|
2 |
"""demo.ipynb
|
3 |
-
|
4 |
Automatically generated by Colab.
|
5 |
-
|
6 |
Original file is located at
|
7 |
https://colab.research.google.com/drive/10nAdNOzeCbnza9ZenZqOLtvBYn8BKlk5
|
8 |
"""
|
9 |
|
10 |
-
|
11 |
import streamlit as st
|
12 |
from PIL import Image
|
13 |
import numpy as np
|
14 |
from joblib import load
|
15 |
from skimage.transform import resize
|
16 |
-
from google.colab import drive
|
17 |
import os
|
18 |
|
19 |
-
drive.mount('/content/drive')
|
20 |
-
|
21 |
def load_model():
|
22 |
-
model
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
return model
|
24 |
|
25 |
# Function to make predictions
|
@@ -30,7 +30,7 @@ def classify_image(image, model):
|
|
30 |
prediction = model.predict(image_reshaped)
|
31 |
return prediction[0]
|
32 |
|
33 |
-
model = load_model()
|
34 |
|
35 |
# Mapping of Monk classes to colors
|
36 |
monk_colors = {
|
@@ -56,4 +56,3 @@ if uploaded_file is not None:
|
|
56 |
if st.button('Classify'):
|
57 |
prediction = classify_image(image, model)
|
58 |
display_monk_class_color(prediction)
|
59 |
-
|
|
|
1 |
# -*- coding: utf-8 -*-
|
2 |
"""demo.ipynb
|
|
|
3 |
Automatically generated by Colab.
|
|
|
4 |
Original file is located at
|
5 |
https://colab.research.google.com/drive/10nAdNOzeCbnza9ZenZqOLtvBYn8BKlk5
|
6 |
"""
|
7 |
|
|
|
8 |
import streamlit as st
|
9 |
from PIL import Image
|
10 |
import numpy as np
|
11 |
from joblib import load
|
12 |
from skimage.transform import resize
|
|
|
13 |
import os
|
14 |
|
|
|
|
|
15 |
def load_model():
|
16 |
+
# Ensure the model path is correct and accessible from your current directory
|
17 |
+
model_path = 'svm_model3.joblib' # Update this path to where you've saved your model
|
18 |
+
if os.path.exists(model_path):
|
19 |
+
model = load(model_path)
|
20 |
+
st.write("Model loaded successfully!")
|
21 |
+
else:
|
22 |
+
st.error("Model file not found.")
|
23 |
return model
|
24 |
|
25 |
# Function to make predictions
|
|
|
30 |
prediction = model.predict(image_reshaped)
|
31 |
return prediction[0]
|
32 |
|
33 |
+
model = load_model() # Load the model on startup
|
34 |
|
35 |
# Mapping of Monk classes to colors
|
36 |
monk_colors = {
|
|
|
56 |
if st.button('Classify'):
|
57 |
prediction = classify_image(image, model)
|
58 |
display_monk_class_color(prediction)
|
|