Skip to content

examples from moondream-examples#332

Merged
EthanReid merged 4 commits into
mainfrom
ethan/add_examples
Apr 20, 2026
Merged

examples from moondream-examples#332
EthanReid merged 4 commits into
mainfrom
ethan/add_examples

Conversation

@EthanReid
Copy link
Copy Markdown
Contributor

Deprecating Moondream-examples, copied examples to the main MD repo.

Copilot AI review requested due to automatic review settings April 20, 2026 06:49
@EthanReid EthanReid merged commit 6eccfce into main Apr 20, 2026
0 of 5 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds quickstart and finetuning example code (previously in moondream-examples) into this repo to consolidate and deprecate the separate examples repository.

Changes:

  • Adds Python/Node/Bash quickstart examples for running Moondream locally or via cloud.
  • Adds Modal deployment + inference examples for hosting Moondream Station on Modal.
  • Adds multiple finetuning example scripts for query/detect training workflows.

Reviewed changes

Copilot reviewed 20 out of 23 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
examples/quickstart/python/requirements.txt Introduces Python quickstart dependencies.
examples/quickstart/python/main.py Adds minimal Python captioning example.
examples/quickstart/python/README.md Documents Python quickstart setup and running.
examples/quickstart/node/package.json Defines Node quickstart package metadata and deps.
examples/quickstart/node/package-lock.json Locks Node quickstart dependency tree.
examples/quickstart/node/main.js Adds Node captioning example.
examples/quickstart/node/README.md Documents Node quickstart setup and running.
examples/quickstart/node/.gitignore Adds ignore rules for the Node quickstart folder.
examples/quickstart/modal/requirements.txt Defines Python deps for Modal examples.
examples/quickstart/modal/modal_infer.py Adds Modal endpoint inference example (query/caption/detect/point).
examples/quickstart/modal/deploy_moondream.py Adds Modal deployment script for Moondream Station.
examples/quickstart/modal/README.md Documents Modal deployment + inference workflow.
examples/quickstart/modal/.DS_Store Adds a macOS metadata artifact file.
examples/quickstart/finetune/train_ssv2_3x3_query.py Adds SSV2 3x3 query finetuning example.
examples/quickstart/finetune/train_rps_query.py Adds rock/paper/scissors query finetuning example.
examples/quickstart/finetune/train_ishape_logs_detect.py Adds iShape logs detect finetuning example.
examples/quickstart/finetune/train_ishape_antenna_detect.py Adds iShape antenna detect finetuning example.
examples/quickstart/finetune/train_glaucoma_query.py Adds glaucoma stage query finetuning example.
examples/quickstart/finetune/train_geoguessr_countries_query.py Adds GeoGuessr country query finetuning example.
examples/quickstart/finetune/train_ballholder_detect.py Adds ball-holder detect finetuning example.
examples/quickstart/bash/main.sh Adds cURL-based quickstart script.
examples/quickstart/bash/README.md Documents Bash quickstart usage.
.gitignore Adds ignores for .DS_Store (scoped) and .vscode/settings.json.
Files not reviewed (1)
  • examples/quickstart/node/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# model = md.vl(api_key="<your-api-key>")

# Load an image
image = Image.open("../../images/frieren.jpg")
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example loads ../../images/frieren.jpg, but there is no images/ directory in this repo (only assets/ exists). This makes the quickstart fail out of the box; either add the referenced image(s) to the repo at that path or update the code to point at an existing sample image (e.g. under assets/).

Suggested change
image = Image.open("../../images/frieren.jpg")
image = Image.open("../../assets/frieren.jpg")

Copilot uses AI. Check for mistakes.
Comment on lines +10 to +12
// read the image we're going to use
const image = fs.readFileSync("../images/frieren.jpg");

Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example reads ../images/frieren.jpg, but there is no examples/quickstart/images/ directory in this repo. Update the path to a real sample image location (or add the image) so the Node quickstart runs without manual asset setup.

Copilot uses AI. Check for mistakes.
pip install -r requirements.txt
```

3. Run Moondream Station locally or tweak the [main.py](quickstart/python/main.py) or run on the cloud using an [API key](https://moondream.ai/c/cloud/api-keys).
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The README link [main.py](quickstart/python/main.py) is incorrect relative to this README’s location and resolves to a non-existent path. Update it to a working relative link (e.g. main.py) and keep the step text consistent.

Suggested change
3. Run Moondream Station locally or tweak the [main.py](quickstart/python/main.py) or run on the cloud using an [API key](https://moondream.ai/c/cloud/api-keys).
3. Run Moondream Station locally or tweak the [main.py](main.py) or run on the cloud using an [API key](https://moondream.ai/c/cloud/api-keys).

Copilot uses AI. Check for mistakes.
Comment on lines +8 to +10

image = Image.open("../../images/frieren.jpg")

Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example opens ../../images/frieren.jpg, but there is no images/ directory in the repo. Update the path to an existing sample image (e.g. under assets/) or include the referenced image so the Modal inference example runs out of the box.

Copilot uses AI. Check for mistakes.
To launch Moondream Station on Modal Labs, first make sure you're in the correct repository:

```
cd quickstart/modal
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The instructions say cd quickstart/modal, but the actual path in this repo is examples/quickstart/modal. As written, users following the README from repo root will end up in a non-existent directory.

Suggested change
cd quickstart/modal
cd examples/quickstart/modal

Copilot uses AI. Check for mistakes.
4. Run the examples to see Moondream in action!

```bash
node main.py
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The README instructs running node main.py, but the Node example file is main.js. This command will fail as written; update it to node main.js (or npm run run).

Suggested change
node main.py
node main.js

Copilot uses AI. Check for mistakes.
Comment on lines +2 to +18

## To run locally
curl --location "http://localhost:2020/v1/{endpoint}" \
--header 'Content-Type: application/json' \
--data '{
"image_url": "data:image/jpeg;base64,${cat ../images/frieren.jpg | base64}",
"stream": false
}'

## To run on cloud
# curl --location "https://api.moondream.ai/v1/{endpoint}"
# --header 'X-Moondream-Auth: ${MOONDREAM_API_KEY}' \
# --header 'Content-Type: application/json' \
# --data '{
# "image_url": "data:image/jpeg;base64,${cat ../images/frieren.jpg | base64}",
# "stream": false
# }'
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script references ../images/frieren.jpg, but this repo does not contain that path. Update the example to use an existing sample image in the repo (or add the referenced image).

Suggested change
## To run locally
curl --location "http://localhost:2020/v1/{endpoint}" \
--header 'Content-Type: application/json' \
--data '{
"image_url": "data:image/jpeg;base64,${cat ../images/frieren.jpg | base64}",
"stream": false
}'
## To run on cloud
# curl --location "https://api.moondream.ai/v1/{endpoint}"
# --header 'X-Moondream-Auth: ${MOONDREAM_API_KEY}' \
# --header 'Content-Type: application/json' \
# --data '{
# "image_url": "data:image/jpeg;base64,${cat ../images/frieren.jpg | base64}",
# "stream": false
# }'
#
# Set IMAGE_PATH to a local image file before running, for example:
# export IMAGE_PATH=./path/to/image.jpg
## To run locally
curl --location "http://localhost:2020/v1/{endpoint}" \
--header 'Content-Type: application/json' \
--data "{
\"image_url\": \"data:image/jpeg;base64,$(base64 < \"${IMAGE_PATH}\")\",
\"stream\": false
}"
## To run on cloud
# curl --location "https://api.moondream.ai/v1/{endpoint}" \
# --header "X-Moondream-Auth: ${MOONDREAM_API_KEY}" \
# --header 'Content-Type: application/json' \
# --data "{
# \"image_url\": \"data:image/jpeg;base64,$(base64 < \"${IMAGE_PATH}\")\",
# \"stream\": false
# }"

Copilot uses AI. Check for mistakes.
Comment on lines +55 to +56
![alt text](../../images/modal/example-image.png)

Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The README references an image at ../../images/modal/example-image.png, but this repo has no images/ directory and the referenced file doesn’t exist. Replace it with a valid path (e.g. under assets/) or remove the broken image link.

Suggested change
![alt text](../../images/modal/example-image.png)

Copilot uses AI. Check for mistakes.

@app.function(
image=image,
memory=4096, # Change your alloted memory here.
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in comment: alloted should be allotted.

Suggested change
memory=4096, # Change your alloted memory here.
memory=4096, # Change your allotted memory here.

Copilot uses AI. Check for mistakes.
Comment on lines +6 to +18
--data '{
"image_url": "data:image/jpeg;base64,${cat ../images/frieren.jpg | base64}",
"stream": false
}'

## To run on cloud
# curl --location "https://api.moondream.ai/v1/{endpoint}"
# --header 'X-Moondream-Auth: ${MOONDREAM_API_KEY}' \
# --header 'Content-Type: application/json' \
# --data '{
# "image_url": "data:image/jpeg;base64,${cat ../images/frieren.jpg | base64}",
# "stream": false
# }'
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script won’t interpolate the base64 image because the JSON is wrapped in single quotes, and it uses invalid substitution syntax (${cat ...}) instead of $(...). As written it will send the literal string. Use command substitution and quoting that allows expansion (or build the JSON via a heredoc), and ensure base64 output is newline-free.

Suggested change
--data '{
"image_url": "data:image/jpeg;base64,${cat ../images/frieren.jpg | base64}",
"stream": false
}'
## To run on cloud
# curl --location "https://api.moondream.ai/v1/{endpoint}"
# --header 'X-Moondream-Auth: ${MOONDREAM_API_KEY}' \
# --header 'Content-Type: application/json' \
# --data '{
# "image_url": "data:image/jpeg;base64,${cat ../images/frieren.jpg | base64}",
# "stream": false
# }'
--data "{
\"image_url\": \"data:image/jpeg;base64,$(base64 < ../images/frieren.jpg | tr -d '\n')\",
\"stream\": false
}"
## To run on cloud
# curl --location "https://api.moondream.ai/v1/{endpoint}" \
# --header "X-Moondream-Auth: ${MOONDREAM_API_KEY}" \
# --header 'Content-Type: application/json' \
# --data "{
# \"image_url\": \"data:image/jpeg;base64,$(base64 < ../images/frieren.jpg | tr -d '\n')\",
# \"stream\": false
# }"

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants