Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
python-version: "3.11"
- name: Compile Python (syntax check)
run: |
python -m py_compile image_database.py visualize_umap.py
python -m py_compile image_database.py
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ Please open a pull request for any change.

### Checks

CI runs a lightweight syntax check (`python -m py_compile`) on `image_database.py` and `visualize_umap.py`.
CI runs a lightweight syntax check (`python -m py_compile`) on `image_database.py`.
37 changes: 8 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ A searchable image database using SigLIP 2 (CLIP) embeddings and SQLite-vec for
- **Image Search**: Find similar images using a reference image
- **Combined Search**: Combine text and image queries with weighted blending
- **Interactive Mode**: Load model once and run multiple queries
- **3D Visualization**: UMAP-based 3D visualization of image embeddings with clustering
- **HTML Gallery**: Beautiful search results with image previews and direct file access

![Search Results Example](browser.png)
Expand All @@ -34,7 +33,7 @@ cd CLIP-database

2. Install dependencies:
```bash
cd github
cd core
pip install -r requirements.txt
```

Expand All @@ -53,7 +52,7 @@ pip install sqlite-vec
Scan a directory and build the image database:

```bash
cd github
cd core
python image_database.py scan /path/to/images --db "/path/to/database.db"
```

Expand All @@ -64,15 +63,15 @@ Options:
- `--limit`: Limit number of images to process (for testing)

```bash
cd github
cd core
python image_database.py scan /path/to/images --batch-size 75 --inference-batch-size 16 --profile --limit 100
```

### Searching Images

#### Text Search
```bash
cd github
cd core
python image_database.py search "a red car" -k 20 --db "/path/to/database.db"
```

Expand All @@ -83,25 +82,25 @@ python image_database.py search "a red car" --db "/path/to/database.db" -k 20

#### Image Search
```bash
cd github
cd core
python image_database.py search /path/to/image.jpg --image -k 20
```

#### Combined Search
```bash
cd github
cd core
python image_database.py search "sunset" --query2 /path/to/image.jpg --weights 0.7 0.3 -k 20
```

#### Negative Prompts
```bash
cd github
cd core
python image_database.py search "nature" --negative "buildings" -k 20
```

#### Interactive Mode
```bash
cd github
cd core
python image_database.py search --interactive
```

Expand All @@ -114,25 +113,6 @@ In interactive mode:
- Type `quit` or `exit` to end session


### 3D Visualization

Generate a UMAP 3D visualization of all image embeddings:

```bash
cd github
python visualize_umap.py
```

This will:
1. Load embeddings from the database
2. Compute UMAP projections (cached for future runs)
3. Cluster embeddings for color coding
4. Generate an interactive HTML visualization

Open the generated HTML file in your browser and click on points to see image previews.

**Note:** The HTML results include "Open Image" and "Open Folder" links that use the `localexplorer:` protocol. To use these links, install a browser extension like [Local Explorer](https://chrome.google.com/webstore/detail/local-explorer/llbiblehpbpeflfgjcdfcpcakjhddedi) for Chrome/Edge. Without the extension, images will still display, but the file/folder links won't work.

## Model

This project uses [SigLIP 2 SO400M](https://huggingface.co/google/siglip2-so400m-patch14-224) from Google, which provides:
Expand All @@ -154,7 +134,6 @@ The SQLite database contains:
- Use `--inference-batch-size` to optimize GPU memory usage
- Enable `--profile` to identify bottlenecks
- The database uses WAL mode for better concurrent access
- UMAP projections are cached to avoid recomputation

## License

Expand Down
5 changes: 1 addition & 4 deletions config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@
"database_dir": "C:\\MyExampleProject",
"model_cache_dir": "C:\\MyExampleProject\\models",
"results_dir": "results",
"thumbnails_dir": "thumbnails",
"umap_output_file": "umap_3d_visualization.html",
"umap_cache_file": "umap_projections_cache.pkl",
"umap_metadata_file": "umap_image_metadata.json"
"thumbnails_dir": "thumbnails"
}
3 changes: 0 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,4 @@ tqdm>=4.66.0
numpy>=1.24.0
sqlite-vec>=0.0.1
sentencepiece>=0.1.99
umap-learn>=0.5.5
plotly>=5.18.0
pandas>=2.0.0
PyMuPDF>=1.23.0
Loading