Spaces:
Sleeping
Sleeping
Update streamlit_app.py
Browse files- streamlit_app.py +5 -12
streamlit_app.py
CHANGED
@@ -25,20 +25,13 @@ except:
|
|
25 |
|
26 |
@st.cache_resource
|
27 |
def load_model():
|
28 |
-
import os
|
29 |
-
import urllib.request
|
30 |
-
|
31 |
-
MODEL_URL = "https://huggingface.co/spaces/leynessa/libkamaja_id/resolve/main/butterfly_classifier.pth"
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
MODEL_PATH = "butterfly_classifier.pth"
|
36 |
-
|
37 |
-
#
|
38 |
if not os.path.exists(MODEL_PATH):
|
39 |
-
st.
|
40 |
-
|
41 |
-
|
42 |
# Load the model
|
43 |
model = models.resnet18(pretrained=False)
|
44 |
model.fc = torch.nn.Linear(model.fc.in_features, len(class_names))
|
|
|
25 |
|
26 |
@st.cache_resource
|
27 |
def load_model():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
MODEL_PATH = "butterfly_classifier.pth"
|
29 |
+
|
30 |
+
# Check if model exists locally
|
31 |
if not os.path.exists(MODEL_PATH):
|
32 |
+
st.error("Model file not found. Please upload butterfly_classifier.pth to your space.")
|
33 |
+
return None
|
34 |
+
|
35 |
# Load the model
|
36 |
model = models.resnet18(pretrained=False)
|
37 |
model.fc = torch.nn.Linear(model.fc.in_features, len(class_names))
|