Skip to content

Commit b0a6c1b

Browse files
author
Jiaaming
committed
fix: import bugs
1 parent f4c4756 commit b0a6c1b

File tree

5 files changed

+53
-8
lines changed

5 files changed

+53
-8
lines changed

.gitattributes

-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
*.pt filter=lfs diff=lfs merge=lfs -text
2-
snap_sort/models/* filter=lfs diff=lfs merge=lfs -text

MANIFEST.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
include snap_sort/models/*
1+
include snap_sort/models/yolov8s.pt
22
include snap_sort/utils/*
33
recursive-include snap_sort/models *

README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@
55

66
# SnapSort
77

8-
### Note: SnapSort is currently in development and may not be fully functional.
9-
108
**SnapSort** is a light weighted (relatively) command-line tool that helps you classify and organize your photos based on focus accuracy, exposure (overexposed/underexposed), and content (landscape/portrait). SnapSort leverages OpenCV for image processing and allows you to quickly sort your photos into categorized folders for easy management.
119

1210
## Features
1311
- **Semantic search**: Search for images based on your prompt.
14-
- **Exposure Classification**: Identify overexposed and underexposed images.
1512
- **Find similar images**: Find similar images based on a reference image.
13+
- **Exposure Classification**: Identify overexposed and underexposed images.
1614

1715
## Installation
1816

examples.md

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# SnapsSort CLI Usage Examples
2+
3+
## Semantic Search
4+
5+
Find images based on a text description:
6+
7+
```bash
8+
# Search for images containing animals
9+
snapsort search animals
10+
# Search for images containing cars and people
11+
snapsort search "car and people"
12+
# Search for landscape images (limit to top 5 results)
13+
snapsort search landscape -n 5
14+
```
15+
16+
## Similar Image Discovery
17+
18+
Find images similar to a reference image:
19+
20+
```bash
21+
# Find images similar to a specific image
22+
snapsort similar /path/to/reference/image.jpg
23+
```
24+
25+
## Exposure Classification
26+
27+
Sort images by exposure levels:
28+
29+
```bash
30+
# Retrieve images with different exposure characteristics
31+
snapsort tone low # Underexposed images
32+
snapsort tone mid # Balanced exposure images
33+
snapsort tone high # Overexposed images
34+
```
35+
36+
## Redo last command
37+
```bash
38+
# Revert the folder structure to the state before the last command
39+
snapsort redo
40+
```
41+
## Key Features
42+
43+
- **Semantic Search**: Discover images using natural language descriptions
44+
- **Similar Image Finder**: Locate visually similar images
45+
- **Exposure Sorting**: Classify images by their light and tone characteristics
46+
47+
**Note**: Ensure you're in the target directory before running these commands.

snap_sort/semantic.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import numpy as np
1111
import json
1212
logging.getLogger().setLevel(logging.WARNING)
13-
import sys
1413
import contextlib
1514

1615
with open(os.devnull, 'w') as f, contextlib.redirect_stdout(f):
@@ -158,7 +157,10 @@ def search_similar_images(embeddings_list, image_paths, prompt, dimension, top_n
158157
if not embeddings_list:
159158
logging.warning("No embeddings found to build Faiss index.")
160159
return []
161-
import faiss
160+
try:
161+
import faiss
162+
except ImportError:
163+
logging.error("Please install the faiss library: pip install faiss-cpu on CPU or faiss-gpu on GPU.")
162164
# Build the Faiss index
163165
faiss_index = faiss.IndexFlatL2(dimension)
164166
embeddings_matrix = np.array(embeddings_list).astype('float32')

0 commit comments

Comments
 (0)