Files
pest-image-search/README.md
zhenghu ec7c9f8dbe feat: 初始化病虫害以图搜图应用
- 基于 CLIP 模型实现图片相似度搜索(app.py / main.py)
  - 新增 Streamlit 可视化交互界面
  - 新增 pyproject.toml、justfile、Dockerfile 项目配置
  - 补充完整 README 文档(功能介绍、快速开始、Docker 部署)
  - 新增 .gitignore
2026-04-14 16:24:04 +08:00

81 lines
1.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# pest-image-search 病虫害以图搜图
基于 CLIP 视觉模型的病虫害图片相似度搜索应用。上传病虫害患处图片,系统自动提取视觉特征并检索知识库中最相似的病虫害类型,提供症状描述与防治建议。
## 功能特性
- 🖼️ 支持上传本地图片、输入图片 URL、选择示例图片三种查询方式
- 🧠 基于 `openai/clip-vit-base-patch32` 本地视觉模型提取图像特征
- 📊 相似度可视化条形图
- 🏷️ 覆盖水稻、小麦、玉米、大豆、番茄、黄瓜等常见作物的病虫害知识库
- 💡 智能推荐最可能的病虫害及防治方案
## 技术栈
- Python 3.14+
- Streamlit 1.52.1
- Plotly 6.5.0
- Transformers 4.51.3 + PyTorch 2.7.0 (CLIP 模型)
- Pillow、NumPy、Requests
## 快速开始
### 使用 uv推荐
```bash
# 安装依赖
uv sync
# 运行应用
uv run streamlit run app.py
```
### 使用 just
```bash
# 查看所有可用命令
just --list
# 运行应用
just run
# 代码格式化
just format
# 代码检查
just check
```
## Docker 部署
```bash
# 构建镜像
docker build -t pest-image-search .
# 运行容器
docker run -p 8000:8000 pest-image-search
```
## 项目结构
```
pest-image-search/
├── app.py # 主应用文件Streamlit
├── main.py # 入口文件
├── pyproject.toml # 项目配置
├── justfile # 任务自动化
├── Dockerfile # Docker 配置
└── README.md # 项目文档
```
## 使用说明
1. 首次启动时会自动下载 CLIP 模型(约 300MB请保持网络畅通
2. 加载完成后自动构建病虫害图片索引
3. 上传或选择查询图片后点击「开始搜索」,即可获得 Top-K 相似病虫害结果
4. 结果仅供参考,实际防治请结合田间情况或咨询农业专家
## 许可证
MIT License