MoritzMMuller commited on
Commit
128f6e3
·
verified ·
1 Parent(s): f747da6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -25
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
- # 1) Grab a working ConvNeXt feature extractor from the official base model
47
- extractor = AutoFeatureExtractor.from_pretrained(
48
- "microsoft/convnext-base-224"
49
- )
50
-
51
- # 2) Build a minimal ConvNextConfig that matches your fine-tuned head
52
- config = ConvNextConfig(
53
- num_labels=2,
54
- id2label={0: "benign", 1: "malignant"},
55
- label2id={"benign": 0, "malignant": 1},
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):