File size: 2,312 Bytes
a760903 bc5cccc a760903 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | ---
license: cc-by-nc-sa-4.0
language:
- zh
- en
tags:
- medical
---
---
# SkinGPT-R1
**SkinGPT-R1** is a dermatological reasoning vision Language model (VLM).
## ⚠️ Disclaimer
This model is **for research and educational use only**. It is **NOT a substitute for professional medical advice, diagnosis, or treatment**.
## 🛠️ Environment Setup
To ensure compatibility, we strongly recommend creating a fresh Conda environment.
### 1. Create Conda Environment
Create a new environment named skingpt-r1 with Python 3.10:
```bash
conda create -n skingpt-r1 python=3.10 -y
conda activate skingpt-r1
```
### 2. Install Dependencies
```bash
pip install -r requirements.txt
```
### (Optional) For faster inference on NVIDIA GPUs:
```bash
pip install flash-attn --no-build-isolation
```
## 🚀 Usage
### Quick Start
If you just installed the environment and want to check if it works:
Open ***demo.py*** and Change the ***IMAGE_PATH*** variable to your image file.
```bash
python demo.py
```
### Interactive Chat
To have a multi-turn conversation (e.g., asking follow-up questions about the diagnosis) in your terminal:
```bash
python chat.py --image ./test_images/lesion.jpg
```
### FastAPI Backend Deployment
To deploy the model as a backend service (supporting image uploads and session management):
#### Start the Server
```bash
python app.py
```
#### API Workflow
Manage sessions via state_id to support multi-user history.
Upload: POST /v1/upload/{state_id} — Uploads an image for the session.
Chat: POST /v1/predict/{state_id} — Sends text (JSON: {"message": "..."}) and gets a response.
Reset: POST /v1/reset/{state_id} — Clears session history and images.
#### Client Example
```python
import requests
API_URL = "http://localhost:5900"
STATE_ID = "patient_001"
# 1. Upload Image
with open("skin_image.jpg", "rb") as f:
requests.post(f"{API_URL}/v1/upload/{STATE_ID}", files={"file": f})
# 2. Ask for Diagnosis
response = requests.post(
f"{API_URL}/v1/predict/{STATE_ID}",
json={"message": "Please analyze this image."}
)
print("AI:", response.json()["message"])
# 3. Ask Follow-up
response = requests.post(
f"{API_URL}/v1/predict/{STATE_ID}",
json={"message": "What treatment do you recommend?"}
)
print("AI:", response.json()["message"])
``` |