Downloads · 30 days
65
20% of all-time downloads
Nagafi/moondream2-q4-onnx
moondream2-q4-onnx is a image-to-text model from Nagafi. Use it when you need a caption or text from an image. It is set up for transformers.js. The card lists the license as apache-2.0.
Quantized version of vikhyatk/moondream2 for efficient browser deployment with Transformers.js.
Downloads · 30 days
65
20% of all-time downloads
All-time downloads
320
Public
Repo size
2.3 GB
Likes
1
Public
Click a slice to open those files.
.onnx2.3 GB · 100%
From the Hugging Face model README
Quantized version of vikhyatk/moondream2 for efficient browser deployment with Transformers.js.
Based on Xenova/moondream2 ONNX conversion.
import {
AutoProcessor,
AutoTokenizer,
Moondream1ForConditionalGeneration,
RawImage,
} from '@huggingface/transformers';
const model_id = 'YOUR_USERNAME/moondream2-q4-onnx';
const processor = await AutoProcessor.from_pretrained(model_id);
const tokenizer = await AutoTokenizer.from_pretrained(model_id);
const model = await Moondream1ForConditionalGeneration.from_pretrained(model_id, {
dtype: 'q4',
device: 'webgpu',
});
const image = await RawImage.fromURL('your-image-url');
const text = '<image>\n\nQuestion: Describe this image\n\nAnswer:';
const textInputs = tokenizer(text);
const visionInputs = await processor(image);
const output = await model.generate({
...textInputs,
...visionInputs,
max_new_tokens: 256,
});
const result = tokenizer.batch_decode(output, { skip_special_tokens: true });
console.log(result[0]);
Apache 2.0 (same as base model)