Downloads · 30 days
5
13% of all-time downloads
manifestasi/smolVLM-161M-q4-manifestasi
smolVLM-161M-q4-manifestasi is a image-text-to-text model from manifestasi. Use it for the image-text-to-text task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
Downloads · 30 days
5
13% of all-time downloads
All-time downloads
39
Public
Parameters
263M
219 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors219 MB · 98%
How the weights are stored.
U8204M · 78%
From the Hugging Face model README
%%capture
!pip install -U bitsandbytes
from transformers import AutoProcessor, AutoModelForVision2Seq
import torch
DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
processor = AutoProcessor.from_pretrained("manifestasi/smolVLM-161M-q4-manifestasi")
model = AutoModelForVision2Seq.from_pretrained("manifestasi/smolVLM-161M-q4-manifestasi",
torch_dtype=torch.float16,
_attn_implementation="eager").to(DEVICE)
from PIL import Image
from transformers.image_utils import load_image
# Load images
# image1 = load_image("https://huggingface.co/spaces/HuggingFaceTB/SmolVLM/resolve/main/example_images/rococo.jpg")
image2 = load_image("/kaggle/input/bandaraaa/799269_1200.jpg")
# Create input messages
messages = [
{
"role": "user",
"content": [
# {"type": "image"},
{"type": "image"},
{"type": "text",
"text": """
Instructions :
you are visual assistant for blind people, please answer politely and short
under 100 words.
Prompt :
can you direct me to find toilet
"""}
]
},
]
# Prepare inputs
prompt = processor.apply_chat_template(messages, add_generation_prompt=True)
# inputs = processor(text=prompt, return_tensors="pt")
inputs = processor(text=prompt, images=[image2], return_tensors="pt")
inputs = inputs.to(DEVICE)
# Generate outputs
from time import time
tim1 = time()
generated_ids = model.generate(**inputs, max_new_tokens=120)
generated_texts = processor.batch_decode(
generated_ids,
skip_special_tokens=True,
)
tim2 = time()
print(f"{(tim2 - tim1)} detik")
print(generated_texts[0].split("Assistant: ")[1])