Image-Text-to-Text
Transformers
Safetensors
qwen2_5_vl
feature-extraction
vision-language
medical
radiology
chest-xray
qwen2.5-vl
conversational
custom_code
text-generation-inference
Instructions to use EvidenceAIResearch/VReason-QwenVL with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use EvidenceAIResearch/VReason-QwenVL with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="EvidenceAIResearch/VReason-QwenVL", trust_remote_code=True) 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, AutoModelForVision2Seq processor = AutoProcessor.from_pretrained("EvidenceAIResearch/VReason-QwenVL", trust_remote_code=True) model = AutoModelForVision2Seq.from_pretrained("EvidenceAIResearch/VReason-QwenVL", trust_remote_code=True, 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 EvidenceAIResearch/VReason-QwenVL with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "EvidenceAIResearch/VReason-QwenVL" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "EvidenceAIResearch/VReason-QwenVL", "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/EvidenceAIResearch/VReason-QwenVL
- SGLang
How to use EvidenceAIResearch/VReason-QwenVL 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 "EvidenceAIResearch/VReason-QwenVL" \ --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": "EvidenceAIResearch/VReason-QwenVL", "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 "EvidenceAIResearch/VReason-QwenVL" \ --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": "EvidenceAIResearch/VReason-QwenVL", "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 EvidenceAIResearch/VReason-QwenVL with Docker Model Runner:
docker model run hf.co/EvidenceAIResearch/VReason-QwenVL
Add model card README
Browse files
README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: transformers
|
| 3 |
+
tags:
|
| 4 |
+
- vision-language
|
| 5 |
+
- medical
|
| 6 |
+
- radiology
|
| 7 |
+
- chest-xray
|
| 8 |
+
- qwen2.5-vl
|
| 9 |
+
pipeline_tag: image-text-to-text
|
| 10 |
+
base_model: Qwen/Qwen2.5-VL-7B-Instruct
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# EvidenceAIResearch/VReason-QwenVL
|
| 14 |
+
|
| 15 |
+
VReason-Huatuo model checkpoint for chest X-ray visual reasoning and report generation.
|
| 16 |
+
|
| 17 |
+
## What is included
|
| 18 |
+
|
| 19 |
+
- Model weights (`safetensors` shards)
|
| 20 |
+
- Tokenizer and config files
|
| 21 |
+
- `generation_config.json`
|
| 22 |
+
- Built-in `model.visual_reason(...)` method available via `trust_remote_code=True`
|
| 23 |
+
|
| 24 |
+
## Installation
|
| 25 |
+
|
| 26 |
+
```bash
|
| 27 |
+
pip install -r requirements.txt
|
| 28 |
+
pip install cxas-vreason
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
If `cxas-vreason` is not yet available in your environment, install from this repo:
|
| 32 |
+
|
| 33 |
+
```bash
|
| 34 |
+
pip install "git+https://huggingface.co/EvidenceAIResearch/VReason-QwenVL#subdirectory=cxas_vreason"
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
## Quick start (Transformers)
|
| 38 |
+
|
| 39 |
+
```python
|
| 40 |
+
import torch
|
| 41 |
+
from PIL import Image
|
| 42 |
+
from transformers import AutoProcessor, AutoModelForVision2Seq
|
| 43 |
+
|
| 44 |
+
repo_id = "EvidenceAIResearch/VReason-QwenVL"
|
| 45 |
+
processor = AutoProcessor.from_pretrained(repo_id, trust_remote_code=True)
|
| 46 |
+
model = AutoModelForVision2Seq.from_pretrained(
|
| 47 |
+
repo_id,
|
| 48 |
+
torch_dtype=torch.float16,
|
| 49 |
+
trust_remote_code=True,
|
| 50 |
+
).eval().cuda()
|
| 51 |
+
|
| 52 |
+
image = Image.open("frontal.jpg").convert("RGB")
|
| 53 |
+
messages = [
|
| 54 |
+
{
|
| 55 |
+
"role": "user",
|
| 56 |
+
"content": [
|
| 57 |
+
{"type": "image", "image": image},
|
| 58 |
+
{
|
| 59 |
+
"type": "text",
|
| 60 |
+
"text": "Based on the provided chest radiograph, explain your diagnosis procedure and write a report.",
|
| 61 |
+
},
|
| 62 |
+
],
|
| 63 |
+
}
|
| 64 |
+
]
|
| 65 |
+
|
| 66 |
+
prompt = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 67 |
+
inputs = processor(text=[prompt], images=[[image]], return_tensors="pt").to(model.device)
|
| 68 |
+
output_ids = model.generate(**inputs, max_new_tokens=1024)
|
| 69 |
+
text = processor.batch_decode(output_ids, skip_special_tokens=False)[0]
|
| 70 |
+
print(text)
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
## Visual reasoning method
|
| 74 |
+
|
| 75 |
+
After loading with `trust_remote_code=True`, the model exposes:
|
| 76 |
+
|
| 77 |
+
- `model.visual_reason(...)`
|
| 78 |
+
|
| 79 |
+
This method can:
|
| 80 |
+
|
| 81 |
+
- `reasoning.json` with regions, sub-regions, and extracted reasoning text
|
| 82 |
+
- Generate ROI image artifacts for anatomy/pathology tool calls (blur/crop/blurcrop)
|
| 83 |
+
|
| 84 |
+
Example:
|
| 85 |
+
|
| 86 |
+
```python
|
| 87 |
+
out = model.visual_reason(
|
| 88 |
+
processor=processor,
|
| 89 |
+
image="frontal.jpg",
|
| 90 |
+
generate_roi=True,
|
| 91 |
+
output_dir="./visual_reason_out",
|
| 92 |
+
viz_mode="blurcrop",
|
| 93 |
+
)
|
| 94 |
+
print(out["report"])
|
| 95 |
+
```
|
| 96 |
+
|
| 97 |
+
Notes:
|
| 98 |
+
|
| 99 |
+
- `trust_remote_code=True` is required to enable `model.visual_reason(...)`.
|
| 100 |
+
- Pass `generate_roi=False` when you only need structured text parsing.
|
| 101 |
+
|
| 102 |
+
## Limitations
|
| 103 |
+
|
| 104 |
+
- Intended for research use only.
|
| 105 |
+
- Not a medical device; outputs must not be used as sole clinical evidence.
|
| 106 |
+
- Performance can vary by data source and imaging protocol.
|