EvidenceAIResearch commited on
Commit
ab71aa9
·
verified ·
1 Parent(s): 35beca7

Add model card README

Browse files
Files changed (1) hide show
  1. README.md +106 -0
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.