Image-Text-to-Text
Transformers
Safetensors
English
Chinese
ovis
text-generation
MLLM
conversational
custom_code
Instructions to use AIDC-AI/Ovis2-16B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AIDC-AI/Ovis2-16B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="AIDC-AI/Ovis2-16B", 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("AIDC-AI/Ovis2-16B", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use AIDC-AI/Ovis2-16B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "AIDC-AI/Ovis2-16B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AIDC-AI/Ovis2-16B", "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/AIDC-AI/Ovis2-16B
- SGLang
How to use AIDC-AI/Ovis2-16B 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 "AIDC-AI/Ovis2-16B" \ --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": "AIDC-AI/Ovis2-16B", "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 "AIDC-AI/Ovis2-16B" \ --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": "AIDC-AI/Ovis2-16B", "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 AIDC-AI/Ovis2-16B with Docker Model Runner:
docker model run hf.co/AIDC-AI/Ovis2-16B
`Use via API` with gradio_client does not work
#4
by tumikosha - opened
I want to inference via API using gradio_client but
All OVIS model workspaces suggest that it is possible to use the model via the Hugging Face API, as shown in the example below:
from gradio_client import Client
client = Client("AIDC-AI/Ovis2-1B", hf_token=HF_TOKEN)
result = client.predict(
chatbot=[],
image_input=handle_file('https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png'),
api_name="/ovis_chat"
)
print(result)
However, in practice, this does not work. The result is the following error:
Traceback (most recent call last):
File "/media/tumi/nvme2/prj/prj_upcode/AI_contabil/HF/ovis.py", line 43, in <module>
result = client.predict(
^^^^^^^^^^^^^^^
File "/media/tumi/.venv/lib/python3.11/site-packages/gradio_client/client.py", line 484, in predict
).result()
^^^^^^^^
File "/media/tumi/.venv/lib/python3.11/site-packages/gradio_client/client.py", line 1545, in result
return super().result(timeout=timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tumi/.local/share/uv/python/cpython-3.11.11-linux-x86_64-gnu/lib/python3.11/concurrent/futures/_base.py", line 456, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/home/tumi/.local/share/uv/python/cpython-3.11.11-linux-x86_64-gnu/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/home/tumi/.local/share/uv/python/cpython-3.11.11-linux-x86_64-gnu/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/media/tumi/.venv/lib/python3.11/site-packages/gradio_client/client.py", line 1166, in _inner
predictions = _predict(*data)
^^^^^^^^^^^^^^^
File "/media/tumi/.venv/lib/python3.11/site-packages/gradio_client/client.py", line 1284, in _predict
raise AppError(message=message, **result)
gradio_client.exceptions.AppError: 'IndexError'
Process finished with exit code 1
tumikosha changed discussion title from `Use via API` does not work to `Use via API` with gradio_client does not work