Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -43,32 +43,17 @@ geolocator = Nominatim(user_agent="skin-dashboard", timeout = 10)
|
|
43 |
|
44 |
@st.cache_resource
|
45 |
def load_image_model(token: str):
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
)
|
57 |
|
58 |
-
# 3) Load *just the weights* from your repo, using the config override
|
59 |
-
model = AutoModelForImageClassification.from_pretrained(
|
60 |
-
MODEL_NAME,
|
61 |
-
config=config,
|
62 |
-
use_auth_token=token,
|
63 |
-
)
|
64 |
-
|
65 |
-
# 4) Return the pipeline
|
66 |
-
return pipeline(
|
67 |
-
"image-classification",
|
68 |
-
model=model,
|
69 |
-
feature_extractor=extractor,
|
70 |
-
device=0, # or -1 for CPU
|
71 |
-
)
|
72 |
|
73 |
@st.cache_resource
|
74 |
def load_llm(token: str):
|
|
|
43 |
|
44 |
@st.cache_resource
|
45 |
def load_image_model(token: str):
|
46 |
+
"""
|
47 |
+
Load the pre-trained skin cancer classification model using PyTorch.
|
48 |
+
"""
|
49 |
+
try:
|
50 |
+
extractor = AutoFeatureExtractor.from_pretrained("Anwarkh1/Skin_Cancer-Image_Classification")
|
51 |
+
model = AutoModelForImageClassification.from_pretrained("Anwarkh1/Skin_Cancer-Image_Classification")
|
52 |
+
return pipeline("image-classification", model=model, feature_extractor=extractor, framework="pt")
|
53 |
+
except Exception as e:
|
54 |
+
st.error(f"Error loading the model: {e}")
|
55 |
+
return None
|
|
|
56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
@st.cache_resource
|
59 |
def load_llm(token: str):
|