← 返回 Skills 市场
tobemsk

本地图片语义搜索

作者 tobemsk · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
42
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install tobemsk-image-search
功能描述
本地图片语义搜索工具,基于 CLIP 模型实现中英文图片内容的语义理解检索,类似小米相册 AI 搜索功能。使用场景:(1) 用户想用自然语言搜索本地图片 (2) 用户需要搜索中文关键词相关的图片 (3) 用户提到"搜图片"、"找图片"、"图片搜索"、"AI相册"等关键词
使用说明 (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

安全使用建议
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.
功能分析
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.
能力评估
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.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install tobemsk-image-search
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /tobemsk-image-search 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
- 首次发布:本地图片语义搜索工具,可通过中英文自然语言搜索本地图片 - 基于 CLIP 模型,支持自然语言与中文关键词的图片检索 - 一键全盘扫描、特征建库,支持增量更新,快速同步新增图片 - 检索结果保存到桌面,便于查看图片路径和相似度 - 简单配置,多系统兼容,支持低配电脑与GPU加速
元数据
Slug tobemsk-image-search
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

本地图片语义搜索 是什么?

本地图片语义搜索工具,基于 CLIP 模型实现中英文图片内容的语义理解检索,类似小米相册 AI 搜索功能。使用场景:(1) 用户想用自然语言搜索本地图片 (2) 用户需要搜索中文关键词相关的图片 (3) 用户提到"搜图片"、"找图片"、"图片搜索"、"AI相册"等关键词. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 42 次。

如何安装 本地图片语义搜索?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install tobemsk-image-search」即可一键安装,无需额外配置。

本地图片语义搜索 是免费的吗?

是的,本地图片语义搜索 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

本地图片语义搜索 支持哪些平台?

本地图片语义搜索 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 本地图片语义搜索?

由 tobemsk(@tobemsk)开发并维护,当前版本 v1.0.0。

💬 留言讨论