Note: This README and repository are for educational purposes. The creation of this repo was inspired by the DINOv3 paper to help visualize and understand the output of the model.
This repository provides interactive tools to visualize and explore patch-wise similarity in images using the DINOv3 vision transformer model. It is designed for researchers, students, and practitioners interested in understanding how self-supervised vision transformers perceive and relate different regions of an image.
Interactive tool to visualize patch-wise similarity in images using DINOv3 models. Select any Hugging Face DINOv3 model, load an image, and explore cosine similarity heatmaps for educational and research purposes.
| Path | Description |
|---|---|
assets/ | Images, figures, or other supporting media used by the project. |
.gitattributes | Top-level file included in the repository. |
.gitignore | Top-level file included in the repository. |
app.py | Top-level file included in the repository. |
camera_similarity.py | Top-level file included in the repository. |
DINOv3CosSimilarity.py | Top-level file included in the repository. |
LICENSE | Repository license information. |
PatchCosSimilarity.ipynb | Notebook used for experiments, analysis, or interactive demos. |
README.md | Primary project documentation. |
requirements.txt | Python dependency specification for local setup. |
Clone the repository.
git clone https://github.com/devMuniz02/DINOv3-Interactive-Patch-Cosine-Similarity.git
cd DINOv3-Interactive-Patch-Cosine-Similarity
Prepare the local environment.
Install Python dependencies:
pip install -r requirements.txt
Run the main application:
python app.py
Install dependencies with:
pip install -r requirements.txt
Run the Gradio app:
python app.py
After runnig the app, go to http://localhost:7860/ to see the app running.
Then:
Note:
Overlay alpha is the intensity of the overlay of patches on top of image
Run the interactive viewer with the default COCO image:
python DINOv3CosSimilarity.py
Specify your own image (local path or URL):
python DINOv3CosSimilarity.py --image path/to/your/image.jpg
python DINOv3CosSimilarity.py --image https://yourdomain.com/image.png
Specify two images (local paths or URLs):
python DINOv3CosSimilarity.py --image1 path/to/image1.jpg --image2 path/to/image2.jpg
python DINOv3CosSimilarity.py --image1 https://yourdomain.com/image1.png --image2 https://yourdomain.com/image2.png
Specify the model with --model (default is vits16):
python DINOv3CosSimilarity.py --model facebook/dinov3-vitb16-pretrain-lvd1689m
--show_grid : Draw patch grid--annotate_indices : Write patch indices on cells--overlay_alpha <float> : Set heatmap alpha (default 0.55)--patch_size <int> : Override patch size (default: model's patch size)

Experience DINOv3 patch similarity in real-time with your camera:
python camera_similarity.py
This interactive camera application displays a 3x2 grid showing:
Camera Controls:
Demo Video:
Requirements:
PatchCosSimilarity.ipynb in Jupyter Notebook.url1 for single-image mode, or both url1 and url2 for two-image mode.model_id variable to any of the models listed above (see commented lines at the top of the notebook).Notebook Controls:
This project is licensed under the MIT License. See the LICENSE file for details.
This project utilizes the DINOv3 model from Hugging Face's Transformers library, along with PyTorch, Matplotlib, and Pillow
This repository provides interactive tools to visualize and explore patch-wise similarity in images using the DINOv3 vision transformer model. It is designed for researchers, students, and practitioners interested in understanding how self-supervised vision transformers perceive and relate different regions of an image.
21 commits
Jupyter Notebook
98.3%
Python
1.7%
Note: This README and repository are for educational purposes. The creation of this repo was inspired by the DINOv3 paper to help visualize and understand the output of the model.
This repository provides interactive tools to visualize and explore patch-wise similarity in images using the DINOv3 vision transformer model. It is designed for researchers, students, and practitioners interested in understanding how self-supervised vision transformers perceive and relate different regions of an image.
Interactive tool to visualize patch-wise similarity in images using DINOv3 models. Select any Hugging Face DINOv3 model, load an image, and explore cosine similarity heatmaps for educational and research purposes.
| Path | Description |
|---|---|
assets/ | Images, figures, or other supporting media used by the project. |
.gitattributes | Top-level file included in the repository. |
.gitignore | Top-level file included in the repository. |
app.py | Top-level file included in the repository. |
camera_similarity.py | Top-level file included in the repository. |
DINOv3CosSimilarity.py | Top-level file included in the repository. |
LICENSE | Repository license information. |
PatchCosSimilarity.ipynb | Notebook used for experiments, analysis, or interactive demos. |
README.md | Primary project documentation. |
requirements.txt | Python dependency specification for local setup. |
Clone the repository.
git clone https://github.com/devMuniz02/DINOv3-Interactive-Patch-Cosine-Similarity.git
cd DINOv3-Interactive-Patch-Cosine-Similarity
Prepare the local environment.
Install Python dependencies:
pip install -r requirements.txt
Run the main application:
python app.py
Install dependencies with:
pip install -r requirements.txt
Run the Gradio app:
python app.py
After runnig the app, go to http://localhost:7860/ to see the app running.
Then:
Note:
Overlay alpha is the intensity of the overlay of patches on top of image
Run the interactive viewer with the default COCO image:
python DINOv3CosSimilarity.py
Specify your own image (local path or URL):
python DINOv3CosSimilarity.py --image path/to/your/image.jpg
python DINOv3CosSimilarity.py --image https://yourdomain.com/image.png
Specify two images (local paths or URLs):
python DINOv3CosSimilarity.py --image1 path/to/image1.jpg --image2 path/to/image2.jpg
python DINOv3CosSimilarity.py --image1 https://yourdomain.com/image1.png --image2 https://yourdomain.com/image2.png
Specify the model with --model (default is vits16):
python DINOv3CosSimilarity.py --model facebook/dinov3-vitb16-pretrain-lvd1689m
--show_grid : Draw patch grid--annotate_indices : Write patch indices on cells--overlay_alpha <float> : Set heatmap alpha (default 0.55)--patch_size <int> : Override patch size (default: model's patch size)

Experience DINOv3 patch similarity in real-time with your camera:
python camera_similarity.py
This interactive camera application displays a 3x2 grid showing:
Camera Controls:
Demo Video:
Requirements:
PatchCosSimilarity.ipynb in Jupyter Notebook.url1 for single-image mode, or both url1 and url2 for two-image mode.model_id variable to any of the models listed above (see commented lines at the top of the notebook).Notebook Controls:
This project is licensed under the MIT License. See the LICENSE file for details.
This project utilizes the DINOv3 model from Hugging Face's Transformers library, along with PyTorch, Matplotlib, and Pillow
This repository provides interactive tools to visualize and explore patch-wise similarity in images using the DINOv3 vision transformer model. It is designed for researchers, students, and practitioners interested in understanding how self-supervised vision transformers perceive and relate different regions of an image.
21 commits
Jupyter Notebook
98.3%
Python
1.7%