Skip to content

Commit

Permalink
fix: import Dict for py-3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
charlie-captain committed May 14, 2023
1 parent 20386d4 commit 8a98373
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,5 @@ done_list.json
make_docker.sh
.idea
.DS_Store
test.py

18 changes: 17 additions & 1 deletion README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,15 @@ Docker将比上面的 shell 命令运行更久,因为它会永远监控新照
2. 运行Docker容器

```shell
docker run -it --name meowai -e user="xxx" -e pwd="xxx" --network host meowai_image
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 DSM
Expand Down Expand Up @@ -78,6 +86,14 @@ Docker将比上面的 shell 命令运行更久,因为它会永远监控新照
| model | 模型数据集 | yolov5m6 | false(default yolov5m6) |
| lang | 标签语言 | zh(中文)/en(英文) | false(default en) |

#### 模型选择

Yolov5的预训练的模型都可以选择,程序会自动下载到环境中。

直接运行python文件则可以运行更大的模型,因为GPU参与运算,速度会比Docker容器快很多。

Docker中运行最好是yolov5s6,平均2秒左右识别速度。

## 开发

目前使用的是yolov5m6.pt数据模型,可以更换更大的数据模型,更多详情请看[Yolov5-Github](https://github.com/ultralytics/yolov5).
Expand Down
23 changes: 16 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ Docker will run longer than the shell command above because it will forever moni

```shell
docker run -it
--name meowai
-e user="xxx"
-e pwd="xxx"
-e mode="person"
-e exclude_class="[\"cat\",\"dog\"]"
--network host
--name meowai \
-e user="xxx" \
-e pwd="xxx" \
-e mode="person" \
-e exclude_class="[\"cat\",\"dog\"]" \
-e model='yolov5m6' \
--network host \
meowai_image
```

Expand All @@ -78,7 +79,7 @@ This will consume your CPU resources.
### Arguments

| 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) |
Expand All @@ -87,6 +88,14 @@ This will consume your CPU resources.
| model | yolov5 model pt file name | yolov5m6 | false(default yolov5m6) |
| lang | tag language | zh/en | false(default en) |

### Model

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.

## Dev

Currently using the yolov5m6.pt dataset, which can be changed to a larger dataset, more can be viewed on the
Expand Down
1 change: 0 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
git pull
chmod 777 ./build.sh
docker build --no-cache -t meowai_image .
5 changes: 3 additions & 2 deletions src/api/api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import gettext
import json
import os
from typing import Dict

import requests

Expand Down Expand Up @@ -267,15 +268,15 @@ def count_total_photos():
return 0


def get_error_code(response: dict[str, object]) -> int:
def get_error_code(response: Dict[str, object]) -> int:
if response.get('success'):
code = error_codes.CODE_SUCCESS
else:
code = response.get('error').get('code')
return code


def get_error_message(response: dict[str, object]) -> str:
def get_error_message(response: Dict[str, object]) -> str:
code = get_error_code(response)
if code in error_codes.error_codes.keys():
message = error_codes.error_codes[code]
Expand Down
13 changes: 7 additions & 6 deletions src/api/error_codes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# source: pages 8 and 16 on PDF:
# https://global.download.synology.com/download/Document/Software/DeveloperGuide/Os/DSM/All/enu/DSM_Login_Web_API_Guide_enu.pdf
from typing import Dict

# NOTE: https://global.synologydownload.com/download/Document/Software/DeveloperGuide/Package/Calendar/2.4/enu
# /Synology_Calendar_API_Guide_enu.pdf, Refers to common error code # 160, "Insufficient application privilege" Page 10.
Expand Down Expand Up @@ -69,7 +70,7 @@
# https://global.download.synology.com/download/Document/Software/DeveloperGuide/Package/SurveillanceStation/All/enu
# /Surveillance_Station_Web_API.pdf Pages 32,33 Refers to Auth error code #411: 'Account Locked (when account max try
# exceed).'
auth_error_codes: dict[int, str] = {
auth_error_codes: Dict[int, str] = {
400: 'No such account or incorrect password',
401: 'Disabled account',
402: 'Denied permission',
Expand All @@ -85,7 +86,7 @@

# Source:https://global.download.synology.com/download/Document/Software/DeveloperGuide/Package/DownloadStation/All/enu/Synology_Download_Station_Web_API.pdf
# Page 29
download_station_error_codes: dict[int, str] = {
download_station_error_codes: Dict[int, str] = {
400: 'File upload failed',
401: 'Max number of tasks reached',
402: 'Destination denied',
Expand All @@ -99,7 +100,7 @@

# TODO use the error code source https://cndl.synology.cn/download/Document/Software/DeveloperGuide/Package
# /FileStation/All/enu/Synology_File_Station_API_Guide.pdf page 10~11
file_station_error_codes: dict[int, str] = {
file_station_error_codes: Dict[int, str] = {
400: 'Invalid parameter of file operation',
401: 'Unknown error of file operation',
402: 'System is too busy',
Expand Down Expand Up @@ -127,7 +128,7 @@

# Source: https://global.synologydownload.com/download/Document/Software/DeveloperGuide/Package/Virtualization/All
# /enu/Synology_Virtual_Machine_Manager_API_Guide.pdf Page 8,9
virtualization_error_codes: dict[int, str] = {
virtualization_error_codes: Dict[int, str] = {
401: 'Bad parameter.',
402: 'Operation failed.',
403: 'Name conflict.',
Expand Down Expand Up @@ -159,7 +160,7 @@

# Source: https://global.synologydownload.com/download/Document/Software/DeveloperGuide/Package/Calendar/2.4/enu
# /Synology_Calendar_API_Guide_enu.pdf Pages 10,11.
calendar_error_codes: dict[int, str] = {
calendar_error_codes: Dict[int, str] = {
400: 'Invalid parameter of file operation',
401: 'Unknown error of file operation',
402: 'System is too busy',
Expand Down Expand Up @@ -191,7 +192,7 @@
# different methods, all the error codes I found are on # Pages: 71, 81, 85, 93, 103, 113, 131, 132, 139, 144, 155,
# 167, 169, 176, 187, 190, 191, 201, 211, 212, 217, 222, 227, # 241, 245, 249, 253, 264, 279, 281, 305, 314,
# 321, 328, 363, 365, 368, 369, 393, 395, 397, 403, 410, 412, 415, # 419, 430, 451, 473, 539, 556
surveillance_station_error_codes: dict[int, str] = {
surveillance_station_error_codes: Dict[int, str] = {
400: 'Execution failed.',
401: 'Parameter invalid.',
402: 'Camera disabled.',
Expand Down
Binary file removed yolov5m6.pt
Binary file not shown.

0 comments on commit 8a98373

Please sign in to comment.