Instructions to use vikhyatk/moondream2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use vikhyatk/moondream2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="vikhyatk/moondream2", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("vikhyatk/moondream2", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use vikhyatk/moondream2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "vikhyatk/moondream2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "vikhyatk/moondream2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/vikhyatk/moondream2
- SGLang
How to use vikhyatk/moondream2 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 "vikhyatk/moondream2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "vikhyatk/moondream2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "vikhyatk/moondream2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "vikhyatk/moondream2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use vikhyatk/moondream2 with Docker Model Runner:
docker model run hf.co/vikhyatk/moondream2
Not as good as 1
Seems after some testing almost all the images I tried seem to give worse prompts (and slower) then version 1.
Result from 1:
"The woman in the image is wearing a blue dress and a short skirt while holding a golf club. She is standing on a lush green golf course, posing for the picture. The dress is sleeveless, and the skirt is short, giving her a stylish and confident appearance. The setting and the woman's outfit suggest that she might be a professional golfer or simply enjoying a leisurely round of golf."
Result from 2:
"A woman is standing in the image, dressed in a blue dress and holding a tennis racket. The background features a grassy area with trees and a sky overhead."
Can you try out the latest version (weights released today)? Should be better at descriptions. If it’s still being too terse please share some of the images and I’ll look into what’s going on.
Ok I got the new model working, it was better with the Mario dance image, I got ...
[moondream1]
{"result":"The image shows a group of people, including a man dressed as Mario, dancing to music. The man in the center of the image is wearing a white shirt and blue jeans, and he is jumping up and down while holding his hands up in the air. The other people in the group are also dancing and enjoying the music. The scene captures the fun and energetic atmosphere of a party or a dance event."}
[moondream2] 3-13-24
{"result":"The image is a digital animation of a group of people dancing on a colorful floor. The animation features a character, likely a character from the popular Mario franchise, dancing in the center of the image. The other characters in the scene are also dancing, creating a lively and energetic atmosphere. The animation is likely designed to be visually appealing and engaging for the audience."}
But with the lady on the golf course image from the previous post I still got a "tennis racket" ...
[moondream2] 3-13-24
{"result":"The woman in the image is wearing a blue dress and holding a tennis racket. She is posing for a picture on a golf course, surrounded by trees and bushes. The setting appears to be a beautiful outdoor location, perfect for a leisurely day of tennis or golf."}

