Image-Text-to-Text
Transformers
Safetensors
English
qwen3_vl
text-generation-inference
vision-language
multimodal
image-captioning
visual-question-answering
conditional-generation
vision
language-model
sft
fine-grained-captioning
computer-vision
vllm
conversational
Instructions to use prithivMLmods/OpenCaption-4B-VL-SFT-v1.0 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use prithivMLmods/OpenCaption-4B-VL-SFT-v1.0 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="prithivMLmods/OpenCaption-4B-VL-SFT-v1.0") 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 AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("prithivMLmods/OpenCaption-4B-VL-SFT-v1.0") model = AutoModelForMultimodalLM.from_pretrained("prithivMLmods/OpenCaption-4B-VL-SFT-v1.0", 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=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use prithivMLmods/OpenCaption-4B-VL-SFT-v1.0 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "prithivMLmods/OpenCaption-4B-VL-SFT-v1.0" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "prithivMLmods/OpenCaption-4B-VL-SFT-v1.0", "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/prithivMLmods/OpenCaption-4B-VL-SFT-v1.0
- SGLang
How to use prithivMLmods/OpenCaption-4B-VL-SFT-v1.0 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 "prithivMLmods/OpenCaption-4B-VL-SFT-v1.0" \ --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": "prithivMLmods/OpenCaption-4B-VL-SFT-v1.0", "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 "prithivMLmods/OpenCaption-4B-VL-SFT-v1.0" \ --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": "prithivMLmods/OpenCaption-4B-VL-SFT-v1.0", "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 prithivMLmods/OpenCaption-4B-VL-SFT-v1.0 with Docker Model Runner:
docker model run hf.co/prithivMLmods/OpenCaption-4B-VL-SFT-v1.0
Update README.md
Browse files
README.md
CHANGED
|
@@ -2,6 +2,128 @@
|
|
| 2 |
library_name: transformers
|
| 3 |
---
|
| 4 |
|
|
|
|
| 5 |
|
|
|
|
| 6 |
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
library_name: transformers
|
| 3 |
---
|
| 4 |
|
| 5 |
+

|
| 6 |
|
| 7 |
+
# **OpenCaption-4B-VL-SFT-v1.0**
|
| 8 |
|
| 9 |
+
> **OpenCaption-4B-VL-SFT-v1.0** is a vision-language captioning model built on top of **Qwen/Qwen3-VL-4B-Instruct**. It was trained for **image captioning** and **high-quality dense image captioning** using a fine-grained mixture of long-form image description traces. The model is designed to produce richer visual understanding than conventional captions by capturing scene composition, object relationships, spatial reasoning, attributes, actions, lighting, background context, and fine visual details.
|
| 10 |
+
|
| 11 |
+
> [!NOTE]
|
| 12 |
+
> This model is an experimental release and may produce unexpected outputs in some scenarios.
|
| 13 |
+
|
| 14 |
+
## **Key Highlights**
|
| 15 |
+
|
| 16 |
+
* **Qwen 3-VL Foundation**: Built on top of **Qwen/Qwen3-VL-4B-Instruct**.
|
| 17 |
+
* **Dense Visual Captioning**: Focused on detailed image understanding and long-form image description.
|
| 18 |
+
* **Fine-Grained Descriptions**: Captures object relationships, spatial layout, attributes, actions, lighting, and context.
|
| 19 |
+
* **Captioning-Oriented Training**: Optimized for detailed image caption generation rather than generic short descriptions.
|
| 20 |
+
* **Research-Focused Release**: Intended for experimentation, evaluation, and captioning research.
|
| 21 |
+
* **Efficient 4B Deployment**: Suitable for local inference and research workflows.
|
| 22 |
+
|
| 23 |
+
## **Quick Start with Transformers**
|
| 24 |
+
|
| 25 |
+
Install the required packages:
|
| 26 |
+
|
| 27 |
+
```bash
|
| 28 |
+
pip install transformers accelerate qwen-vl-utils
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
Use the model with the following example:
|
| 32 |
+
|
| 33 |
+
```python
|
| 34 |
+
from transformers import Qwen3VLForConditionalGeneration, AutoProcessor
|
| 35 |
+
from qwen_vl_utils import process_vision_info
|
| 36 |
+
import torch
|
| 37 |
+
|
| 38 |
+
# Load the model
|
| 39 |
+
model = Qwen3VLForConditionalGeneration.from_pretrained(
|
| 40 |
+
"prithivMLmods/OpenCaption-4B-VL-SFT-v1.0",
|
| 41 |
+
torch_dtype="auto",
|
| 42 |
+
device_map="auto"
|
| 43 |
+
)
|
| 44 |
+
|
| 45 |
+
processor = AutoProcessor.from_pretrained(
|
| 46 |
+
"prithivMLmods/OpenCaption-4B-VL-SFT-v1.0"
|
| 47 |
+
)
|
| 48 |
+
|
| 49 |
+
messages = [
|
| 50 |
+
{
|
| 51 |
+
"role": "user",
|
| 52 |
+
"content": [
|
| 53 |
+
{
|
| 54 |
+
"type": "image",
|
| 55 |
+
"image": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg",
|
| 56 |
+
},
|
| 57 |
+
{
|
| 58 |
+
"type": "text",
|
| 59 |
+
"text": "Provide a detailed caption for this image with fine-grained visual details."
|
| 60 |
+
},
|
| 61 |
+
],
|
| 62 |
+
}
|
| 63 |
+
]
|
| 64 |
+
|
| 65 |
+
text = processor.apply_chat_template(
|
| 66 |
+
messages,
|
| 67 |
+
tokenize=False,
|
| 68 |
+
add_generation_prompt=True
|
| 69 |
+
)
|
| 70 |
+
|
| 71 |
+
image_inputs, video_inputs = process_vision_info(messages)
|
| 72 |
+
|
| 73 |
+
inputs = processor(
|
| 74 |
+
text=[text],
|
| 75 |
+
images=image_inputs,
|
| 76 |
+
videos=video_inputs,
|
| 77 |
+
padding=True,
|
| 78 |
+
return_tensors="pt",
|
| 79 |
+
).to(model.device)
|
| 80 |
+
|
| 81 |
+
generated_ids = model.generate(
|
| 82 |
+
**inputs,
|
| 83 |
+
max_new_tokens=512
|
| 84 |
+
)
|
| 85 |
+
|
| 86 |
+
generated_ids_trimmed = [
|
| 87 |
+
out_ids[len(in_ids):] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
|
| 88 |
+
]
|
| 89 |
+
|
| 90 |
+
output_text = processor.batch_decode(
|
| 91 |
+
generated_ids_trimmed,
|
| 92 |
+
skip_special_tokens=True,
|
| 93 |
+
clean_up_tokenization_spaces=False
|
| 94 |
+
)
|
| 95 |
+
|
| 96 |
+
print(output_text[0])
|
| 97 |
+
```
|
| 98 |
+
|
| 99 |
+
## **Training Details**
|
| 100 |
+
|
| 101 |
+
| Setting | Value |
|
| 102 |
+
| :--------------------- | :------------------------------------------------------------- |
|
| 103 |
+
| **Base Model** | **Qwen/Qwen3-VL-4B-Instruct** |
|
| 104 |
+
| **Training Method** | **Single-stage supervised fine-tuning (SFT)** |
|
| 105 |
+
| **Training Objective** | **Fine-grained image captioning and dense visual description** |
|
| 106 |
+
| **Training Precision** | **BF16 (Full Precision)** |
|
| 107 |
+
| **Training Data** | **10K Dense Image Caption Traces** |
|
| 108 |
+
|
| 109 |
+
## **Intended Use**
|
| 110 |
+
|
| 111 |
+
* **Image Captioning**: Generating clear and detailed captions for images.
|
| 112 |
+
* **Dense Image Understanding**: Describing scenes with richer visual context and fine-grained detail.
|
| 113 |
+
* **Visual Reasoning**: Explaining object placement, interactions, and relationships in an image.
|
| 114 |
+
* **Research and Evaluation**: Studying caption quality, visual grounding, and multimodal fine-tuning.
|
| 115 |
+
* **Local Deployment**: Running a compact 4B vision-language captioning model for experimentation.
|
| 116 |
+
|
| 117 |
+
## **Limitations**
|
| 118 |
+
|
| 119 |
+
* **Experimental Model**: Output quality may vary across domains and image styles.
|
| 120 |
+
* **Caption Biases**: Performance depends on the diversity and quality of the training traces.
|
| 121 |
+
* **Hallucinations**: Like other multimodal models, the model may occasionally describe details that are not present.
|
| 122 |
+
* **Not a Ground-Truth Detector**: The model is designed for captioning and visual description, not strict object verification.
|
| 123 |
+
|
| 124 |
+
## **Acknowledgements**
|
| 125 |
+
|
| 126 |
+
* **[Qwen/Qwen3-VL-4B-Instruct](https://huggingface.co/Qwen/Qwen3-VL-4B-Instruct)**: Base model used for this project.
|
| 127 |
+
* **[Transformers](https://huggingface.co/docs/transformers/en/index)**: Core inference and model-loading library.
|
| 128 |
+
* **[qwen-vl-utils](https://github.com/QwenLM/Qwen2.5-VL)**: Utility helpers for vision-language input processing.
|
| 129 |
+
* **TRL**: Used in the training and alignment workflow for supervised fine-tuning.
|