← Back to Skills Marketplace
tobemsk

本地图片语义搜索

by tobemsk · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
42
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install tobemsk-image-search
Description
本地图片语义搜索工具,基于 CLIP 模型实现中英文图片内容的语义理解检索,类似小米相册 AI 搜索功能。使用场景:(1) 用户想用自然语言搜索本地图片 (2) 用户需要搜索中文关键词相关的图片 (3) 用户提到"搜图片"、"找图片"、"图片搜索"、"AI相册"等关键词
README (SKILL.md)

本地图片语义搜索工具

基于 CLIP 模型的全盘中英文图片语义搜索工具,支持中文关键词检索。

项目结构

image-search/
├── SKILL.md              # 本说明文件
├── requirements.txt      # Python 依赖
└── scripts/
    ├── scan.py           # 首次全量建库(约2小时)
    ├── update.py         # 增量更新(只处理新增图片)
    ├── search.py         # 搜索图片
    └── config.py         # 配置文件

快速开始

第一步:安装依赖

pip install -r requirements.txt

注意:首次运行会自动下载 CLIP 模型(约 400MB),请确保网络畅通。模型会缓存到 ~/.cache/huggingface/

第二步:首次建库(只需一次)

python scripts/scan.py
  • 扫描 C:\ D:\ E:\ F:\ 四个盘符的所有图片
  • 提取图片特征并建立向量索引
  • 耗时约 2 小时(取决于图片数量)
  • 完成后索引保存在 image_db/ 目录

第三步:搜索图片

python scripts/search.py 关键词

支持中英文关键词,例如:

python scripts/search.py 塔
python scripts/search.py 猫
python scripts/search.py sunset
python scripts/search.py 建筑 红色

搜索结果保存到桌面 搜索结果_关键词.txt,包含图片路径和相似度分数。

增量更新(后续使用)

每次新增图片后,运行增量更新:

python scripts/update.py
  • 自动扫描四个盘符
  • 找出新增图片(不在索引中的)
  • 只对新图片提取特征,几分钟完成
  • 追加到现有索引

工作原理

  1. 特征提取:使用 OFA-Sys/chinese-clip-vit-base-patch16 模型将图片转换为 512 维向量
  2. 向量存储:使用 FAISS 向量数据库存储和检索
  3. 语义搜索:将搜索词转换为向量,在向量空间中找最相似的图片

配置修改

编辑 scripts/config.py

SCAN_ROOTS = ["C:\\", "D:\\", "E:\\", "F:\\"]  # 扫描的根目录
EXCLUDE_DIRS = ["$RECYCLE.BIN", "System Volume Information", ".cache"]  # 排除的目录
IMAGE_EXTENSIONS = {".jpg", ".jpeg", ".png", ".gif", ".bmp", ".webp"}  # 支持的图片格式
MODEL_NAME = "OFA-Sys/chinese-clip-vit-base-patch16"  # CLIP 模型
BATCH_SIZE = 16  # 批处理大小,内存不足可调小

硬件要求

  • CPU: i5-4590(已验证可用)
  • 内存: 建议 8GB 以上
  • 显卡: 可用 GPU 加速(如 GTX 750 Ti),不用也能跑
  • 硬盘: 需要约 1GB 空间存储索引

常见问题

Q: 内存不足怎么办? A: 减小 config.py 中的 BATCH_SIZE(如改为 4 或 8)

Q: 模型下载失败? A: 国内网络可能需要设置镜像源:

set HF_ENDPOINT=https://hf-mirror.com

Q: 如何完全重建索引? A: 删除 image_db/ 目录,然后重新运行 scan.py

Usage Guidance
Review this before installing if your computer contains private photos. Limit the scan to chosen folders, protect or delete the image_db and Desktop result files, and install dependencies/model files only from sources you trust.
Capability Analysis
Type: OpenClaw Skill Name: tobemsk-image-search Version: 1.0.0 The skill performs a high-risk recursive scan of all available drive letters (A-Z) to index images for semantic search. While this behavior is aligned with its stated purpose, the broad file system access and the automatic configuration of a third-party model mirror (hf-mirror.com) in 'scripts/config.py' and 'scripts/scan.py' represent significant privacy and security risks. Additionally, 'scripts/search.py' automatically writes search result logs to the user's Desktop directory.
Capability Assessment
Purpose & Capability
The CLIP/FAISS code is coherent with semantic image search, but the capability necessarily reads and indexes many local photos, which are sensitive personal data.
Instruction Scope
The main commands are user-directed, but the onboarding flow encourages running a full scan before search rather than first limiting the folder scope.
Install Mechanism
There is no install spec, while the docs instruct pip installation and the code downloads a HuggingFace model through a configured mirror; this is expected for the ML purpose but should be reviewed.
Credentials
The default scan scope is very broad for a user-invocable skill: it scans multiple/all local drives for images and metadata does not declare a narrow capability boundary.
Persistence & Privilege
The skill stores a persistent image index and image-path list under image_db and writes search-result files to the Desktop, without clear retention or cleanup controls beyond manual deletion.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install tobemsk-image-search
  3. After installation, invoke the skill by name or use /tobemsk-image-search
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
- 首次发布:本地图片语义搜索工具,可通过中英文自然语言搜索本地图片 - 基于 CLIP 模型,支持自然语言与中文关键词的图片检索 - 一键全盘扫描、特征建库,支持增量更新,快速同步新增图片 - 检索结果保存到桌面,便于查看图片路径和相似度 - 简单配置,多系统兼容,支持低配电脑与GPU加速
Metadata
Slug tobemsk-image-search
Version 1.0.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is 本地图片语义搜索?

本地图片语义搜索工具,基于 CLIP 模型实现中英文图片内容的语义理解检索,类似小米相册 AI 搜索功能。使用场景:(1) 用户想用自然语言搜索本地图片 (2) 用户需要搜索中文关键词相关的图片 (3) 用户提到"搜图片"、"找图片"、"图片搜索"、"AI相册"等关键词. It is an AI Agent Skill for Claude Code / OpenClaw, with 42 downloads so far.

How do I install 本地图片语义搜索?

Run "/install tobemsk-image-search" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is 本地图片语义搜索 free?

Yes, 本地图片语义搜索 is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does 本地图片语义搜索 support?

本地图片语义搜索 is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created 本地图片语义搜索?

It is built and maintained by tobemsk (@tobemsk); the current version is v1.0.0.

💬 Comments