Reasoning Capability
: Produces explicit reasoning traces alongside final answers.
Multi-Task Support
: Supports Visual Question Answering (VQA), Report Generation, and Visual Grounding.
Resident-Level Report Drafting
: Matches or outperforms resident-drafted reports in 50% of cases.
Two Inference Modes
Reasoning Mode
: Higher performance with explicit reasoning traces.
Instruct Mode
: Faster inference without reasoning traces.
🎬 Get Started
CheXOne is post-trained on Qwen2.5VL-3B-Instruct model, which has been in the latest Hugging face transformers and we advise you to build from source with command:
from transformers import Qwen2_5_VLForConditionalGeneration, AutoTokenizer, AutoProcessor
from qwen_vl_utils import process_vision_info
# default: Load the model on the available device(s)
model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
"StanfordAIMI/CheXOne", torch_dtype="auto", device_map="auto"
)
# We recommend enabling flash_attention_2 for better acceleration and memory saving, especially in multi-image scenarios.# model = Qwen2_5_VLForConditionalGeneration.from_pretrained(# "StanfordAIMI/CheXOne",# torch_dtype=torch.bfloat16,# attn_implementation="flash_attention_2",# device_map="auto",# )# default processer
processor = AutoProcessor.from_pretrained("StanfordAIMI/CheXOne")
# The default range for the number of visual tokens per image in the model is 4-16384.# We recommand to set max_pixels=512*512 to align with the training setting.# min_pixels = 256*28*28# max_pixels = 512*512# processor = AutoProcessor.from_pretrained("StanfordAIMI/CheXOne", min_pixels=min_pixels, max_pixels=max_pixels)# Inference Mode: Reasoning
messages = [
{
"role": "user",
"content": [
{
"type": "image",
"image": "https://github.com/YBZh/CheXOne/blob/main/asset/cxr.jpg",
},
{"type": "text", "text": "Write an example findings section for the CXR. Please reason step by step, and put your final answer within \\boxed{{}}."},
],
}
]
# Inference Mode: Instruct# messages = [# {# "role": "user",# "content": [# {# "type": "image",# "image": "https://github.com/YBZh/CheXOne/blob/main/asset/cxr.jpg",# },# {"type": "text", "text": "Write an example findings section for the CXR."},# ],# }# ]# Preparation for inference
text = processor.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True
)
image_inputs, video_inputs = process_vision_info(messages)
inputs = processor(
text=[text],
images=image_inputs,
videos=video_inputs,
padding=True,
return_tensors="pt",
)
inputs = inputs.to("cuda")
# Inference: Generation of the output
generated_ids = model.generate(**inputs, max_new_tokens=1024)
generated_ids_trimmed = [
out_ids[len(in_ids) :] for in_ids, out_ids inzip(inputs.input_ids, generated_ids)
]
output_text = processor.batch_decode(
generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
)
print(output_text)
Multi image inference
# Messages containing multiple images and a text query
messages = [
{
"role": "user",
"content": [
{"type": "image", "image": "https://github.com/YBZh/CheXOne/blob/main/asset/cxr.jpg"},
{"type": "image", "image": "https://github.com/YBZh/CheXOne/blob/main/asset/cxr_lateral.jpg"},
{"type": "text", "text": "Write an example findings section for the CXR. Please reason step by step, and put your final answer within \\boxed{{}}."},
],
}
]
# Preparation for inference
text = processor.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True
)
image_inputs, video_inputs = process_vision_info(messages)
inputs = processor(
text=[text],
images=image_inputs,
videos=video_inputs,
padding=True,
return_tensors="pt",
)
inputs = inputs.to("cuda")
# Inference
generated_ids = model.generate(**inputs, max_new_tokens=128)
generated_ids_trimmed = [
out_ids[len(in_ids) :] for in_ids, out_ids inzip(inputs.input_ids, generated_ids)
]
output_text = processor.batch_decode(
generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
)
print(output_text)
CheXOne huggingface.co is an AI model on huggingface.co that provides CheXOne's model effect (), which can be used instantly with this StanfordAIMI CheXOne model. huggingface.co supports a free trial of the CheXOne model, and also provides paid use of the CheXOne. Support call CheXOne model through api, including Node.js, Python, http.
CheXOne huggingface.co is an online trial and call api platform, which integrates CheXOne's modeling effects, including api services, and provides a free online trial of CheXOne, you can try CheXOne online for free by clicking the link below.
StanfordAIMI CheXOne online free url in huggingface.co:
CheXOne is an open source model from GitHub that offers a free installation service, and any user can find CheXOne on GitHub to install. At the same time, huggingface.co provides the effect of CheXOne install, users can directly use CheXOne installed effect in huggingface.co for debugging and trial. It also supports api for free installation.