Views
No views yet
⚠️ MEDICAL & REGULATORY DISCLAIMERThis model is for educational and research purposes only.
- Must NOT be used in real-world/clinical applications (screening, triage, diagnosis, or treatment).
- Not a medical device and not reviewed/approved by any regulator (e.g., FDA/MHRA).
- Outputs must NOT replace clinical judgment. All suspicious lesions should be evaluated by a qualified clinician.
| Metric | Value |
|---|---|
| Accuracy | 81.59% |
| ROC-AUC | 0.8900 |
| PR-AUC | 0.6602 |
| Precision | 0.5121 |
| Recall | 0.8056 |
| Loss | 0.4426 |
pip install tensorflow huggingface_hub pillow numpy1# Import required libraries
2from huggingface_hub import hf_hub_download
3import tensorflow as tf
4import numpy as np
5from PIL import Image
6
7# Download model from Hugging Face
8print("Downloading model from Hugging Face...")
9model_path = hf_hub_download(
10 repo_id="devatreya/skin-lesion-resnet50",
11 filename="resnet50_best.h5"
12)
13
14# Load model
15print("Loading model...")
16model = tf.keras.models.load_model(model_path)
17
18# Preprocess image function
19def preprocess_image(image_path):
20 """Load and preprocess image for ResNet50"""
21 img = Image.open(image_path).convert('RGB')
22 img = img.resize((224, 224))
23 img_array = np.array(img, dtype=np.float32)
24
25 # ResNet50 preprocessing (ImageNet/Caffe-style)
26 img_array = img_array[..., ::-1] # RGB to BGR
27 mean = [103.939, 116.779, 123.68]
28 img_array[..., 0] -= mean[0]
29 img_array[..., 1] -= mean[1]
30 img_array[..., 2] -= mean[2]
31
32 return np.expand_dims(img_array, axis=0)
33
34# Run inference
35image_path = "path/to/your/lesion_image.jpg" # Change this
36img_array = preprocess_image(image_path)
37prediction = model.predict(img_array)[0][0]
38
39# Display result
40print(f"\n{'='*50}")
41print(f"Prediction: {'MALIGNANT' if prediction >= 0.5 else 'BENIGN'}")
42print(f"Confidence: {prediction:.2%}")
43print(f"{'='*50}")GlobalAveragePooling2D
↓
BatchNormalization
↓
Dropout (0.5)
↓
Dense (512, ReLU)
↓
BatchNormalization
↓
Dropout (0.5)
↓
Dense (256, ReLU)
↓
Dropout (0.3)
↓
Dense (1, Sigmoid)Educational use only — NOT for real-world or clinical applications.
1@article{tschandl2018ham10000,
2 title={The HAM10000 dataset, a large collection of multi-source dermatoscopic images of common pigmented skin lesions},
3 author={Tschandl, Philipp and Rosendahl, Cliff and Kittler, Harald},
4 journal={Scientific data},
5 volume={5},
6 number={1},
7 pages={1--9},
8 year={2018},
9 publisher={Nature Publishing Group}
10}resnet50_best.h5 (214 MB)