Image-Text-to-Text
Transformers
Safetensors
English
libra
text-generation
maira2
custom_code
radiology
Automated Chest X-ray Report Generation
MLLM
RRG
conversational
Instructions to use X-iZhang/libra-maira-2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use X-iZhang/libra-maira-2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="X-iZhang/libra-maira-2", 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)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("X-iZhang/libra-maira-2", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use X-iZhang/libra-maira-2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "X-iZhang/libra-maira-2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "X-iZhang/libra-maira-2", "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/X-iZhang/libra-maira-2
- SGLang
How to use X-iZhang/libra-maira-2 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 "X-iZhang/libra-maira-2" \ --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": "X-iZhang/libra-maira-2", "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 "X-iZhang/libra-maira-2" \ --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": "X-iZhang/libra-maira-2", "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 X-iZhang/libra-maira-2 with Docker Model Runner:
docker model run hf.co/X-iZhang/libra-maira-2
Update config.json
Browse files- config.json +10 -5
config.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
| 9 |
"freeze_mm_mlp_adapter": false,
|
| 10 |
"hidden_act": "silu",
|
| 11 |
"hidden_size": 4096,
|
| 12 |
-
"image_aspect_ratio": "
|
| 13 |
"initializer_range": 0.02,
|
| 14 |
"intermediate_size": 11008,
|
| 15 |
"max_length": 4096,
|
|
@@ -22,7 +22,7 @@
|
|
| 22 |
"mm_use_im_patch_token": false,
|
| 23 |
"mm_use_im_start_end": false,
|
| 24 |
"mm_vision_select_feature": "patch",
|
| 25 |
-
"mm_vision_select_layer": -
|
| 26 |
"mm_vision_tower": "microsoft/rad-dino-maira-2",
|
| 27 |
"model_type": "libra",
|
| 28 |
"num_attention_heads": 32,
|
|
@@ -31,17 +31,22 @@
|
|
| 31 |
"pad_token_id": 0,
|
| 32 |
"pretraining_tp": 1,
|
| 33 |
"rms_norm_eps": 1e-05,
|
| 34 |
-
"rope_scaling":
|
|
|
|
|
|
|
|
|
|
| 35 |
"rope_theta": 10000.0,
|
| 36 |
"tie_word_embeddings": false,
|
| 37 |
"tokenizer_model_max_length": 1024,
|
| 38 |
"tokenizer_padding_side": "right",
|
| 39 |
-
"torch_dtype": "
|
| 40 |
"transformers_version": "4.51.3",
|
|
|
|
| 41 |
"tune_mm_mlp_adapter": true,
|
| 42 |
"tune_mm_vision_resampler": false,
|
| 43 |
"unfreeze_mm_vision_tower": true,
|
|
|
|
| 44 |
"use_cache": false,
|
| 45 |
"use_mm_proj": true,
|
| 46 |
"vocab_size": 32207
|
| 47 |
-
}
|
|
|
|
| 9 |
"freeze_mm_mlp_adapter": false,
|
| 10 |
"hidden_act": "silu",
|
| 11 |
"hidden_size": 4096,
|
| 12 |
+
"image_aspect_ratio": "square",
|
| 13 |
"initializer_range": 0.02,
|
| 14 |
"intermediate_size": 11008,
|
| 15 |
"max_length": 4096,
|
|
|
|
| 22 |
"mm_use_im_patch_token": false,
|
| 23 |
"mm_use_im_start_end": false,
|
| 24 |
"mm_vision_select_feature": "patch",
|
| 25 |
+
"mm_vision_select_layer": -1,
|
| 26 |
"mm_vision_tower": "microsoft/rad-dino-maira-2",
|
| 27 |
"model_type": "libra",
|
| 28 |
"num_attention_heads": 32,
|
|
|
|
| 31 |
"pad_token_id": 0,
|
| 32 |
"pretraining_tp": 1,
|
| 33 |
"rms_norm_eps": 1e-05,
|
| 34 |
+
"rope_scaling": {
|
| 35 |
+
"factor": 1.5,
|
| 36 |
+
"rope_type": "linear"
|
| 37 |
+
},
|
| 38 |
"rope_theta": 10000.0,
|
| 39 |
"tie_word_embeddings": false,
|
| 40 |
"tokenizer_model_max_length": 1024,
|
| 41 |
"tokenizer_padding_side": "right",
|
| 42 |
+
"torch_dtype": "float16",
|
| 43 |
"transformers_version": "4.51.3",
|
| 44 |
+
"image_token_index": 32204,
|
| 45 |
"tune_mm_mlp_adapter": true,
|
| 46 |
"tune_mm_vision_resampler": false,
|
| 47 |
"unfreeze_mm_vision_tower": true,
|
| 48 |
+
"use_maira_feature_norm": true,
|
| 49 |
"use_cache": false,
|
| 50 |
"use_mm_proj": true,
|
| 51 |
"vocab_size": 32207
|
| 52 |
+
}
|