Instructions to use JoseferEins/SmolVLM-500M-Instruct-fer0 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use JoseferEins/SmolVLM-500M-Instruct-fer0 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="JoseferEins/SmolVLM-500M-Instruct-fer0") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("JoseferEins/SmolVLM-500M-Instruct-fer0") model = AutoModelForImageTextToText.from_pretrained("JoseferEins/SmolVLM-500M-Instruct-fer0") - llama-cpp-python
How to use JoseferEins/SmolVLM-500M-Instruct-fer0 with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="JoseferEins/SmolVLM-500M-Instruct-fer0", filename="gguf/emovlm-500m.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] ) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use JoseferEins/SmolVLM-500M-Instruct-fer0 with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf JoseferEins/SmolVLM-500M-Instruct-fer0 # Run inference directly in the terminal: llama-cli -hf JoseferEins/SmolVLM-500M-Instruct-fer0
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf JoseferEins/SmolVLM-500M-Instruct-fer0 # Run inference directly in the terminal: llama-cli -hf JoseferEins/SmolVLM-500M-Instruct-fer0
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf JoseferEins/SmolVLM-500M-Instruct-fer0 # Run inference directly in the terminal: ./llama-cli -hf JoseferEins/SmolVLM-500M-Instruct-fer0
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf JoseferEins/SmolVLM-500M-Instruct-fer0 # Run inference directly in the terminal: ./build/bin/llama-cli -hf JoseferEins/SmolVLM-500M-Instruct-fer0
Use Docker
docker model run hf.co/JoseferEins/SmolVLM-500M-Instruct-fer0
- LM Studio
- Jan
- vLLM
How to use JoseferEins/SmolVLM-500M-Instruct-fer0 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "JoseferEins/SmolVLM-500M-Instruct-fer0" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "JoseferEins/SmolVLM-500M-Instruct-fer0", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/JoseferEins/SmolVLM-500M-Instruct-fer0
- SGLang
How to use JoseferEins/SmolVLM-500M-Instruct-fer0 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "JoseferEins/SmolVLM-500M-Instruct-fer0" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "JoseferEins/SmolVLM-500M-Instruct-fer0", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
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 "JoseferEins/SmolVLM-500M-Instruct-fer0" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "JoseferEins/SmolVLM-500M-Instruct-fer0", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Ollama
How to use JoseferEins/SmolVLM-500M-Instruct-fer0 with Ollama:
ollama run hf.co/JoseferEins/SmolVLM-500M-Instruct-fer0
- Unsloth Studio new
How to use JoseferEins/SmolVLM-500M-Instruct-fer0 with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for JoseferEins/SmolVLM-500M-Instruct-fer0 to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for JoseferEins/SmolVLM-500M-Instruct-fer0 to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for JoseferEins/SmolVLM-500M-Instruct-fer0 to start chatting
- Docker Model Runner
How to use JoseferEins/SmolVLM-500M-Instruct-fer0 with Docker Model Runner:
docker model run hf.co/JoseferEins/SmolVLM-500M-Instruct-fer0
- Lemonade
How to use JoseferEins/SmolVLM-500M-Instruct-fer0 with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull JoseferEins/SmolVLM-500M-Instruct-fer0
Run and chat with the model
lemonade run user.SmolVLM-500M-Instruct-fer0-{{QUANT_TAG}}List all available models
lemonade list
llm.create_chat_completion(
messages = [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this image in one sentence."
},
{
"type": "image_url",
"image_url": {
"url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
}
}
]
}
]
)SmolVLM-500M-Instruct-fer0
Fine-tuned version of SmolVLM-500M-Instruct on a subset of AffectNet (emotion recognition), with text labels transcribed via GPT-4o-mini.
This is just priliminary, we'll update soon with proper evalutation and info.
Example
Predictions:
- Base model: A woman with blonde hair is looking to the side with a hand on her chin.
- This model: The expression conveys a sense of contemplation or concern. The furrowed brow and slightly parted lips suggest a deep thought or worry. The hand on the chin indicates a hint of introspection, hinting at a possible emotional state of unease or contemplation.
Training Summary
- Loss values:
| Step | Training Loss |
|---|---|
| 25 | 2.80 |
| 50 | 0.82 |
| 75 | 0.48 |
| 100 | 0.43 |
- Hyperparameters:
- Learning rate: 1e-4
- Batch size: 4 (grad. accum. ×4)
- Epochs: 1
- Optimizer: 8-bit AdamW
- Scheduler: linear (warmup 50 steps)
- Seed: 42
Frameworks
- Transformers 4.50.0
- PyTorch 2.3.1+cu121
- Datasets 3.6.0
- Tokenizers 0.21.1
Run it by loading the processor of the base model:
import argparse
import torch
from transformers import AutoProcessor, AutoModelForVision2Seq
from transformers.image_utils import load_image
FINE_ID = "JoseferEins/SmolVLM-500M-Instruct-fer0" # your fine-tuned model
BASE_ID = "HuggingFaceTB/SmolVLM-500M-Instruct" # base model (and processor)
DEFAULT_IMAGE = "image.png"
PROMPT = "Describe the emotional state of the person."
device = "cuda" if torch.cuda.is_available() else "cpu"
def load_model(model_id: str):
try:
return AutoModelForVision2Seq.from_pretrained(
model_id,
dtype=torch.bfloat16 if device == "cuda" else torch.float32,
attn_implementation="eager",
).to(device).eval()
except TypeError:
# for older transformers parameter name
return AutoModelForVision2Seq.from_pretrained(
model_id,
torch_dtype=torch.bfloat16 if device == "cuda" else torch.float32,
_attn_implementation="eager",
).to(device).eval()
def run_once(model, processor, image_path: str, max_new_tokens: int) -> str:
image = load_image(image_path)
messages = [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": PROMPT}]}]
prompt = processor.apply_chat_template(messages, add_generation_prompt=True)
inputs = processor(text=prompt, images=[image], return_tensors="pt").to(device)
with torch.inference_mode():
ids = model.generate(**inputs, max_new_tokens=max_new_tokens)
return processor.batch_decode(ids, skip_special_tokens=True)[0]
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--model", choices=["fine", "base", "both"], default="both",
help="Which model to run: your fine-tuned repo, the base, or both.")
ap.add_argument("--image", default=DEFAULT_IMAGE, help="Path/URL to image.")
ap.add_argument("--max_new_tokens", type=int, default=256)
args = ap.parse_args()
# Processor always from BASE (it has tokenizer & preprocessor files)
processor = AutoProcessor.from_pretrained(BASE_ID)
if args.model in ("fine", "both"):
fine_model = load_model(FINE_ID)
out = run_once(fine_model, processor, args.image, args.max_new_tokens)
print("\n=== Output (FINE) ===")
print(out)
if args.model in ("base", "both"):
base_model = load_model(BASE_ID)
out = run_once(base_model, processor, args.image, args.max_new_tokens)
print("\n=== Output (BASE) ===")
print(out)
if __name__ == "__main__":
main()
- Downloads last month
- 51
Model tree for JoseferEins/SmolVLM-500M-Instruct-fer0
Base model
HuggingFaceTB/SmolLM2-360M
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="JoseferEins/SmolVLM-500M-Instruct-fer0", filename="gguf/emovlm-500m.gguf", )