Skip to content

Commit 6db2e3a

Browse files
committed
fix(cli): address batched inference review findings
1 parent a4b695a commit 6db2e3a

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

‎dinov2-cli.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ int main(int argc, char **argv) {
196196
fprintf(stderr, "%s: preprocessed image (%d x %d)\n", __func__, img_f.nx, img_f.ny);
197197
imgs_f.push_back(std::move(img_f));
198198
}
199+
std::vector<Image>().swap(imgs);
199200

200201
// one graph covers a whole chunk, so all images inside an n_batch-sized
201202
// chunk must share dimensions; different chunks may differ

‎docs/cli.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ wording. Flags that take a value read it from the next argument.
4343
| `--batch N` | 1 | max images per forward pass (max 64); inputs run in chunks of N |
4444
| `-c`, `--classify` | off | classify each input image and print top-k labels |
4545
| `-k N`, `--topk` | 5 | number of classes printed with `-c` |
46-
| `--print-embeddings` | off | emit one embeddings JSON object on stdout |
46+
| `--print-embeddings` | off | emit one JSON object for one input; one JSON object per line (JSONL) for multiple inputs |
4747
| `--print-patch-tokens` | off | add per-patch token vectors to that JSON |
4848
| `--l2-normalize` | off | L2-normalize emitted embedding vectors |
4949
| `-o FNAME`, `--out` | off | write a PCA visualization of patch features; a directory for multiple inputs |
@@ -185,6 +185,10 @@ All data goes to stdout, all logs go to stderr. Pipe safely:
185185
dinov2-cli -m models/model.gguf -i assets/tench.jpg --print-embeddings | jq .cls
186186
```
187187

188+
For multi-input JSONL or PCA runs, a later chunk failure can leave stdout or PCA
189+
output partial after earlier chunks were emitted. The process exits 1; consumers
190+
must check the exit status before treating output as complete.
191+
188192
## Workflows
189193

190194
### Classify top-k

0 commit comments

Comments
 (0)