okami.mom/strata

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

Niko1221Merge f-ds-out ac306afb2 into f-own-intaff3a132f

main
1.5 KiB23 linesraw
1/** Prepared vision files stay in the source config; activation belongs to a loaded instance. */
2export function runtimeVision(config,requested){
3 const mode=requested??(config.ui_vision_enabled===false?'no':config.ui_vision_device);
4 if(mode!==undefined&&!['yes','no','cpu','gpu'].includes(mode))throw new Error('Choose whether to enable picture reading.');
5 if(mode==='no')return undefined;
6 if(mode===undefined)return config.vision;
7 if(!config.vision)throw new Error('Prepare this model’s vision files before enabling picture reading.');
8 if(mode==='cpu'&&config.vision.cpu_exe){const {cpu_exe,...rest}=config.vision;return {...rest,exe:cpu_exe,gpu:false};} // AMD: the CPU reader program, not the HIP one with the GPU hidden
9 return {...config.vision,...(mode==='cpu'?{gpu:false}:mode==='gpu'?{gpu:true}:{})};
10}
11
12/**
13 * The catalog with each picture-capable size marked as ready (`images`) or not (`imagesCapable` stays true either way). The Qwen engines
14 * read pictures with a separate program (strata-vision) that has to sit in the engine folder.
15 */
16export function markPictures(catalog,visionReader){
17 if(!catalog||!Array.isArray(catalog.families))return catalog;
18 const ready=(s)=>!!s.images&&visionReader===true;
19 return {...catalog,families:catalog.families.map(f=>{
20  const sizes=(f.sizes??[]).map(s=>({...s,imagesCapable:!!s.images,images:ready(s)}));
21  return {...f,imagesCapable:!!f.images,images:sizes.length?sizes.some(s=>s.images):!!f.images&&visionReader===true,sizes};
22 })};
23}