diff --git a/scheduler.py b/scheduler.py index c960fbf..0f7bb25 100644 --- a/scheduler.py +++ b/scheduler.py @@ -16,7 +16,6 @@ except ImportError: from winnow.cli import main SCHEDULE = os.environ["CRON_SCHEDULE"] -MODELS_DIR = os.environ.get("HF_HOME", "/models/huggingface") INSIGHTFACE_HOME = os.environ.get("INSIGHTFACE_HOME", "/models/.insightface") logger = logging.getLogger(__name__) @@ -24,11 +23,8 @@ logger = logging.getLogger(__name__) def check_models() -> None: buffalo = Path(INSIGHTFACE_HOME) / "models" / "buffalo_l" - hf_hub = Path(MODELS_DIR) / "hub" if not buffalo.exists(): print(" InsightFace Buffalo_L not found — will download on first run", flush=True) - if not (hf_hub.exists() and any(hf_hub.iterdir())): - print(" HuggingFace models not found — will download on first run", flush=True) NOW = time.time() diff --git a/scripts/benchmark.py b/scripts/benchmark.py index 2f384e5..6e5b992 100644 --- a/scripts/benchmark.py +++ b/scripts/benchmark.py @@ -2,8 +2,8 @@ """ winnow inference benchmark: GPU vs CPU throughput. -Measures InsightFace (face mode) and SigLIP (object mode) latency and -throughput. Run with FORCE_CPU=true for CPU-only baseline. +Measures InsightFace (ArcFace) latency and throughput. +Run with FORCE_CPU=true for CPU-only baseline. Usage inside container: # GPU mode: @@ -47,11 +47,6 @@ def make_face_image(size: int = 640) -> Image.Image: return img -def make_random_image(width: int = 224, height: int = 224) -> Image.Image: - rng = np.random.default_rng(42) - return Image.fromarray(rng.integers(0, 256, (height, width, 3), dtype=np.uint8), "RGB") - - def _stats(times_s: list[float]) -> dict: arr = np.array(times_s) * 1000 # ms return { @@ -119,61 +114,6 @@ def bench_insightface(n_warmup: int = 5, n_runs: int = 30) -> None: print(f" 320×320 median : {s2['median_ms']:.1f} ms ({s2['ips']:.1f} img/s)") -def bench_siglip( - n_warmup: int = 3, - n_runs: int = 20, - batch_sizes: tuple = (1, 4, 8, 16, 32), -) -> None: - import torch - - import winnow.embeddings as emb_mod - emb_mod._siglip_model = None - emb_mod._siglip_processor = None - emb_mod._siglip_loaded = False - - print(" Loading model...") - t_load = time.perf_counter() - model, processor = emb_mod.get_siglip_model() - load_s = time.perf_counter() - t_load - - if model is None: - print(" SKIP: SigLIP failed to load") - return - - device = next(model.parameters()).device - print(f" Model load time : {load_s:.2f} s (device: {device})") - - print(f" {'Batch':>5} {'ms/batch':>10} {'ms/img':>8} {'img/s':>8} {'p95/img':>9}") - for bs in batch_sizes: - imgs = [make_random_image(224, 224) for _ in range(bs)] - inputs = processor(images=imgs, return_tensors="pt") - inputs = {k: v.to(device) for k, v in inputs.items()} - - # Warmup - for _ in range(n_warmup): - with torch.no_grad(): - model(**inputs) - if str(device) != "cpu": - torch.cuda.synchronize() - - times: list[float] = [] - for _ in range(n_runs): - if str(device) != "cpu": - torch.cuda.synchronize() - t0 = time.perf_counter() - with torch.no_grad(): - model(**inputs) - if str(device) != "cpu": - torch.cuda.synchronize() - times.append(time.perf_counter() - t0) - - s = _stats(times) - print( - f" {bs:>5} {s['median_ms']:>10.1f} {s['median_ms']/bs:>8.2f}" - f" {bs * 1000 / s['median_ms']:>8.1f} {s['p95_ms']/bs:>9.2f}" - ) - - def main() -> None: print("=" * 56) print(" winnow inference benchmark") @@ -185,10 +125,6 @@ def main() -> None: bench_insightface() print() - print("── SigLIP google/siglip-base-patch16-224 (objects) ───") - bench_siglip() - print() - if __name__ == "__main__": # Add winnow to path when run directly inside container diff --git a/winnow/cache.py b/winnow/cache.py index 5d6e529..828139f 100644 --- a/winnow/cache.py +++ b/winnow/cache.py @@ -15,7 +15,6 @@ logger = logging.getLogger(__name__) # Model versions — bump these when the upstream model changes MODEL_VERSIONS = { "insightface": "buffalo_l_v1", - "siglip": "siglip-base-patch16-224_v1", "immich": "immich_buffalo_l_v1", } diff --git a/winnow/log_config.py b/winnow/log_config.py index fa75a29..0b5d0ee 100644 --- a/winnow/log_config.py +++ b/winnow/log_config.py @@ -13,12 +13,9 @@ console = Console() NOISY_LOGGERS = ( "urllib3", "PIL", - "ultralytics", "insightface", "onnxruntime", "matplotlib", - "transformers", - "torch", ) @@ -51,7 +48,6 @@ def setup_logging(verbose: bool = False) -> logging.Logger: # Suppress Python warnings from ML libraries warnings.filterwarnings("ignore", category=UserWarning, module="onnxruntime") - warnings.filterwarnings("ignore", category=FutureWarning, module="transformers") return root