okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-own-3v (aec86299d) into f-own-int: our own Qwen vision tower (mtmd stays the default)0479b72e9

main
2.1 KiB42 linesraw
1// tools/vision/own/own_main.cpp - strata-vision-own: the picture reader on our own tower alone (no ggml, no llama.cpp, no mtmd).
2//
3//   strata-vision-own --mmproj <mmproj.gguf> [--gpu] [--threads N] [--max-tokens N] [--min-tokens N]    (--model and --tower are accepted and ignored)
4// The same protocol as strata-vision (see own_reader.h).  It builds in seconds on a Linux box, which is what the tower's CPU / CUDA / HIP checks use;
5// the shipped program is still strata-vision, which carries this reader as `--tower own`.
6#include "own_reader.h"
7
8#include <cstdio>
9#include <cstdlib>
10#include <cstring>
11#include <string>
12
13int main(int argc, char** argv) {
14    strata_vit::OwnReaderOptions o;
15    bool gpu_hidden = true;
16    for (int i = 1; i < argc; ++i) {
17        const std::string a = argv[i];
18        auto next = [&]() -> std::string {
19            if (i + 1 >= argc) { std::fprintf(stderr, "%s needs a value\n", a.c_str()); std::exit(2); }
20            return argv[++i];
21        };
22        if (a == "--mmproj") o.mmproj = next();
23        else if (a == "--gpu") { o.gpu = true; gpu_hidden = false; }
24        else if (a == "--threads") o.threads = std::atoi(next().c_str());
25        else if (a == "--max-tokens") o.max_tokens = std::atoi(next().c_str());
26        else if (a == "--min-tokens") o.min_tokens = std::atoi(next().c_str());
27        else if (a == "--model" || a == "--tower" || a == "--flash-attn") next();
28        else if (a == "--version") { std::printf("strata-vision-own\n"); return 0; }
29        else { std::fprintf(stderr, "unknown argument %s\n", a.c_str()); return 2; }
30    }
31    if (o.mmproj.empty()) { std::fprintf(stderr, "usage: strata-vision-own --mmproj <mmproj.gguf> [--gpu] [--threads N] [--max-tokens N] [--min-tokens N]\n"); return 2; }
32    if (gpu_hidden) {   // on the CPU the GPU stays unseen (as strata-vision does)
33#ifdef _WIN32
34        _putenv_s("CUDA_VISIBLE_DEVICES", "-1");
35        _putenv_s("HIP_VISIBLE_DEVICES", "-1");
36#else
37        setenv("CUDA_VISIBLE_DEVICES", "-1", 1);
38        setenv("HIP_VISIBLE_DEVICES", "-1", 1);
39#endif
40    }
41    return strata_vit::own_reader_run(o);
42}