Classifies dermatoscopic images into 7 diagnostic categories covering the most common pigmented skin lesions encountered in clinical practice.
HAM10000 (Human Against Machine with 10,000 training images)
Reference: Tschandl et al. 2018, Nature - "The HAM10000 dataset, a large collection of multi-source dermatoscopic images of common pigmented skin lesions"
1from transformers import AutoProcessor, AutoModelForImageTextToText
2from peft import PeftModel
3from PIL import Image
4
5# Load base model + adapter
6base_model_id = "google/medgemma-4b-it"
7adapter_id = "efecelik/medgemma-dermatology-lora"
8
9processor = AutoProcessor.from_pretrained(base_model_id)
10model = AutoModelForImageTextToText.from_pretrained(
11 base_model_id, torch_dtype="bfloat16", device_map="auto"
12)
13model = PeftModel.from_pretrained(model, adapter_id)
14
15# Prepare input
16image = Image.open("skin_lesion.jpg").convert("RGB")
17messages = [
18 {"role": "user", "content": [
19 {"type": "image"},
20 {"type": "text", "text": "Classify this dermatoscopic skin lesion image."}
21 ]}
22]
23
24inputs = processor.apply_chat_template(
25 messages, add_generation_prompt=True, tokenize=True,
26 return_dict=True, return_tensors="pt", images=[image]
27).to(model.device)
28
29output = model.generate(**inputs, max_new_tokens=256)
30print(processor.decode(output[0], skip_special_tokens=True))
This adapter is part of the
MedVision AI platform built for the
MedGemma Impact Challenge. It is designed for:
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}