Instructions to use tencent/Youtu-VL-4B-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tencent/Youtu-VL-4B-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="tencent/Youtu-VL-4B-Instruct", 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("tencent/Youtu-VL-4B-Instruct", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use tencent/Youtu-VL-4B-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "tencent/Youtu-VL-4B-Instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tencent/Youtu-VL-4B-Instruct", "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/tencent/Youtu-VL-4B-Instruct
- SGLang
How to use tencent/Youtu-VL-4B-Instruct 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 "tencent/Youtu-VL-4B-Instruct" \ --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": "tencent/Youtu-VL-4B-Instruct", "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 "tencent/Youtu-VL-4B-Instruct" \ --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": "tencent/Youtu-VL-4B-Instruct", "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 tencent/Youtu-VL-4B-Instruct with Docker Model Runner:
docker model run hf.co/tencent/Youtu-VL-4B-Instruct
Add link to Demo for VL and CV tasks to README
#7
by zhixiangwei - opened
README.md
CHANGED
|
@@ -127,6 +127,37 @@ generated_text = outputs[0]
|
|
| 127 |
print(f"Youtu-VL output: {generated_text}")
|
| 128 |
```
|
| 129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
## 🎉 Citation
|
| 131 |
|
| 132 |
If you find our work useful in your research, please consider citing our paper:
|
|
|
|
| 127 |
print(f"Youtu-VL output: {generated_text}")
|
| 128 |
```
|
| 129 |
|
| 130 |
+
### Demo for VL and CV tasks
|
| 131 |
+
|
| 132 |
+
A simple demo for quick start, including VL and CV tasks: [jupyter notebook](https://github.com/TencentCloudADP/youtu-vl/blob/main/demo/demo.ipynb)
|
| 133 |
+
|
| 134 |
+
The core part of this demo is three lines below:
|
| 135 |
+
|
| 136 |
+
```python
|
| 137 |
+
model_path = "tencent/Youtu-VL-4B-Instruct"
|
| 138 |
+
youtu_vl = YoutuVL(model_path)
|
| 139 |
+
response = youtu_vl(prompt, img_path, seg_mode=seg_mode)
|
| 140 |
+
```
|
| 141 |
+
|
| 142 |
+
### Qualitative Results
|
| 143 |
+
* **Task: Grounding**
|
| 144 |
+
> **Prompt:** Please provide the bounding box coordinate of the region this sentence describes: a black and white cat sitting on the edge of the bathtub
|
| 145 |
+
>
|
| 146 |
+
> <img src="https://cdn-uploads.huggingface.co/production/uploads/656312995475849b82c38bc4/349v2vYasfz4GtF_T_D09.png" width="300px">
|
| 147 |
+
|
| 148 |
+
* **Task: Object Detection**
|
| 149 |
+
> **Prompt:** Detect all objects in the provided image.
|
| 150 |
+
>
|
| 151 |
+
> <img src="https://cdn-uploads.huggingface.co/production/uploads/656312995475849b82c38bc4/rUJ6PzIjGJWwK4e9owPlY.png" width="300px">
|
| 152 |
+
|
| 153 |
+
* **Task: Referring Segmentation**
|
| 154 |
+
> **Prompt:** Can you segment "hotdog on left" in this image?
|
| 155 |
+
>
|
| 156 |
+
> <img src="https://cdn-uploads.huggingface.co/production/uploads/656312995475849b82c38bc4/K-5UG6HSLb28UFGx2pdPX.png" width="300px">
|
| 157 |
+
|
| 158 |
+
For more examples, please refer to paper and Jupyter notebooks.
|
| 159 |
+
|
| 160 |
+
|
| 161 |
## 🎉 Citation
|
| 162 |
|
| 163 |
If you find our work useful in your research, please consider citing our paper:
|