使用Yolov5离线检测图片并在Synology Photos上对图片添加标签,支持识别80种场景
通过Synology API获取图片缩略图,使用离线yolov5模型识别并对图片添加标签,支持图片和视频
- git clone repository
- install requirements.txt
pip3 install -r requirements.txt pip3 install -r yolov5/requirements.txt pip3 install torch torchvision
- run py
user="xxx" \ pwd="xxx" \ mode="xxx" \ exclude_class="[\"cat\"]" \ ip="192.168.5.1:5000" \ python3 main.py
Docker将比上面的 shell 命令运行更久,因为它会永远监控新照片,并且可以在开机时运行启动Docker
-
拉取镜像
//arm64 [600MB] docker pull charliecaptain/meowai-image:latest-arm-linux //x86-64 [2G] docker pull charliecaptain/meowai-image:latest
-
运行Docker容器
docker run -it --name meowai \ -e user="xxx" \ -e pwd="xxx" \ -e mode="person" \ -e exclude_class="[\"cat\",\"dog\"]" \ -e model='yolov5s6' \ --network host \ meowai_image
运行在Synology上会占用大量CPU,请谨慎使用
参数 | 说明 | 例子 | 必选 |
---|---|---|---|
user | 登录用户名 | - | true |
pwd | 登录密码 | - | true |
ip | Nas的地址:端口 | 0.0.0.0:5000 | false(default 127.0.0.1:5000) |
mode | 个人文件夹还是共享文件夹 | "person" or"share" | false(default person) |
exclude_class | 排除识别的场景(80种), 具体看src/detect/detect_dict.py | ['cat','dog'] | false(default []) |
model | 模型数据集 | yolov5m6 | false(default yolov5m6) |
lang | 标签语言 | zh(中文)/en(英文) | false(default en) |
Yolov5的预训练的模型都可以选择,程序会自动下载到环境中。
直接运行python文件则可以运行更大的模型,因为GPU参与运算,速度会比Docker容器快很多。
Docker中运行最好是yolov5s6,平均2秒左右识别速度。
目前使用的是yolov5m6.pt数据模型,可以更换更大的数据模型,更多详情请看Yolov5-Github.
- 安装Docker
- 克隆项目
- 修改代码
- 构建Docker镜像
chmod 777 ./build.sh ./build.sh
user="xxx" pwd="xxx" mode="xxx" exclude_class="[\"dog\"]" python3 src/util/util.py
https://github.com/zeichensatz/SynologyPhotosAPI
感谢您的支持
TRC20(USDT): TKRJkxUWYnnjLXVjN5Nutk6cvZ3Nz3S9pv
MIT License
Copyright (c) 2023 Charlie
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.