Skip to main content
Built by Best ROI Media · First-Party IntegrationMITWave 4 · LiveBestRoiMedia/bestroi-game-tools

vision

Shared local DINOv2, CLIP, and classical image descriptor library with disk caching.

Offline Python embedding and image-descriptor library powering lookalike and assetfind, providing cached DINOv2 and CLIP embeddings on Apple MPS alongside classical edge, luminance, palette, and saliency metrics.

View on GitHub ↗
Quick clonegit clone https://github.com/BestRoiMedia/bestroi-game-tools.git
GitHub repositoryBestRoiMedia/bestroi-game-tools
Module path_tools/vision/
LicenseMIT
Release waveWave 4
LanguagesPython

Why we built it

Multiple QA and asset tools needed fast, reproducible visual embeddings without paying per-call cloud API fees or duplicating model-loading and caching boilerplate.

Architecture & how it works

vision/embed.py loads facebook/dinov2-small, facebook/dinov2-base, and openai/clip-vit-base-patch32 from the local Hugging Face cache on Apple MPS (or CPU), squashes full frames to preserve whole-room composition, and caches vectors in ~/.cache/vision_embed/ keyed by SHA-256 or pixel hash. It also exposes masked classical descriptors for edge orientation, edge density, Lab histograms, k-means palettes, and spectral-residual saliency.

Key capabilities

  • Local DINOv2-small/base CLS + mean-patch embeddings and 16x16 spatial patch grids
  • Local CLIP ViT-B/32 text and image embeddings for zero-shot visual search
  • Content-addressed disk cache keyed by file SHA-256 or pixel hash
  • Weight-masked classical descriptors (edges, luminance, Lab palette transport, saliency)
  • Unified image loader supporting PNG, JPG, WEBP, and SVG (via resvg)

Usage example

Compute DINOv2 and CLIP embeddings from PythonPython
from vision import embed as V

dino_vecs = V.dino(["./room_a.png", "./room_b.png"], size="base")
img_clip = V.clip_image(["./room_a.png"])
txt_clip = V.clip_text(["moonlit gothic window"])
similarity = img_clip @ txt_clip.T
Run python3 vision/embed.py doctor && python3 vision/embed.py selftest to verify MPS and models.