Run this model with HF Jobs
Run vikhyatk/moondream2 on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/vikhyatk/moondream2. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/vikhyatk/moondream2 on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/vikhyatk/moondream2. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/vikhyatk/moondream2. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
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)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("vikhyatk/moondream2", trust_remote_code=True, device_map="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
Update README.md
Browse files2 unmodified lines34567891011121314151617181920212223242526272829303132333435363738394041424344452 unmodified linespipeline_tag: image-text-to-text---moondream is a small vision language model designed to run efficiently on edge devices. Check out the [GitHub repository](https://github.com/vikhyat/moondream) for details, or try it out on the [Hugging Face Space](https://huggingface.co/spaces/vikhyatk/moondream2)!**Benchmarks**| Release | VQAv2 | GQA | TextVQA | DocVQA | TallyQA<br>(simple/full) | POPE<br>(rand/pop/adv) || --- | --- | --- | --- | --- | --- | --- || **2024-08-26** (latest) | 80.3 | 64.3 | 65.2 | 70.5 | 82.6 / 77.6 | 89.6 / 88.8 / 87.2 || 2024-07-23 | 79.4 | 64.9 | 60.2 | 61.9 | 82.0 / 76.8 | 91.3 / 89.7 / 86.9 || 2024-05-20 | 79.4 | 63.1 | 57.2 | 30.5 | 82.1 / 76.6 | 91.5 / 89.6 / 86.2 || 2024-05-08 | 79.0 | 62.7 | 53.1 | 30.5 | 81.6 / 76.1 | 90.6 / 88.3 / 85.0 || 2024-04-02 | 77.7 | 61.7 | 49.7 | 24.3 | 80.1 / 74.2 | - || 2024-03-13 | 76.8 | 60.6 | 46.4 | 22.2 | 79.6 / 73.3 | - || 2024-03-06 | 75.4 | 59.8 | 43.1 | 20.9 | 79.5 / 73.2 | - || 2024-03-04 | 74.2 | 58.5 | 36.4 | - | - | - |**Usage**```bashpip install transformers einops``````pythonfrom transformers import AutoModelForCausalLM, AutoTokenizerfrom PIL import Imagemodel_id = "vikhyatk/moondream2"revision = "2024-08-26"model = AutoModelForCausalLM.from_pretrained(model_id, trust_remote_code=True, revision=revision)tokenizer = AutoTokenizer.from_pretrained(model_id, revision=revision)image = Image.open('<IMAGE_PATH>')enc_image = model.encode_image(image)print(model.answer_question(enc_image, "Describe this image.", tokenizer))```The model is updated regularly, so we recommend pinning the model version to aspecific release as shown above.2 unmodified lines3456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051522 unmodified linespipeline_tag: image-text-to-text---Moondream is a small vision language model designed to run efficiently on edge devices.* [Website](https://moondream.ai/)* [Demo](https://moondream.ai/playground)* [GitHub](https://github.com/vikhyat/moondream)This repository contains the latest (**2025-01-09**) release of Moondream, as well as historical releases. The model is updated frequently, so we recommend specifying a revision as shown below if you're using it in a production application.**Usage**```pythonfrom transformers import AutoModelForCausalLM, AutoTokenizerfrom PIL import Imagemodel = AutoModelForCausalLM.from_pretrained("vikhyatk/moondream2",revision="2025-01-09",trust_remote_code=True,# Uncomment to run on GPU.# device_map={"": "cuda"})# Captioningprint("Short caption:")print(model.caption(image, length="short")["caption"])print("\nNormal caption:")for t in model.caption(image, length="normal", stream=True)["caption"]:# Streaming generation example, supported for caption() and detect()print(t, end="", flush=True)print(model.caption(image, length="normal"))# Visual Queryingprint("\nVisual query: 'How many people are in the image?'")print(model.query(image, "How many people are in the image?")["answer"])# Object Detectionprint("\nObject detection: 'face'")objects = model.detect(image, "face")["objects"]print(f"Found {len(objects)} face(s)")# Pointingprint("\nPointing: 'person'")points = model.point(image, "person")["points"]print(f"Found {len(points)} person(s)")```
README.md+34-27