🚀 PaliGemma皮肤病学模型
本模型基于PaliGemma-3B架构,针对皮肤病学相关的图像和文本处理任务进行了微调。它结合了图像分析和自然语言处理技术,旨在辅助识别各种皮肤状况。
🚀 快速开始
以下是使用该模型的示例代码:
import torch
from transformers import AutoProcessor, PaliGemmaForConditionalGeneration
from PIL import Image
model_id = "brucewayne0459/paligemma_derm"
processor = AutoProcessor.from_pretrained(model_id)
model = PaliGemmaForConditionalGeneration.from_pretrained(model_id, device_map={"": 0})
model.eval()
input_text = "Identify the skin condition?"
input_image_path = " Replace with your actual image path"
input_image = Image.open(input_image_path).convert("RGB")
inputs = processor(text=input_text, images=input_image, return_tensors="pt", padding="longest").to("cuda" if torch.cuda.is_available() else "cpu")
max_new_tokens = 50
with torch.no_grad():
outputs = model.generate(**inputs, max_new_tokens=max_new_tokens)
decoded_output = processor.decode(outputs[0], skip_special_tokens=True)
print("Model Output:", decoded_output)
✨ 主要特性
- 基于PaliGemma-3B架构,专为皮肤病学任务微调。
- 结合图像分析和自然语言处理,辅助识别皮肤状况。
- 可直接用于分析皮肤病图像,洞察潜在皮肤问题。
📦 安装指南
文档未提及安装步骤,故跳过此章节。
💻 使用示例
基础用法
import torch
from transformers import AutoProcessor, PaliGemmaForConditionalGeneration
from PIL import Image
model_id = "brucewayne0459/paligemma_derm"
processor = AutoProcessor.from_pretrained(model_id)
model = PaliGemmaForConditionalGeneration.from_pretrained(model_id, device_map={"": 0})
model.eval()
input_text = "Identify the skin condition?"
input_image_path = " Replace with your actual image path"
input_image = Image.open(input_image_path).convert("RGB")
inputs = processor(text=input_text, images=input_image, return_tensors="pt", padding="longest").to("cuda" if torch.cuda.is_available() else "cpu")
max_new_tokens = 50
with torch.no_grad():
outputs = model.generate(**inputs, max_new_tokens=max_new_tokens)
decoded_output = processor.decode(outputs[0], skip_special_tokens=True)
print("Model Output:", decoded_output)
📚 详细文档
模型详情
模型描述
本模型基于PaliGemma - 3B架构,针对皮肤病学相关的图像和文本处理任务进行了微调。它旨在结合图像分析和自然语言处理技术,辅助识别各种皮肤状况。
- 开发者:Bruce_Wayne
- 模型类型:视觉模型
- 微调基础模型:https://huggingface.co/google/paligemma-3b-pt-224
- 是否使用LoRA适配器:是
- 预期用途:医学图像分析,特别是皮肤病学领域
若想了解模型的工作原理,请访问 -->https://forms.gle/cBA6apSevTyiEbp46
用途
直接使用
该模型可直接用于分析皮肤病图像,洞察潜在的皮肤状况。
偏差、风险和局限性
- 肤色偏差:模型可能在训练时使用了不能充分代表所有肤色的数据集,这可能导致结果出现偏差。
- 地理偏差:模型的性能可能会因不同地理区域某些疾病的流行程度而有所不同。
训练详情
训练数据
模型在包含皮肤病图像和疾病名称的数据集上进行了微调。
训练过程
模型使用LoRA(低秩自适应)进行了微调,以提高训练效率。同时采用了混合精度(bfloat16)来加速训练并减少内存使用。
训练超参数
- 训练模式:混合精度(bfloat16)
- 训练轮数:10
- 学习率:2e - 5
- 批量大小:6
- 梯度累积步数:4
评估
测试数据、因素和指标
测试数据
模型在一个独立的皮肤病图像和疾病名称验证集上进行了评估,该验证集与训练数据不同。
指标
- 验证损失:在训练过程中跟踪该损失,以评估模型性能。
- 准确率:评估模型预测的主要指标。
结果
模型最终的验证损失约为0.2214,表明在基于所用数据集预测皮肤状况方面表现良好。
环境影响
- 硬件类型:1 x L4 GPU
- 使用时长:约22小时
- 云服务提供商:LIGHTNING AI
- 计算区域:美国
- 碳排放:0.9千克二氧化碳当量
技术规格
模型架构和目标
- 架构:基于PaliGemma - 3B的视觉 - 语言模型
- 目标:从图像和文本中对皮肤病状况进行分类和诊断
计算基础设施
硬件
🔧 技术细节
模型架构和目标
- 架构:基于PaliGemma-3B的视觉 - 语言模型
- 目标:从图像和文本中对皮肤病状况进行分类和诊断
计算基础设施
硬件
📄 许可证
本模型采用Apache-2.0许可证。
模型卡片作者
Bruce_Wayne