CoolFace
Apppublic

moebiusT7/book-ocr-studio

sourceHugging Faceagpl-3.0updated 2d agoView on Hugging Face
0likes
model_store.py25 linesDownload Raw Back to root
1"""Shared model-store selection for setup and GPU workers; no network actions."""2import json3import os4from pathlib import Path5 6DEFAULT_MODEL = 'gemma4:12b-it-qat'7OPTIONAL_MODEL = 'gemma4:26b-a4b-it-qat'8 9def model_directory(root, *, setup=False):10    root = Path(root)11    if os.environ.get('BOOK_OCR_MODELS'):12        return Path(os.environ['BOOK_OCR_MODELS']).expanduser().resolve()13    settings = root/'model-settings.json'14    if settings.exists():15        data = json.loads(settings.read_text(encoding='utf-8'))16        value = data.get('models_directory')17        if not isinstance(value, str) or not value or not Path(value).is_absolute():18            raise ValueError('Invalid model-settings.json: models_directory must be an absolute path')19        return Path(value)20    # Preserve the old installation path only for existing, unconfigured workers.21    legacy = Path('/usr/share/ollama/.ollama/models')22    if not setup and legacy.is_dir():23        return legacy24    return (root/'models').resolve()25