This project is a local desktop app for exploring image similarity on Apple Silicon with DINOv2, Hugging Face Transformers, and a native Qt UI. It supports side-by-side image browsing, click-based patch selection, and similarity heat maps across a second image.
The repository includes demo assets in test_images/ so the app is ready to run immediately after setup.
embed: returns one normalized embedding vector for an imagedense: returns normalized per-patch features for an image, which is the building block for pixel or region similarity heat maps
This portfolio version is intentionally fixed to:
facebook/dinov2-baseThat keeps the app behavior simple and consistent, and it gave the best results in local testing on an M1 with 16GB memory.
This project is pinned to Python 3.12 because PyTorch support tends to lag behind the newest Python release.
Install dependencies with:
uv syncRun the lightweight test suite with:
uv run python -m unittest discover -s testsOnce the repository is on GitHub, you can install it directly from the repo URL:
pip install git+https://github.com/morishuz/semantic-similarity-explorer.gitOr with uv:
uv pip install git+https://github.com/morishuz/semantic-similarity-explorer.gitAfter install, you can launch the app with:
dino-uiExtract one embedding vector:
uv run python main.py embed /path/to/image.jpgExtract dense patch features:
uv run python main.py dense /path/to/image.jpgPut the images you want to browse into:
test_images/Then launch the desktop app:
uv run python app.pyOr:
uv run dino-uiThe UI will:
- read images from
test_images - let you select a left and right image from dropdowns
- show the two selected images side by side
- refresh the dropdowns if you add more files while the app is open
- let you click a position on the left image and render a patch-similarity heat map over the right image
- run as a native Qt window through
PySide6, which gives us a better path for richer click interaction, overlays, and zoom behavior
- The script uses
mpsautomatically on Apple Silicon when available, otherwise it falls back to CPU. - The current heat map uses normalized patch-feature similarity and maps click positions by normalized image coordinates.
- If an MPS kernel is missing for a specific op, try
PYTORCH_ENABLE_MPS_FALLBACK=1.
