Skip to content

Commit bfd07e7

Browse files
committed
refactor(项目): 优化相关文档
- 更新 README.md 中的项目描述、安装指南等内容 - 移除开发安装部分,简化文档结构 - 调整代码中的日志配置方式 - 更新单元测试,增加对新功能的测试用例 - 修改 pyproject.toml,更新项目依赖
1 parent f0972d6 commit bfd07e7

6 files changed

Lines changed: 343 additions & 116 deletions

File tree

README.md

Lines changed: 23 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# iSearch 图片搜索引擎
1+
# ImgSearch 图片搜索引擎
22

3-
[🇨🇳 中文](#isearch-图片搜索引擎)[🇬🇧 English](#isearch)
3+
[🇨🇳 中文](#imgsearch-图片搜索引擎)[🇬🇧 English](#imgsearch)
44

5-
iSearch 是一款轻量级图片搜索引擎,支持以图搜图和文字描述搜图。基于 TinyCLIP(OpenCLIP 兼容)和 HNSWlib 构建,速度快、资源占用低,可在 2GB 内存设备上运行。可作为独立搜索引擎使用,或作为 Python 库集成到其他系统。
5+
ImgSearch 是一款轻量级图片搜索引擎,支持以图搜图和文字描述搜图。基于 TinyCLIP(OpenCLIP 兼容)和 HNSWlib 构建,速度快、资源占用低,可在 2GB 内存设备上运行。可作为独立搜索引擎使用,或作为 Python 库集成到其他系统。
66

77
## 特性
88

@@ -29,29 +29,17 @@ pip install imgsearch
2929
# macOS Intel/Apple Silicon 或 Linux CPU
3030
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
3131

32-
# 然后安装 iSearch
32+
# 然后安装 ImgSearch
3333
pip install imgsearch
3434
```
3535

36-
**注意**:iSearch 使用 TinyCLIP 模型(基于 OpenCLIP),兼容 CPU/GPU。GPU 用户可直接安装标准 PyTorch(`pip install torch torchvision`)以加速推理。
37-
38-
### 开发安装(可选)
39-
40-
若需贡献代码或运行测试:
41-
42-
```shell
43-
git clone https://github.com/your-repo/isearch.git # 替换为实际仓库
44-
cd isearch
45-
pip install -e .[dev]
46-
```
47-
48-
依赖包括:PyTorch, OpenCLIP (TinyCLIP), HNSWlib, Pyro5, Pillow, psutil 等。完整列表见 [pyproject.toml](pyproject.toml)
36+
**注意**:ImgSearch 使用 TinyCLIP 模型(基于 OpenCLIP),兼容 CPU/GPU。GPU 用户可直接安装标准 PyTorch(`pip install torch torchvision`)以加速推理。
4937

5038
## 快速开始
5139

5240
### 1. 服务管理
5341

54-
iSearch 使用后台服务处理索引和搜索。服务支持 Unix 域套接字(默认,本地高效)或 TCP 绑定。
42+
ImgSearch 使用后台服务处理索引和搜索。服务支持 Unix 域套接字(默认,本地高效)或 TCP 绑定。
5543

5644
#### 启动服务
5745

@@ -102,11 +90,13 @@ isearch add -l name ./images/
10290
isearch add -d my_gallery ./photos/ -B ./isearch.sock
10391
```
10492

105-
添加后,图片会被转换为 384x384 WebP 并提取 TinyCLIP 特征(512 维向量),存储在 HNSW 索引中。批量处理(默认 100 张/批),支持数万张图片
93+
添加后,图片会被转换为 384x384 并提取 TinyCLIP 特征(512 维向量),存储在 HNSW 索引中。
10694

10795
### 3. 搜索图片
10896

109-
搜索使用 `search` 子命令,但它是默认行为:若未指定子命令且参数不匹配其他命令,则自动视为搜索。语法:`isearch [search] QUERY``[search]` 可选)。
97+
搜索图片使用 `search` 子命令,为了操作方便,isearch 已将它设为默认子命令,使用时可以省略。
98+
99+
搜图语法:`isearch [search] QUERY``[search]` 可选)。
110100

111101
#### 以图搜图
112102

@@ -208,7 +198,7 @@ Similarity between images: 87.5%
208198

209199
## 作为 Python 模块使用
210200

211-
iSearch 可导入为库,直接操作服务或独立使用(但推荐服务模式以支持并发)。
201+
ImgSearch 可导入为库,直接操作服务或独立使用(但推荐服务模式以支持并发)。
212202

213203
```python
214204
from imgsearch.client import Client
@@ -254,7 +244,7 @@ print(f'清空成功: {cleared}')
254244

255245
## 模型选择指南
256246

257-
iSearch 支持多种 TinyCLIP 模型变体,平衡速度、准确率和资源。默认 `ViT-45LY` 适用于大多数场景。
247+
ImgSearch 支持多种 TinyCLIP 模型变体,平衡速度、准确率和资源。默认 `ViT-45LY` 适用于大多数场景。
258248

259249
| 模型键 | ImageNet-1K Acc@1 (%) | MACs (G) | Throughput (pairs/s) | 推荐场景 |
260250
|----------|-----------------------|----------|----------------------|-----------------------------|
@@ -319,7 +309,6 @@ pytest src/test/
319309
- pyro5 >=5.15
320310
- Pillow >=11.3.0
321311
- psutil >=7.0.0
322-
- transformers >=4.56.1
323312
- bidict >=0.23.1
324313
- msgpack >=1.1.1
325314
- numpy (平台特定)
@@ -330,11 +319,11 @@ MIT License
330319

331320
---
332321

333-
# iSearch
322+
# ImgSearch
334323

335-
[🇬🇧 English](#isearch)[🇨🇳 中文](#isearch-图片搜索引擎)
324+
[🇬🇧 English](#imgsearch)[🇨🇳 中文](#imgsearch-图片搜索引擎)
336325

337-
iSearch is a lightweight image search engine supporting image-to-image and text-to-image search. Built on TinyCLIP (OpenCLIP-compatible) and HNSWlib, it's fast and resource-efficient, running on 2GB RAM devices. Use standalone or integrate as a Python library.
326+
ImgSearch is a lightweight image search engine supporting image-to-image and text-to-image search. Built on TinyCLIP (OpenCLIP-compatible) and HNSWlib, it's fast and resource-efficient, running on 2GB RAM devices. Use standalone or integrate as a Python library.
338327

339328
## Features
340329

@@ -361,29 +350,17 @@ For CPU-only setups (e.g., no NVIDIA GPU on macOS/server):
361350
# Install CPU PyTorch first
362351
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
363352

364-
# Then install iSearch
353+
# Then install ImgSearch
365354
pip install imgsearch
366355
```
367356

368-
**Note**: iSearch uses TinyCLIP models (OpenCLIP-based), compatible with CPU/GPU. GPU users: Install standard PyTorch (`pip install torch torchvision`) for acceleration.
369-
370-
### Development Installation (Optional)
371-
372-
For contributions or testing:
373-
374-
```shell
375-
git clone https://github.com/your-repo/isearch.git # Replace with actual repo
376-
cd isearch
377-
pip install -e .[dev]
378-
```
379-
380-
Dependencies: PyTorch, OpenCLIP (TinyCLIP), HNSWlib, Pyro5, Pillow, psutil, etc. Full list in [pyproject.toml](pyproject.toml).
357+
**Note**: ImgSearch uses TinyCLIP models (OpenCLIP-based), compatible with CPU/GPU. GPU users: Install standard PyTorch (`pip install torch torchvision`) for acceleration.
381358

382359
## Quick Start
383360

384361
### 1. Service Management
385362

386-
iSearch runs as a background service for indexing/search. Supports Unix domain sockets (default, local-efficient) or TCP binding.
363+
ImgSearch runs as a background service for indexing/search. Supports Unix domain sockets (default, local-efficient) or TCP binding.
387364

388365
#### Start Service
389366

@@ -434,11 +411,13 @@ isearch add -l name ./images/
434411
isearch add -d my_gallery ./photos/ -B ./isearch.sock
435412
```
436413

437-
Images converted to 384x384 WebP, extract TinyCLIP features (512-dim vectors), stored in HNSW index. Batch processing (default 100/batch), handles tens of thousands.
414+
Images converted to 384x384, extract TinyCLIP features (512-dim vectors), stored in HNSW index.
438415

439416
### 3. Search Images
440417

441-
Search uses `search` subcommand, but it's the default: if no subcommand specified and args don't match others, auto-treated as search. Syntax: `isearch [search] QUERY` (`[search]` optional).
418+
Search images uses the `search` subcommand, but for operational convenience, iSearch has set it as the default subcommand, which can be omitted during use. If no subcommand is specified and the arguments don't match other commands, it will be automatically treated as a search.
419+
420+
Search images syntax: `isearch [search] QUERY` (`[search]` optional).
442421

443422
#### Image-to-Image Search
444423

@@ -586,7 +565,7 @@ print(f'Cleared: {cleared}')
586565

587566
## Model Selection Guide
588567

589-
iSearch supports various TinyCLIP model variants, balancing speed, accuracy, resources. Default `ViT-45LY` for most cases.
568+
ImgSearch supports various TinyCLIP model variants, balancing speed, accuracy, resources. Default `ViT-45LY` for most cases.
590569

591570
| Model Key | ImageNet-1K Acc@1 (%) | MACs (G) | Throughput (pairs/s) | Recommended For |
592571
|-----------|-----------------------|----------|----------------------|-------------------------------------|
@@ -651,7 +630,6 @@ Follow style, use modern Python (>=3.11). See [CONTRIBUTING.md] if available.
651630
- pyro5 >=5.15
652631
- Pillow >=11.3.0
653632
- psutil >=7.0.0
654-
- transformers >=4.56.1
655633
- bidict >=0.23.1
656634
- msgpack >=1.1.1
657635
- numpy (platform-specific)

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ dependencies = [
2727
"pillow>=11.3.0",
2828
"psutil>=7.0.0",
2929
"pyro5>=5.15",
30-
"transformers>=4.56.1",
3130
# NumPy with version constraints
3231
"numpy<2; sys_platform=='darwin' and platform_machine=='x86_64'",
3332
"numpy>=1.24.0; sys_platform!='darwin' or platform_machine!='x86_64'",

src/imgsearch/clip.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
preprocessing. Features are normalized to unit length for cosine similarity.
77
"""
88

9-
import logging
109
from concurrent.futures import ThreadPoolExecutor
1110

1211
import numpy as np
@@ -17,11 +16,6 @@
1716
from imgsearch.consts import DEFAULT_MODEL_KEY, MODELS
1817
from imgsearch.utils import Feature, cpu_count
1918

20-
# Suppress verbose transformers logging
21-
for name, logger in logging.Logger.manager.loggerDict.items():
22-
if name.startswith('transformers.') and isinstance(logger, logging.Logger):
23-
logger.setLevel(logging.ERROR)
24-
2519

2620
class Clip:
2721
"""Wrapper for OpenCLIP models supporting image/text embedding and similarity.

src/imgsearch/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ def get_logger(name: str, level: int = logging.INFO, log_dir=BASE_DIR):
179179
def open_images(paths: Sequence[str | Path]):
180180
"""Open images with system default image viewer"""
181181
system = platform.system()
182+
paths = [str(path) for path in paths if is_image(Path(path))]
182183
try:
183184
if system == 'Windows':
184185
subprocess.run(['explorer', *paths])

0 commit comments

Comments
 (0)