onnx-community/paligemma2-3b-pt-448
By onnx-community · ↓ 5 · ♥ 0 · Updated 2025-03-06
What's in this repo
This page lists the files in onnx-community/paligemma2-3b-pt-448, including decoder_model_merged.onnx, decoder_model_merged_bnb4.onnx, decoder_model_merged_fp16.onnx and more.
- 24 ONNX models (.onnx files)
- 40 files, including 24 .onnx, 8 .onnx_data, 6 .json, 1 .md
- Last updated 2025-03-06
ONNX files
| File | Size | Download |
|---|---|---|
| onnx/decoder_model_merged.onnx | — | Download |
| onnx/decoder_model_merged_bnb4.onnx | — | Download |
| onnx/decoder_model_merged_fp16.onnx | — | Download |
| onnx/decoder_model_merged_int8.onnx | — | Download |
| onnx/decoder_model_merged_q4.onnx | — | Download |
| onnx/decoder_model_merged_q4f16.onnx | — | Download |
| onnx/decoder_model_merged_quantized.onnx | — | Download |
| onnx/decoder_model_merged_uint8.onnx | — | Download |
| onnx/embed_tokens.onnx | — | Download |
| onnx/embed_tokens_bnb4.onnx | — | Download |
Showing 10 of 24 .onnx files — see the full file list on the right.
How to use
These ONNX files can be loaded with ONNX Runtime. To inspect a model graph, upload the file to the Netron viewer. Download links point to the original files on Hugging Face.
README
https://huggingface.co/google/paligemma2-3b-pt-448 with ONNX weights to be compatible with Transformers.js.
Usage (Transformers.js)
If you haven't already, you can install the Transformers.js JavaScript library from NPM using:
npm i @huggingface/transformers
Example: Image captioning with onnx-community/paligemma2-3b-pt-448.
import { AutoProcessor, PaliGemmaForConditionalGeneration, load_image } from '@huggingface/transformers';
// Load processor and model
const model_id = 'onnx-community/paligemma2-3b-pt-448';
const processor = await AutoProcessor.from_pretrained(model_id);
const model = await PaliGemmaForConditionalGeneration.from_pretrained(model_id, {
dtype: {
embed_tokens: 'fp16', // or 'q8'
vision_encoder: 'fp16', // or 'q4', 'q8'
decoder_model_merged: 'q4', // or 'q4f16'
},
});
// Prepare inputs
const url = 'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg'
const raw_image = await load_image(url);
const prompt = '<image>'; // Caption, by default
const inputs = await processor(raw_image, prompt);
// Generate a response
const output = await model.generate({
...inputs,
max_new_tokens: 100,
})
const generated_ids = output.slice(null, [inputs.input_ids.dims[1], null]);
const answer = processor.batch_decode(
generated_ids,
{ skip_special_tokens: true },
);
console.log(answer[0]);
// a blue and white car parked on a street
Note: Having a separate repo for ONNX weights is intended to be a temporary solution until WebML gains more traction. If you would like to make your models web-ready, we recommend converting to ONNX using 🤗 Optimum and structuring your repo like this one (with ONNX weights located in a subfolder named onnx).
Model info
Created: 2024-12-06
Updated: 2025-03-06
View on Hugging Face