This repo is a minimal starter project for creating image embeddings (here using UNICOM), and then visualizing and exploring those embeddings with static and interactive plots:
- Rich feature representation through UNICOM
- Interactive plotting using the Bokeh Python package - also see my blog post
1. Clone this repo, and the UNICOM repo:
Make sure you have git and git lfs installed on your machine (e.g. via git lfs install).
git clone https://github.com/mluerig/demo-image-embeddings
git clone https://github.com/deepglint/unicom2. Install mamba via miniforge, or conda (Miniconda/Anaconda).
3. Open a terminal at the repo root dir, and create the environment from environment.yml:
mamba env create -f environment.yml -n unicom1Then activate it:
mamba activate unicom14. Optional: install PyTorch with GPU (NVIDIA) support. If you have a compatible CUDA GPU and drivers, install the CUDA build from the official channels:
mamba install nvidia::cuda-toolkit==12.6
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu126 --force-reinstallIf you do not have a GPU, you can skip this step. Embedding generation will still run on CPU, but it will be much slower.
5. Prepare the example data and run the notebooks:
- create embeddings in
scripts/01_create_embeddings.ipynb - visualize and explore them in
scripts/02_make_cluster_plots.ipynb
- The provided
environment.ymlkeeps PyTorch out by default so you can choose CPU or GPU builds explicitly. - The example workflow uses UNICOM embeddings, but the plotting notebooks can also be adapted to embeddings from other models.
