Image-Text-to-Text
Transformers
Safetensors
English
Chinese
qwen2_vl
text-generation-inference
label
conversational
Instructions to use prithivMLmods/Caption-Pro with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use prithivMLmods/Caption-Pro with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="prithivMLmods/Caption-Pro") 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, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("prithivMLmods/Caption-Pro") model = AutoModelForImageTextToText.from_pretrained("prithivMLmods/Caption-Pro") 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
- vLLM
How to use prithivMLmods/Caption-Pro with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "prithivMLmods/Caption-Pro" # 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/Caption-Pro", "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/Caption-Pro
- SGLang
How to use prithivMLmods/Caption-Pro 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/Caption-Pro" \ --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/Caption-Pro", "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/Caption-Pro" \ --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/Caption-Pro", "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/Caption-Pro with Docker Model Runner:
docker model run hf.co/prithivMLmods/Caption-Pro
Update README.md
Browse files
README.md
CHANGED
|
@@ -11,43 +11,42 @@ tags:
|
|
| 11 |
- text-generation-inference
|
| 12 |
- label
|
| 13 |
---
|
| 14 |
-

|
|
|
|
| 15 |
|
| 16 |
+
# **Caption-Pro**
|
| 17 |
+
|
| 18 |
+
**Caption-Pro** is an advanced image caption and annotation generator optimized for generating detailed, structured JSON outputs. Built upon a powerful vision-language architecture with enhanced OCR and multilingual support, Caption-Pro extracts high-quality captions and annotations from images for seamless integration into your applications.
|
| 19 |
|
| 20 |
#### Key Enhancements:
|
| 21 |
|
| 22 |
+
* **Advanced Image Understanding**: Fine-tuned on millions of annotated images, Caption-Pro delivers precise comprehension and interpretation of visual content.
|
| 23 |
* **Optimized for JSON Output**: Produces structured JSON data containing captions and detailed annotations—perfect for integration with databases, APIs, and automation pipelines.
|
| 24 |
* **Enhanced OCR Capabilities**: Accurately extracts textual content from images in multiple languages, including English, Chinese, Japanese, Korean, Arabic, and more.
|
| 25 |
* **Multimodal Processing**: Seamlessly handles both image and text inputs, generating comprehensive annotations based on the provided image.
|
| 26 |
* **Multilingual Support**: Recognizes and processes text within images across various languages.
|
| 27 |
* **Secure and Optimized Model Weights**: Employs safetensors for efficient and secure model loading.
|
| 28 |
|
|
|
|
|
|
|
| 29 |
### How to Use
|
| 30 |
|
| 31 |
```python
|
| 32 |
from transformers import Qwen2VLForConditionalGeneration, AutoTokenizer, AutoProcessor
|
| 33 |
from qwen_vl_utils import process_vision_info
|
| 34 |
|
| 35 |
+
# Load the Caption-Pro model with optimized parameters
|
| 36 |
model = Qwen2VLForConditionalGeneration.from_pretrained(
|
| 37 |
+
"prithivMLmods/Caption-Pro", torch_dtype="auto", device_map="auto"
|
| 38 |
)
|
| 39 |
|
| 40 |
# Recommended acceleration for performance optimization:
|
| 41 |
# model = Qwen2VLForConditionalGeneration.from_pretrained(
|
| 42 |
+
# "prithivMLmods/Caption-Pro",
|
| 43 |
# torch_dtype=torch.bfloat16,
|
| 44 |
# attn_implementation="flash_attention_2",
|
| 45 |
# device_map="auto",
|
| 46 |
# )
|
| 47 |
|
| 48 |
+
# Load the default processor for Caption-Pro
|
| 49 |
+
processor = AutoProcessor.from_pretrained("prithivMLmods/Caption-Pro")
|
| 50 |
|
| 51 |
# Define the input messages with both an image and a text prompt
|
| 52 |
messages = [
|
|
|
|
| 87 |
print(output_text)
|
| 88 |
```
|
| 89 |
|
|
|
|
|
|
|
| 90 |
### **Key Features**
|
| 91 |
|
| 92 |
1. **Annotation-Ready Training Data**
|
|
|
|
| 107 |
6. **Secure and Efficient Model Weights**
|
| 108 |
- Uses safetensors for enhanced security and optimized model performance.
|
| 109 |
|
| 110 |
+
**Caption-Pro** streamlines the process of generating image captions and annotations, making it an ideal solution for applications that require detailed visual content analysis and structured data integration.
|
|
|
|
|
|