Instructions to use 0llheaven/Llama-3.2-11B-Vision-Radiology-mini with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use 0llheaven/Llama-3.2-11B-Vision-Radiology-mini with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="0llheaven/Llama-3.2-11B-Vision-Radiology-mini") 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)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("0llheaven/Llama-3.2-11B-Vision-Radiology-mini") model = AutoModelForMultimodalLM.from_pretrained("0llheaven/Llama-3.2-11B-Vision-Radiology-mini") 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=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use 0llheaven/Llama-3.2-11B-Vision-Radiology-mini with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "0llheaven/Llama-3.2-11B-Vision-Radiology-mini" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "0llheaven/Llama-3.2-11B-Vision-Radiology-mini", "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" } } ] } ] }'Use Docker
docker model run hf.co/0llheaven/Llama-3.2-11B-Vision-Radiology-mini
- SGLang
How to use 0llheaven/Llama-3.2-11B-Vision-Radiology-mini with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "0llheaven/Llama-3.2-11B-Vision-Radiology-mini" \ --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": "0llheaven/Llama-3.2-11B-Vision-Radiology-mini", "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" } } ] } ] }'Use Docker images
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 "0llheaven/Llama-3.2-11B-Vision-Radiology-mini" \ --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": "0llheaven/Llama-3.2-11B-Vision-Radiology-mini", "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" } } ] } ] }' - Unsloth Studio
How to use 0llheaven/Llama-3.2-11B-Vision-Radiology-mini with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for 0llheaven/Llama-3.2-11B-Vision-Radiology-mini to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for 0llheaven/Llama-3.2-11B-Vision-Radiology-mini to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for 0llheaven/Llama-3.2-11B-Vision-Radiology-mini to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="0llheaven/Llama-3.2-11B-Vision-Radiology-mini", max_seq_length=2048, ) - Docker Model Runner
How to use 0llheaven/Llama-3.2-11B-Vision-Radiology-mini with Docker Model Runner:
docker model run hf.co/0llheaven/Llama-3.2-11B-Vision-Radiology-mini
Uploaded model
- Developed by: Anukul
- Finetuned from model : unsloth/Llama-3.2-11B-Vision-Instruct
- Dataset : unsloth/radiology_mini
Model Overview
The model is designed to assist in interpreting radiology images such as X-rays, CT scans, and MRIs. It can also provide preliminary disease identification to support medical professionals.
This fine-tune the unsloth/Llama-3.2-11B-Vision-Instruct model for a radiology image captioning task. The model has been optimized to be twice as fast as the previous version, allowing for efficient fine-tuning.
Dataset Description
The dataset used for this project is unsloth/radiology_mini, a small-scale dataset derived from the ROCOv2-radiology dataset. It includes: Train Set, Test Set This dataset represents 0.33% of the original dataset found at ROCOv2-radiology on Hugging Face.
Usage
from unsloth import FastVisionModel
from PIL import Image
import numpy as np
import torch
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
# Load model and tokenizer
model, tokenizer = FastVisionModel.from_pretrained(
"0llheaven/Llama-3.2-11B-Vision-Radiology-mini",
load_in_4bit=True,
use_gradient_checkpointing="unsloth",
)
FastVisionModel.for_inference(model)
model.to(device)
def predict_radiology_description(image, instruction):
try:
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(device)
output_ids = model.generate(
**inputs,
max_new_tokens=256,
temperature=1.5,
min_p=0.1
)
generated_text = tokenizer.decode(output_ids[0], skip_special_tokens=True)
return generated_text.replace("assistant", "\n\nassistant").strip()
except Exception as e:
return f"Error: {str(e)}"
# Example of usage!
image_path = 'example_image.jpeg'
instruction = 'You are an expert radiographer. Describe accurately what you see in this image.'
image = Image.open(image_path).convert("RGB")
output = predict_radiology_description(image, instruction)
print(output)
- Downloads last month
- 12
Model tree for 0llheaven/Llama-3.2-11B-Vision-Radiology-mini
Base model
meta-llama/Llama-3.2-11B-Vision-Instruct