Skip to content

Commit ce78341

Browse files
committed
build: 添加 [all] 依赖组,支持仅安装客户端,并更新版本号至 0.3.1,调整内存限制以支持更高负载
1 parent 0607558 commit ce78341

5 files changed

Lines changed: 44 additions & 19 deletions

File tree

README.md

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,34 @@ ImgSearch is a lightweight image search engine that supports image-to-image and
1515

1616
## Installation
1717

18-
### Standard Installation
18+
### Full Installation (Client + Server)
1919

20-
ImgSearch relies on TinyCLIP models (built on OpenCLIP), which require PyTorch. The standard installation automatically pulls in the CUDA version of PyTorch. This is recommended for users with NVIDIA GPUs to speed up image inference.
20+
To use the full functionality of ImgSearch (including client and server), you need to specify the `all` dependency group during installation. This will install all the dependency packages required to run the server, such as `PyTorch`, on the system.
21+
22+
```shell
23+
pip install 'imgsearch[all]'
24+
```
25+
26+
### Standard Installation (Client Only)
27+
28+
The standard installation includes only the client-side dependencies:
2129

2230
```shell
2331
pip install imgsearch
2432
```
2533

26-
### CPU Environment
34+
**⚠️ Note**: Since the standard installation lacks PyTorch and other dependencies, you cannot run the `isearch service start` command.
35+
36+
### Non-CUDA environment
2737

28-
For non-CUDA environments, install the CPU version of PyTorch first, then install ImgSearch:
38+
For users in non-CUDA environments who want to run the server, it is recommended to install the CPU version of PyTorch first, and then install ImgSearch:
2939

3040
```shell
3141
# Install CPU version of PyTorch
3242
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
3343

3444
# Install ImgSearch
35-
pip install imgsearch
45+
pip install 'imgsearch[all]'
3646
```
3747

3848
If using uv as your Python package manager:
@@ -309,30 +319,40 @@ ImgSearch 是一款轻量级图片搜索引擎,支持以图搜图和文字描
309319

310320
## 安装
311321

312-
### 标准安装
322+
### 完整安装(客户端 + 服务端)
313323

314-
ImgSearch 使用的 TinyCLIP 模型(基于 OpenCLIP)依赖 PyTorch。标准安装时,pip 会自动安装 CUDA 版的 PyTorch。建议使用 NVIDIA 显卡的用户选择这种方式以加速图像推理过程。
324+
要使用 ImgSearch 的完整功能(包含客户端和服务端),需要在安装时指定 `all` 依赖组,这会将服务端运行所需的 `PyTorch` 等依赖包全部安装到系统上:
325+
326+
```shell
327+
pip install 'imgsearch[all]'
328+
```
329+
330+
### 标准安装(仅客户端)
331+
332+
标准安装仅包含客户端所需的依赖:
315333

316334
```shell
317335
pip install imgsearch
318336
```
319337

320-
### CPU 环境安装
338+
**⚠️ 注意**:由于标准安装缺少 Pytorch 等依赖项,所以无法执行 `isearch service start` 命令。
321339

322-
对于非 CUDA 环境的用户,建议先安装 CPU 版 PyTorch,然后再安装 imgsearch:
340+
### 非 CUDA 环境
341+
342+
对于非 CUDA 环境的用户如果要运行服务端时,建议先安装 CPU 版 PyTorch,然后再安装 ImgSearch:
323343

324344
```shell
325345
# 安装 CPU 版 PyTorch
326346
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
327347

328348
# 安装 ImgSearch
329-
pip install imgsearch
349+
pip install 'imgsearch[all]'
330350
```
331351

332352
使用 uv 作为 Python 包管理工具的可以这样安装:
333353

334354
```shell
335-
uv pip install --torch-backend cpu imgsearch
355+
uv pip install --torch-backend cpu 'imgsearch[all]'
336356
```
337357

338358
## 使用方法

pyproject.toml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,22 @@ dependencies = [
2525
"pillow>=11.3.0",
2626
"psutil>=7.1.0",
2727
"pyro5>=5.15",
28-
# NumPy with version constraints
29-
"numpy<2; sys_platform=='darwin' and platform_machine=='x86_64'",
30-
"numpy>=1.24.0; sys_platform!='darwin' or platform_machine!='x86_64'",
31-
# PyTorch dependencies with platform-specific versions
28+
]
29+
[project.optional-dependencies]
30+
all = [
31+
# PyTorch
3232
"torch==2.2.2; sys_platform=='darwin' and platform_machine=='x86_64'",
3333
"torch>=2.8.0; sys_platform!='darwin' or platform_machine!='x86_64'",
3434
"torchvision>=0.17.2", # dependi: disable-check
35+
# NumPy
36+
"numpy<2; sys_platform=='darwin' and platform_machine=='x86_64'",
37+
"numpy>=1.24.0; sys_platform!='darwin' or platform_machine!='x86_64'",
3538
# TinyCLIP dependencies
3639
"ftfy>=6.3.1",
3740
"regex>=2025.9.18",
3841
"tqdm>=4.67.1",
3942
"huggingface-hub>=0.35.0",
4043
]
41-
4244
[dependency-groups]
4345
dev = [
4446
"ipython>=9.5.0",

src/imgsearch/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.3.0'
1+
__version__ = '0.3.1'

src/imgsearch/server.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,9 @@ def run(self):
409409
self.logger.debug(f'Model : {self.model_key}')
410410

411411
self.daemon.requestLoop()
412+
except ImportError as e:
413+
self.logger.error(f'Missing optional dependencies: {e}')
414+
self.logger.error("Run `pip install 'imgsearch[all]'` for a full install.")
412415
except Exception as e:
413416
self.logger.error(f'Server failed to start: {e}')
414417
finally:

src/imgsearch/setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
RestartSec=30
2424
SyslogIdentifier=isearch
2525
OOMScoreAdjust=-500
26-
MemoryMax=1500M
27-
MemoryHigh=960M
26+
MemoryMax=2048M
27+
MemoryHigh=1280M
2828
ProtectSystem=strict
2929
3030
[Install]

0 commit comments

Comments
 (0)