chore: remove dead object/SigLIP references after pipeline removal
- cache.py: drop siglip MODEL_VERSIONS entry - log_config.py: drop ultralytics/transformers/torch from noise silencers - scheduler.py: drop HF_HOME and HuggingFace model check - scripts/benchmark.py: drop bench_siglip and make_random_image
This commit is contained in:
@@ -16,7 +16,6 @@ except ImportError:
|
|||||||
from winnow.cli import main
|
from winnow.cli import main
|
||||||
|
|
||||||
SCHEDULE = os.environ["CRON_SCHEDULE"]
|
SCHEDULE = os.environ["CRON_SCHEDULE"]
|
||||||
MODELS_DIR = os.environ.get("HF_HOME", "/models/huggingface")
|
|
||||||
INSIGHTFACE_HOME = os.environ.get("INSIGHTFACE_HOME", "/models/.insightface")
|
INSIGHTFACE_HOME = os.environ.get("INSIGHTFACE_HOME", "/models/.insightface")
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -24,11 +23,8 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
def check_models() -> None:
|
def check_models() -> None:
|
||||||
buffalo = Path(INSIGHTFACE_HOME) / "models" / "buffalo_l"
|
buffalo = Path(INSIGHTFACE_HOME) / "models" / "buffalo_l"
|
||||||
hf_hub = Path(MODELS_DIR) / "hub"
|
|
||||||
if not buffalo.exists():
|
if not buffalo.exists():
|
||||||
print(" InsightFace Buffalo_L not found — will download on first run", flush=True)
|
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()
|
NOW = time.time()
|
||||||
|
|||||||
+2
-66
@@ -2,8 +2,8 @@
|
|||||||
"""
|
"""
|
||||||
winnow inference benchmark: GPU vs CPU throughput.
|
winnow inference benchmark: GPU vs CPU throughput.
|
||||||
|
|
||||||
Measures InsightFace (face mode) and SigLIP (object mode) latency and
|
Measures InsightFace (ArcFace) latency and throughput.
|
||||||
throughput. Run with FORCE_CPU=true for CPU-only baseline.
|
Run with FORCE_CPU=true for CPU-only baseline.
|
||||||
|
|
||||||
Usage inside container:
|
Usage inside container:
|
||||||
# GPU mode:
|
# GPU mode:
|
||||||
@@ -47,11 +47,6 @@ def make_face_image(size: int = 640) -> Image.Image:
|
|||||||
return img
|
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:
|
def _stats(times_s: list[float]) -> dict:
|
||||||
arr = np.array(times_s) * 1000 # ms
|
arr = np.array(times_s) * 1000 # ms
|
||||||
return {
|
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)")
|
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:
|
def main() -> None:
|
||||||
print("=" * 56)
|
print("=" * 56)
|
||||||
print(" winnow inference benchmark")
|
print(" winnow inference benchmark")
|
||||||
@@ -185,10 +125,6 @@ def main() -> None:
|
|||||||
bench_insightface()
|
bench_insightface()
|
||||||
print()
|
print()
|
||||||
|
|
||||||
print("── SigLIP google/siglip-base-patch16-224 (objects) ───")
|
|
||||||
bench_siglip()
|
|
||||||
print()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# Add winnow to path when run directly inside container
|
# Add winnow to path when run directly inside container
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ logger = logging.getLogger(__name__)
|
|||||||
# Model versions — bump these when the upstream model changes
|
# Model versions — bump these when the upstream model changes
|
||||||
MODEL_VERSIONS = {
|
MODEL_VERSIONS = {
|
||||||
"insightface": "buffalo_l_v1",
|
"insightface": "buffalo_l_v1",
|
||||||
"siglip": "siglip-base-patch16-224_v1",
|
|
||||||
"immich": "immich_buffalo_l_v1",
|
"immich": "immich_buffalo_l_v1",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,12 +13,9 @@ console = Console()
|
|||||||
NOISY_LOGGERS = (
|
NOISY_LOGGERS = (
|
||||||
"urllib3",
|
"urllib3",
|
||||||
"PIL",
|
"PIL",
|
||||||
"ultralytics",
|
|
||||||
"insightface",
|
"insightface",
|
||||||
"onnxruntime",
|
"onnxruntime",
|
||||||
"matplotlib",
|
"matplotlib",
|
||||||
"transformers",
|
|
||||||
"torch",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -51,7 +48,6 @@ def setup_logging(verbose: bool = False) -> logging.Logger:
|
|||||||
|
|
||||||
# Suppress Python warnings from ML libraries
|
# Suppress Python warnings from ML libraries
|
||||||
warnings.filterwarnings("ignore", category=UserWarning, module="onnxruntime")
|
warnings.filterwarnings("ignore", category=UserWarning, module="onnxruntime")
|
||||||
warnings.filterwarnings("ignore", category=FutureWarning, module="transformers")
|
|
||||||
|
|
||||||
return root
|
return root
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user