Skip to content

Commit eed6974

Browse files
committed
fix: 修复文档及代码中的错误
1 parent 89af971 commit eed6974

3 files changed

Lines changed: 23 additions & 24 deletions

File tree

README.md

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,17 @@ If using uv as your Python package manager:
4141
uv pip install --torch-backend cpu imgsearch
4242
```
4343

44-
**Note**: ImgSearch's TinyCLIP models work on both CPU and GPU. GPU users can skip the CPU-specific steps and use the standard PyTorch installation for faster performance.
45-
4644
## Quick Start
4745

4846
### 1. Service Management
4947

5048
ImgSearch follows a client-server architecture: the server handles indexing and search tasks, while the client manages user requests. Before using ImgSearch, start the server process.
5149

52-
The server supports Unix domain sockets (default for local, efficient connections) or TCP binding. The default Unix socket is at `~/.isearch/isearch.sock`.
50+
The server supports unix domain sockets (default for local, efficient connections) or TCP binding. The default unix socket is at `~/.isearch/isearch.sock`.
5351

5452
#### Basic Usage
5553

56-
The default model is ViT-45LY (TinyCLIP-auto-ViT-45M-32-Text-18M-LAIONYFCC400M). See [Model Selection Guide](#model-selection-guide) for available options.
54+
The default model is ViT-45LY (`TinyCLIP-auto-ViT-45M-32-Text-18M-LAIONYFCC400M`). See [Model Selection Guide](#model-selection-guide) for available options.
5755

5856
##### i. Start Service
5957

@@ -90,7 +88,7 @@ ImgSearch service is running
9088

9189
#### Running as a System Service
9290

93-
ImgSearch can run as a background system service that starts and stops with your system. On Linux, it uses `systemd`; on macOS, `launchd`. The tool auto-detects your environmentno manual configuration needed.
91+
ImgSearch can run as a background system service that starts and stops with your system. On Linux, it uses `systemd`; on macOS, `launchd`. The tool auto-detects your environmentno manual configuration needed.
9492

9593
##### i. Set Up Service
9694

@@ -131,39 +129,37 @@ The `add` command extracts 512-dimensional feature vectors from images using Tin
131129

132130
The `search` subcommand handles image searches, but for ease of use, it's the default—omit it if your arguments don't match other commands.
133131

134-
Search syntax: `isearch [search] QUERY` (`[search]` optional).
132+
Search command: `isearch [search] QUERY`.
135133

136134
#### Search by Image
137135

138136
```shell
139137
# Search similar images, return top 10 results (similarity ≥0%)
140138
isearch ./query.jpg
141-
# Equivalent: isearch search ./query.jpg
139+
140+
# Equivalent:
141+
isearch search ./query.jpg
142142

143143
# Set minimum similarity threshold and result count
144-
isearch -n 5 -m 80 ./query.jpg
145-
# Equivalent: isearch search -n 5 -m 80 ./query.jpg
144+
isearch -n 5 -t 80 ./query.jpg
146145

147-
# Automatically open result images
146+
# Automatically open result images (the Label when adding an image must be a path)
148147
isearch -o ./query.jpg
149-
# Equivalent: isearch search -o ./query.jpg
150148
```
151149

152150
#### Search by Text
153151

154152
```shell
155153
# Search for "red flower" related images
156154
isearch "red flower"
157-
# Equivalent: isearch search "red flower"
158155

159156
# Specify count and threshold
160-
isearch -n 3 -m 70 "sunset beach"
161-
# Equivalent: isearch search -n 3 -m 70 "sunset beach"
157+
isearch -n 3 -t 70 "sports car"
162158
```
163159

164160
Results sorted by similarity descending, show path and percentage. Example:
165161
```
166-
Searching red flower...
162+
Searching sports car...
167163
Found 5 similar images (similarity ≥ 70.0%):
168164
1. /path/to/img1.jpg 92.3%
169165
2. /path/to/img2.png 85.1%
@@ -341,10 +337,10 @@ uv pip install --torch-backend cpu imgsearch
341337

342338
## 使用方法
343339

344-
ImgSearch 整体为 C-S 架构,服务端处理索引和搜索,客户端处理用户请求。使用前需先开启他的服务端程序。
345-
346340
### 1. 服务管理
347341

342+
ImgSearch 整体为 C-S 架构,服务端处理索引和搜索,客户端处理用户请求。使用前需先开启他的服务端程序。
343+
348344
ImgSearch 服务端支持 Unix 域套接字或 TCP 绑定。默认使用 Unix 域套接字运行在本地,稳定且高效。默认 UDS 位置为 `~/.isearch/isearch.sock`
349345

350346
#### 基本用法
@@ -425,7 +421,7 @@ isearch add -d my_gallery ./photos/ -B ./isearch.sock
425421

426422
搜索图片使用 `search` 子命令,为了操作方便,isearch 已将它设为默认子命令,使用时可以省略。
427423

428-
搜图语法`isearch [search] QUERY``[search]` 可选)
424+
搜图方式`isearch [search] QUERY`
429425

430426
#### 以图搜图
431427

@@ -437,9 +433,9 @@ isearch ./query.jpg
437433
isearch search ./query.jpg
438434

439435
# 设置最小相似度阈值和结果数量
440-
isearch -n 5 -m 80 ./query.jpg
436+
isearch -n 5 -t 80 ./query.jpg
441437

442-
# 自动打开结果图片
438+
# 自动打开结果图片(添加图片时的 Label 必须是 path)
443439
isearch -o ./query.jpg
444440
```
445441

@@ -450,7 +446,7 @@ isearch -o ./query.jpg
450446
isearch "red flower"
451447

452448
# 指定数量和阈值
453-
isearch -n 3 -m 70 "sports car"
449+
isearch -n 3 -t 70 "sports car"
454450
```
455451

456452
搜索结果按相似度降序排列,显示路径和相似度。示例:
@@ -585,3 +581,4 @@ ImgSearch 支持多种 TinyCLIP 模型,默认的 `ViT-45LY` 平衡了速度、
585581
# 重启 isearch 服务
586582
isearch service stop
587583
isearch service start -m NEW_MODEL_KEY
584+
```

src/imgsearch/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def create_parser() -> ArgumentParser:
258258
help=f'Search images {ut.bold("(default)")}',
259259
formatter_class=DefaultFmt,
260260
)
261-
cmd_search.add_argument('-m', dest='sim_thr', type=int, default=0, help='Similarity threshold, 0 - 100')
261+
cmd_search.add_argument('-t', dest='sim_thr', type=int, default=0, help='Similarity threshold, 0 - 100')
262262
cmd_search.add_argument('-n', dest='num', type=int, default=10, help='Number of search results')
263263
cmd_search.add_argument('-o', dest='open_res', action='store_true', help='Open the searched images')
264264
cmd_search.add_argument('target', nargs='?', help='Search target (image path or keyword)')

src/imgsearch/setup.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
Group={usergroup}
1818
WorkingDirectory={base_dir}
1919
Environment=PATH={py_bin}:/usr/local/bin:/usr/bin:/bin
20-
ExecStart={py_bin}/isearch service start -b {base_dir} -m {model_key} -B {bind} -l {log_level}
20+
ExecStart={py_bin}/isearch service start -b {base_dir} -m {model_key} -B {bind} -L {log_level}
2121
ExecStop=kill $MAINPID
2222
Restart=on-failure
2323
RestartSec=30
@@ -50,7 +50,7 @@
5050
<string>{model_key}</string>
5151
<string>-B</string>
5252
<string>{bind}</string>
53-
<string>-l</string>
53+
<string>-L</string>
5454
<string>{log_level}</string>
5555
</array>
5656
@@ -141,6 +141,8 @@ def setup_service(
141141
) -> bool:
142142
"""Install service on the current platform."""
143143
base_dir = Path(base_dir).resolve()
144+
if not base_dir.exists():
145+
base_dir.mkdir(parents=True, exist_ok=True)
144146
if not base_dir.is_dir():
145147
raise NotADirectoryError(f'Base directory {base_dir} does not exist.')
146148

0 commit comments

Comments
 (0)