Views
No views yet
| 번호 | 질환명 | 영문명 | Code |
|---|---|---|---|
| 0 | 광선각화증 | Actinic Keratosis | AK |
| 1 | 기저세포암 | Basal Cell Carcinoma | BCC |
| 2 | 멜라닌세포모반 | Melanocytic Nevus | MN |
| 3 | 보웬병 | Bowen's Disease | BD |
| 4 | 비립종 | Milia | MI |
| 5 | 사마귀 | Wart | WA |
| 6 | 악성흑색종 | Malignant Melanoma | MM |
| 7 | 지루각화증 | Seborrheic Keratosis | SK |
| 8 | 편평세포암 | Squamous Cell Carcinoma | SCC |
| 9 | 표피낭종 | Epidermal Cyst | EC |
| 10 | 피부섬유종 | Dermatofibroma | DF |
| 11 | 피지샘증식증 | Sebaceous Hyperplasia | SH |
| 12 | 혈관종 | Hemangioma | HE |
| 13 | 화농 육아종 | Pyogenic Granuloma | PG |
| 14 | 흑색점 | Lentigo | LE |
1from openai import OpenAI
2import base64
3
4# 현재 사용 중인 설정 (localhost의 vLLM 서버)
5client = OpenAI(
6 api_key="empty", # vLLM은 빈 키 사용
7 base_url="http://localhost:8001/v1" # vLLM 서버 주소
8)
9
10# 또는 RunPod 엔드포인트 사용 시
11# client = OpenAI(
12# api_key="rpa_토큰",
13# base_url="https://api.runpod.ai/v2/엔드포인트/openai/v1"
14# )
15
16# 이미지 인코딩
17def encode_image(path):
18 with open(path, "rb") as f:
19 return base64.b64encode(f.read()).decode("utf-8")
20
21# 피부 진단 instruction (한국어)
22instruction = """너는 피부 병변을 진단하는 전문 AI이다. 다음은 네가 진단할 수 있는 피부 병변 목록이며, 각 병변의 임상적 특징은 아래와 같다. 환자에게 나타난 병변의 이미지와 설명을 바탕으로 가장 적합한 질병을 하나 선택하여 진단하라.
23
240: 광선각화증
251: 기저세포암
262: 멜라닌세포모반
273: 보웬병
284: 비립종
295: 사마귀
306: 악성흑색종
317: 지루각화증
328: 편평세포암
339: 표피낭종
3410: 피부섬유종
3511: 피지샘증식증
3612: 혈관종
3713: 화농 육아종
3814: 흑색점
39
40<root><label id_code="{코드}" score="{점수}">{진단명}</label><summary>{진단소견}</summary><similar_labels><similar_label id_code="{코드}" score="{점수}">{유사질병명}</similar_label></similar_labels></root>
41"""
42
43# 진단 수행
44image_base64 = encode_image("path_to_skin_image.jpg")
45response = client.chat.completions.create(
46 model="model_name", # vLLM에서 로드된 모델명
47 messages=[
48 {
49 "role": "user",
50 "content": [
51 {"type": "text", "text": instruction},
52 {
53 "type": "image_url",
54 "image_url": {
55 "url": f"data:image/jpeg;base64,{image_base64}",
56 },
57 },
58 ],
59 }
60 ],
61)
62
63print(response.choices[0].message.content)1<root>
2<label id_code="1" score="85.2">기저세포암</label>
3<summary>이미지에서는 진주빛 반투명 결절 형태의 병변이 관찰됩니다. 이러한 병변은 일반적으로 천천히 성장하며 주변 조직으로 깊게 침습할 수 있는 특성을 가지고 있습니다...</summary>
4<similar_labels>
5<similar_label id_code="3" score="12.0">보웬병</similar_label>
6<similar_label id_code="0" score="8.5">광선각화증</similar_label>
7</similar_labels>
8</root>class_performance.csv 파일을 참조하세요.| 클래스 | Precision | Recall | F1-Score |
|---|---|---|---|
| 광선각화증 | 0.929 | 0.382 | 0.542 |
| 기저세포암 | 0.786 | 0.595 | 0.677 |
| 멜라닌세포모반 | 0.679 | 1.000 | 0.809 |
| 보웬병 | 0.615 | 0.552 | 0.582 |
| 비립종 | 0.905 | 0.950 | 0.927 |
| 사마귀 | 0.829 | 0.895 | 0.861 |
| 악성흑색종 | 0.517 | 0.455 | 0.484 |
| 지루각화증 | 0.732 | 0.789 | 0.759 |
| 편평세포암 | 0.697 | 0.852 | 0.767 |
| 표피낭종 | 0.900 | 0.621 | 0.735 |
| 피부섬유종 | 0.681 | 0.941 | 0.790 |
| 피지샘증식증 | 0.757 | 0.933 | 0.836 |
| 혈관종 | 1.000 | 0.679 | 0.808 |
| 화농 육아종 | 0.745 | 1.000 | 0.854 |
| 흑색점 | 1.000 | 0.719 | 0.836 |
├── evaluation_results.json # 상세 평가 결과
├── class_performance.csv # 클래스별 성능 지표
├── confusion_matrix.png # 혼동행렬 시각화
├── class_performance.png # 성능 차트
└── README.md # 모델 문서 (이 파일)