examples from moondream-examples#332
Conversation
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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/).
| image = Image.open("../../images/frieren.jpg") | |
| image = Image.open("../../assets/frieren.jpg") |
| // read the image we're going to use | ||
| const image = fs.readFileSync("../images/frieren.jpg"); | ||
|
|
There was a problem hiding this comment.
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.
| 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). |
There was a problem hiding this comment.
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.
| 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). |
|
|
||
| image = Image.open("../../images/frieren.jpg") | ||
|
|
There was a problem hiding this comment.
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.
| To launch Moondream Station on Modal Labs, first make sure you're in the correct repository: | ||
|
|
||
| ``` | ||
| cd quickstart/modal |
There was a problem hiding this comment.
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.
| cd quickstart/modal | |
| cd examples/quickstart/modal |
| 4. Run the examples to see Moondream in action! | ||
|
|
||
| ```bash | ||
| node main.py |
There was a problem hiding this comment.
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).
| node main.py | |
| node main.js |
|
|
||
| ## 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 | ||
| # }' |
There was a problem hiding this comment.
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).
| ## 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 | |
| # }" |
|  | ||
|
|
There was a problem hiding this comment.
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.
|  |
|
|
||
| @app.function( | ||
| image=image, | ||
| memory=4096, # Change your alloted memory here. |
There was a problem hiding this comment.
Typo in comment: alloted should be allotted.
| memory=4096, # Change your alloted memory here. | |
| memory=4096, # Change your allotted memory here. |
| --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 | ||
| # }' |
There was a problem hiding this comment.
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.
| --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 | |
| # }" |
Deprecating Moondream-examples, copied examples to the main MD repo.