Skip to content

Latest commit

 

History

History
73 lines (47 loc) · 3.49 KB

README_zh.md

File metadata and controls

73 lines (47 loc) · 3.49 KB

PicQuery

中文|English

cover_en

🔍 使用自然语言搜索本地图片,完全离线运行。例如:"书桌上的笔记本电脑"、"海边日落"、"草丛中的小猫"等。
支持通过相册选图进行相似图片搜索

  • 完全免费,无内购
  • 支持中英文双语搜索
  • 图片索引和搜索全程离线运行,隐私无忧
  • 8000+照片搜索1秒内出结果
  • 首次启动等待索引构建,后续搜索立等可取

安装

🍎 iOS用户请参考灵感来源应用 Queryable代码),由@mazzzystar 开发。

实现原理

感谢 @mazzzystar@Young-Flash 在开发过程中给予的帮助,讨论记录可查看此处

PicQuery 的核心技术基于OpenAI的CLIP模型和Apple的mobile clip

首先通过图像编码器将待搜索的图片编码为向量并建立索引存储。当用户输入搜索文本时,使用文本编码器将文本同样编码为向量。通过计算文本向量与已索引图片向量的相似度,选取相似度最高的K张图片作为搜索结果。

使用 CLIP 模型构建

要构建本项目,您需要获取量化后的CLIP模型。

请按步骤运行此jupyter notebook,当运行至_"You are done"_章节时,您应该在./result目录下获得以下模型文件:

  • clip-image-int8.ort
  • clip-text-int8.ort

若不想运行脚本,可直接从Google Drive下载

使用 mobile-clip 模型构建

要构建本项目,您需要获取量化后的模型文件:

  • vision_model.ort
  • text_model.ort

可从Google Drive下载

将文件放入app\src\main\assets目录即可使用。

选择模型模块

val AppModules = listOf(viewModelModules, dataModules, modulesCLIP, domainModules)中选择需要的模块,Clip对应modulesCLIP模块,mobile-clip对应modulesMobileCLIP模块

FAQ

Issue 1

java.lang.RuntimeException: java.lang.reflect.InvocationTarget Exception

Don't forget to add model files to app\src\main\assets directory

Issue 2

java.io.FileNotFoundException: clip-image-int8.ort

Make sure the model files are in the correct directory, if you are using mobile-clip, make sure you are using the correct model files, and change the module to modulesMobileCLIP

致谢

许可证

本项目基于MIT协议开源。保留所有权利。