Use Yolov5 to perform offline detection on images and add tags to the images in Synology Photos, supporting the recognition of 80 scenes.
Extract thumbnail images using Synology API and add labels to images using offline yolov5 model.
- 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 will run longer than the shell command above because it will forever monitor for new photos.
-
pull docker image
//arm64 [600MB] docker pull charliecaptain/meowai-image:latest-arm-linux //x86-64 [2G] docker pull charliecaptain/meowai-image:latest
-
run docker container
docker run -it --name meowai \ -e user="xxx" \ -e pwd="xxx" \ -e mode="person" \ -e exclude_class="[\"cat\",\"dog\"]" \ -e model='yolov5m6' \ --network host \ meowai_image
This will consume your CPU resources.
Argument | Description | Demo | Require |
---|---|---|---|
user | login user | - | true |
pwd | login password | - | true |
ip | nas ip | 0.0.0.0:5000 | false(default 127.0.0.1:5000) |
mode | person dir or share dir | "person" or"share" | false(default person) |
exclude_class | exclude detect scenes, see src/detect/detect_dict.py | ['cat','dog'] | false(default []) |
model | yolov5 model pt file name | yolov5m6 | false(default yolov5m6) |
lang | tag language | zh/en | false(default en) |
Pretrained models for YOLOv5 can be selected and will be automatically downloaded to the environment.
Running the Python file directly allows for the use of larger models with the participation of the GPU, resulting in significantly faster processing speeds compared to running within a Docker container.
Docker is best suited for running yolov5s6, which has an average recognition speed of about 2 seconds.
Currently using the yolov5m6.pt dataset, which can be changed to a larger dataset, more can be viewed on the website Yolov5-Github.
- install docker
- git clone project
- build docker image
chmod 777 ./build.sh ./build.sh
- run docker
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.