okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
0479b72e9
main
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 ; 15bool gpu_hidden = true; 16for (int i = 1 ;i < argc ;++ i ) { 17const std::string a = argv [i ]; 18auto next = [& ]()-> std::string { 19if (i + 1 >=argc ) { std::fprintf (stderr ,"%s needs a value\n" ,a .c_str ()); std::exit (2 ); } 20return argv [++ i ]; 21 }; 22if (a == "--mmproj" )o .mmproj = next (); 23else if (a == "--gpu" ) {o .gpu = true;gpu_hidden = false; } 24else if (a == "--threads" )o .threads = std::atoi (next ().c_str ()); 25else if (a == "--max-tokens" )o .max_tokens = std::atoi (next ().c_str ()); 26else if (a == "--min-tokens" )o .min_tokens = std::atoi (next ().c_str ()); 27else if (a == "--model" || a == "--tower" || a == "--flash-attn" )next (); 28else if (a == "--version" ) { std::printf ("strata-vision-own\n" );return 0 ; } 29else { std::fprintf (stderr ,"unknown argument %s\n" ,a .c_str ());return 2 ; } 30 } 31if (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 ; } 32if (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 37setenv ("CUDA_VISIBLE_DEVICES" ,"-1" ,1 ); 38setenv ("HIP_VISIBLE_DEVICES" ,"-1" ,1 ); 39#endif 40 } 41return strata_vit::own_reader_run (o ); 42}