Nougat ONNX
Collection
Faster Nougat in ONNX format (optimum onnxruntime) • 5 items • Updated • 1
How to use pszemraj/nougat-base-onnx with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("image-text-to-text", model="pszemraj/nougat-base-onnx") # Load model directly
from transformers import AutoTokenizer, AutoModelForImageTextToText
tokenizer = AutoTokenizer.from_pretrained("pszemraj/nougat-base-onnx")
model = AutoModelForImageTextToText.from_pretrained("pszemraj/nougat-base-onnx")How to use pszemraj/nougat-base-onnx with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "pszemraj/nougat-base-onnx"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "pszemraj/nougat-base-onnx",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/pszemraj/nougat-base-onnx
How to use pszemraj/nougat-base-onnx with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "pszemraj/nougat-base-onnx" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "pszemraj/nougat-base-onnx",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "pszemraj/nougat-base-onnx" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "pszemraj/nougat-base-onnx",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use pszemraj/nougat-base-onnx with Docker Model Runner:
docker model run hf.co/pszemraj/nougat-base-onnx
https://huggingface.co/facebook/nougat-base but exported to onnx. This is not quantized.
from transformers import NougatProcessor
from optimum.onnxruntime import ORTModelForVision2Seq
model_name = 'pszemraj/nougat-base-onnx'
processor = NougatProcessor.from_pretrained(model_name)
model = ORTModelForVision2Seq.from_pretrained(
model_name,
provider="CPUExecutionProvider", # 'CUDAExecutionProvider' for gpu
use_merged=False,
use_io_binding=True
)
on colab CPU-only (at time of writing) you may get CuPy errors, to solve this uninstall it:
pip uninstall cupy-cuda11x -y
See here