Instructions to use pcuenq/paddle-test-3 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use pcuenq/paddle-test-3 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="pcuenq/paddle-test-3", 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 AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("pcuenq/paddle-test-3", trust_remote_code=True) model = AutoModelForMultimodalLM.from_pretrained("pcuenq/paddle-test-3", trust_remote_code=True, 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 pcuenq/paddle-test-3 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "pcuenq/paddle-test-3" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "pcuenq/paddle-test-3", "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/pcuenq/paddle-test-3
- SGLang
How to use pcuenq/paddle-test-3 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 "pcuenq/paddle-test-3" \ --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": "pcuenq/paddle-test-3", "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 "pcuenq/paddle-test-3" \ --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": "pcuenq/paddle-test-3", "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 pcuenq/paddle-test-3 with Docker Model Runner:
docker model run hf.co/pcuenq/paddle-test-3
| pipeline_tag: image-text-to-text | |
| library_name: transformers | |
| # PaddleOCR-VL-0.9B | |
| Duplicated from https://huggingface.co/PaddlePaddle/PaddleOCR-VL | |
| Example use with transformers: | |
| ```py | |
| from transformers import AutoModelForCausalLM, AutoProcessor | |
| import torch | |
| DEVICE="cuda" if torch.cuda.is_available() else "mps" if torch.mps.is_available() else "cpu" | |
| model_id = "pcuenq/PaddleOCR-VL-0.9B" | |
| model = AutoModelForCausalLM.from_pretrained( | |
| model_id, trust_remote_code=True, dtype=torch.bfloat16 | |
| ).to(DEVICE).eval() | |
| processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True) | |
| from transformers.image_utils import load_image | |
| image_url = "https://fiverr-res.cloudinary.com/images/t_main1,q_auto,f_auto,q_auto,f_auto/gigs/154456946/original/41556aac80fc43dcb29ce656d786c0a6f9b4073f/do-handwritten-text-image-or-pdf-to-word-means-typing-form.jpg" | |
| image = load_image(image_url) | |
| messages = [{"role": "user", "content": "OCR"}] | |
| text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True) | |
| inputs = processor(text=[text], images=[image], return_tensors="pt").to(DEVICE) | |
| generated = model.generate(**inputs, max_new_tokens=200, do_sample=False) | |
| resp = processor.batch_decode(generated, skip_special_tokens=True)[0] | |
| answer = resp.split(text)[-1].strip() | |
| print(answer) | |
| ``` |