unsloth/Radiology_mini
Viewer โข Updated โข 2.31k โข 701 โข 50
How to use Omarrran/Hnm_Llama3_2_Vision_lora_model with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("image-text-to-text", model="Omarrran/Hnm_Llama3_2_Vision_lora_model")
messages = [
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},
{"type": "text", "text": "What animal is on the candy?"}
]
},
]
pipe(text=messages) # pip install -U transformers accelerate
# Load model directly
from transformers import AutoProcessor, AutoModelForMultimodalLM
processor = AutoProcessor.from_pretrained("Omarrran/Hnm_Llama3_2_Vision_lora_model")
model = AutoModelForMultimodalLM.from_pretrained("Omarrran/Hnm_Llama3_2_Vision_lora_model", device_map="auto")
messages = [
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},
{"type": "text", "text": "What animal is on the candy?"}
]
},
]
inputs = processor.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(model.device)
outputs = model.generate(**inputs, max_new_tokens=256)
print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:]))How to use Omarrran/Hnm_Llama3_2_Vision_lora_model with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "Omarrran/Hnm_Llama3_2_Vision_lora_model"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Omarrran/Hnm_Llama3_2_Vision_lora_model",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this image in one sentence."
},
{
"type": "image_url",
"image_url": {
"url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
}
}
]
}
]
}'docker model run hf.co/Omarrran/Hnm_Llama3_2_Vision_lora_model
How to use Omarrran/Hnm_Llama3_2_Vision_lora_model with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "Omarrran/Hnm_Llama3_2_Vision_lora_model" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Omarrran/Hnm_Llama3_2_Vision_lora_model",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this image in one sentence."
},
{
"type": "image_url",
"image_url": {
"url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
}
}
]
}
]
}'docker run --gpus all \
--shm-size 32g \
-p 30000:30000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HF_TOKEN=<secret>" \
--ipc=host \
lmsysorg/sglang:latest \
python3 -m sglang.launch_server \
--model-path "Omarrran/Hnm_Llama3_2_Vision_lora_model" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Omarrran/Hnm_Llama3_2_Vision_lora_model",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this image in one sentence."
},
{
"type": "image_url",
"image_url": {
"url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
}
}
]
}
]
}'How to use Omarrran/Hnm_Llama3_2_Vision_lora_model with Docker Model Runner:
docker model run hf.co/Omarrran/Hnm_Llama3_2_Vision_lora_model
The Hnm_Llama3.2_(11B)-Vision_lora_model is a fine-tuned version of Llama 3.2 (11B) Vision with LoRA-based parameter-efficient fine-tuning (PEFT). It specializes in vision-language tasks, particularly for medical image captioning and understanding.
This model was fine-tuned on a Tesla T4 (Google Colab) using Unsloth, a framework designed for efficient fine-tuning of large models.
unsloth/Llama-3.2-11B-Vision-Instructunsloth/Radiology_minifrom unsloth import FastVisionModel
model, tokenizer = FastVisionModel.from_pretrained(
"Hnm_Llama3.2_(11B)-Vision_lora_model",
load_in_4bit=True # Set to False for full precision
)
import torch
from transformers import TextStreamer
FastVisionModel.for_inference(model) # Enable inference mode
# Load an image from dataset
dataset = load_dataset("unsloth/Radiology_mini", split="train")
image = dataset[0]["image"]
instruction = "Describe this medical image accurately."
messages = [
{"role": "user", "content": [
{"type": "image"},
{"type": "text", "text": instruction}
]}
]
input_text = tokenizer.apply_chat_template(messages, add_generation_prompt=True)
inputs = tokenizer(
image,
input_text,
add_special_tokens=False,
return_tensors="pt"
).to("cuda")
text_streamer = TextStreamer(tokenizer, skip_prompt=True)
_ = model.generate(**inputs, streamer=text_streamer, max_new_tokens=128,
use_cache=True, temperature=1.5, min_p=0.1)
If you use this model, please cite:
@misc{Hnm_Llama3.2_11B_Vision,
author = {Haq Nawaz Malik},
title = {Fine-tuned Llama 3.2 (11B) Vision Model},
year = {2025},
url = {https://huggingface.co/Omarrran/Hnm_Llama3_2_Vision_lora_model}
}
For any questions or support, reach out via: