Views
No views yet
1# Quantized using OpenVINO NNCF
2# INT4 symmetric quantization
3# Applied to both vision encoder and language decoder⚠️ Note: This is an experimental quantization. Formal benchmarks pending.
pip install optimum[openvino] transformers pillow1from optimum.intel import OVModelForVision2Seq
2from transformers import AutoProcessor
3from PIL import Image
4import requests
5
6# Load model and processor
7model_id = "dev-bjoern/smolvlm-int4-ov"
8processor = AutoProcessor.from_pretrained(model_id)
9model = OVModelForVision2Seq.from_pretrained(model_id)
10
11# Load an image
12url = "https://huggingface.co/spaces/merve/chameleon-7b/resolve/main/bee.jpg"
13image = Image.open(requests.get(url, stream=True).raw)
14
15# Create conversation
16messages = [
17 {
18 "role": "user",
19 "content": [
20 {"type": "image"},
21 {"type": "text", "text": "What do you see in this image?"}
22 ]
23 }
24]
25
26# Process and generate
27prompt = processor.apply_chat_template(messages, add_generation_prompt=True)
28inputs = processor(text=prompt, images=[image], return_tensors="pt")
29generated_ids = model.generate(**inputs, max_new_tokens=200)
30output = processor.batch_decode(generated_ids, skip_special_tokens=True)
31print(output[0])1# Load multiple images
2image1 = Image.open("path/to/image1.jpg")
3image2 = Image.open("path/to/image2.jpg")
4
5messages = [
6 {
7 "role": "user",
8 "content": [
9 {"type": "image"},
10 {"type": "image"},
11 {"type": "text", "text": "Compare these two images"}
12 ]
13 }
14]
15
16# Process with multiple images
17inputs = processor(text=prompt, images=[image1, image2], return_tensors="pt")size={"longest_edge": N*384} where N=3 or 4 for balance1@misc{smolvlm-int4-ov,
2 author = {Bjoern Bethge},
3 title = {SmolVLM INT4 OpenVINO},
4 year = {2024},
5 publisher = {Hugging Face},
6 howpublished = {\url{https://huggingface.co/dev-bjoern/smolvlm-int4-ov}}
7}
8
9@article{marafioti2025smolvlm,
10 title={SmolVLM: Redefining small and efficient multimodal models},
11 author={Andrés Marafioti and others},
12 journal={arXiv preprint arXiv:2504.05299},
13 year={2025}
14}