Image-Text-to-Text
Transformers
Safetensors
English
mllama
vision-language
multimodal
image-question-answering
biomedical
huggingface
fastvision
conversational
text-generation-inference
Instructions to use Sai1290/X-Rays-LLM with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Sai1290/X-Rays-LLM with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Sai1290/X-Rays-LLM") 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("Sai1290/X-Rays-LLM") model = AutoModelForMultimodalLM.from_pretrained("Sai1290/X-Rays-LLM", 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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Sai1290/X-Rays-LLM with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Sai1290/X-Rays-LLM" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Sai1290/X-Rays-LLM", "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/Sai1290/X-Rays-LLM
- SGLang
How to use Sai1290/X-Rays-LLM 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 "Sai1290/X-Rays-LLM" \ --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": "Sai1290/X-Rays-LLM", "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 "Sai1290/X-Rays-LLM" \ --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": "Sai1290/X-Rays-LLM", "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 Runner
How to use Sai1290/X-Rays-LLM with Docker Model Runner:
docker model run hf.co/Sai1290/X-Rays-LLM
|
Download README.md from Sai1290/X-Rays-LLM: direct link, hf CLI and curl.
- Browser
- Download file 2.66 kB
-
https://huggingface.co/Sai1290/X-Rays-LLM/resolve/main/README.md
- Command line
-
hf download hf://Sai1290/X-Rays-LLM/README.md
-
curl -L -o README.md https://huggingface.co/Sai1290/X-Rays-LLM/resolve/main/README.md
2.66 kB
metadata
tags:
- vision-language
- multimodal
- image-question-answering
- biomedical
- transformers
- huggingface
- fastvision
license: openrail
language:
- en
datasets:
- axiong/pmc_oa_demo
library_name: transformers
model-index:
- name: Medical Image QA Model (PMC-OA)
results: []
🩺 Medical Image QA Model — Vision-Language Expert
This is a multimodal model fine-tuned for image-based biomedical question answering and captioning, based on scientific figures from PMC Open Access subset. The model takes a biomedical image and an optional question, then generates an expert-level description or answer.
🧠 Model Architecture
- Base Model:
FastVisionModel(e.g., a BLIP, MiniGPT4, or Flamingo-style model) - Backbone: Vision encoder + LLM (supports
apply_chat_templatefor prompt formatting) - Trained for Tasks:
- Biomedical image captioning
- Image-based question answering
🧬 Dataset
- Name: axiong/pmc_oa_demo
- Samples: 100 samples (demo)
- Fields:
image: Biomedical figure (from scientific paper)caption: Expert-written captionquestion: (optional) User query about the imageanswer: (optional) Expert response
🧪 Example Usage
🔍 Visual Inference with Instruction & Optional Question
from transformers import TextStreamer
import matplotlib.pyplot as plt
# Prepare model and tokenizer
FastVisionModel.for_inference(model)
sample = dataset[10]
image = sample["image"]
caption = sample.get("caption", "")
# Display the image
plt.imshow(image)
plt.axis('off')
plt.title("Input Image")
plt.show()
instruction = "You are an expert Doctor. Describe accurately what you see in this image."
question = input("Please enter your question about the image (or press Enter to skip): ").strip()
# Build messages for the chat template
user_content = [
{"type": "image", "image": image},
{"type": "text", "text": instruction}
]
if question:
user_content.append({"type": "text", "text": question})
messages = [{"role": "user", "content": user_content}]
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")
streamer = TextStreamer(tokenizer, skip_prompt=True)
_ = model.generate(
**inputs,
streamer=streamer,
max_new_tokens=128,
use_cache=True,
temperature=1.5,
min_p=0.1,
)
# Optional: display true caption for comparison
print("\nGround Truth Caption:\n", caption)