为照片识别编写docker
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
ARG VERSION
|
||||
# 使用官方的paddle镜像作为基础
|
||||
FROM registry.baidubce.com/paddlepaddle/paddle:2.6.1-gpu-cuda12.0-cudnn8.9-trt8.6
|
||||
|
||||
@@ -5,7 +6,8 @@ FROM registry.baidubce.com/paddlepaddle/paddle:2.6.1-gpu-cuda12.0-cudnn8.9-trt8.
|
||||
WORKDIR /app
|
||||
|
||||
# 设置环境变量
|
||||
ENV PYTHONUNBUFFERED=1 \
|
||||
ENV VERSION=${VERSION} \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
# 设置pip镜像地址,加快安装速度
|
||||
PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
|
||||
|
||||
@@ -1,14 +1,101 @@
|
||||
version: '3.9'
|
||||
|
||||
services:
|
||||
photo_mask_1:
|
||||
container_name: photo_mask_1
|
||||
image: photo_mask
|
||||
photo_review_1:
|
||||
container_name: photo_review_1
|
||||
image: fcb_photo_review
|
||||
build:
|
||||
context: .
|
||||
args:
|
||||
VERSION: "0.0.1"
|
||||
volumes:
|
||||
- ./log:/app/log
|
||||
restart: always
|
||||
command: [ "photo_review.py", "--clean", "True" ]
|
||||
deploy:
|
||||
resources:
|
||||
reservations:
|
||||
devices:
|
||||
- device_ids: [ "0", "1" ]
|
||||
capabilities: [ "gpu" ]
|
||||
driver: "nvidia"
|
||||
|
||||
photo_review_2:
|
||||
container_name: photo_review_2
|
||||
image: fcb_photo_review
|
||||
volumes:
|
||||
- ./log:/app/log
|
||||
restart: always
|
||||
depends_on:
|
||||
- photo_review_1
|
||||
command: [ "photo_review.py" ]
|
||||
deploy:
|
||||
resources:
|
||||
reservations:
|
||||
devices:
|
||||
- device_ids: [ "0", "1" ]
|
||||
capabilities: [ "gpu" ]
|
||||
driver: "nvidia"
|
||||
|
||||
photo_review_3:
|
||||
container_name: photo_review_3
|
||||
image: fcb_photo_review
|
||||
volumes:
|
||||
- ./log:/app/log
|
||||
restart: always
|
||||
depends_on:
|
||||
- photo_review_2
|
||||
command: [ "photo_review.py" ]
|
||||
deploy:
|
||||
resources:
|
||||
reservations:
|
||||
devices:
|
||||
- device_ids: [ "0", "1" ]
|
||||
capabilities: [ "gpu" ]
|
||||
driver: "nvidia"
|
||||
|
||||
photo_review_4:
|
||||
container_name: photo_review_4
|
||||
image: fcb_photo_review
|
||||
volumes:
|
||||
- ./log:/app/log
|
||||
restart: always
|
||||
depends_on:
|
||||
- photo_review_3
|
||||
command: [ "photo_review.py" ]
|
||||
deploy:
|
||||
resources:
|
||||
reservations:
|
||||
devices:
|
||||
- device_ids: [ "0", "1" ]
|
||||
capabilities: [ "gpu" ]
|
||||
driver: "nvidia"
|
||||
|
||||
photo_review_5:
|
||||
container_name: photo_review_5
|
||||
image: fcb_photo_review
|
||||
volumes:
|
||||
- ./log:/app/log
|
||||
restart: always
|
||||
depends_on:
|
||||
- photo_review_4
|
||||
command: [ "photo_review.py" ]
|
||||
deploy:
|
||||
resources:
|
||||
reservations:
|
||||
devices:
|
||||
- device_ids: [ "0", "1" ]
|
||||
capabilities: [ "gpu" ]
|
||||
driver: "nvidia"
|
||||
|
||||
photo_mask_1:
|
||||
container_name: photo_mask_1
|
||||
image: fcb_photo_review
|
||||
volumes:
|
||||
- ./log:/app/log
|
||||
restart: always
|
||||
depends_on:
|
||||
- photo_review_1
|
||||
command: [ "photo_mask.py", "--clean", "True" ]
|
||||
deploy:
|
||||
resources:
|
||||
@@ -20,7 +107,7 @@ services:
|
||||
|
||||
photo_mask_2:
|
||||
container_name: photo_mask_2
|
||||
image: photo_mask
|
||||
image: fcb_photo_review
|
||||
volumes:
|
||||
- ./log:/app/log
|
||||
restart: always
|
||||
@@ -37,7 +124,7 @@ services:
|
||||
|
||||
photo_mask_3:
|
||||
container_name: photo_mask_3
|
||||
image: photo_mask
|
||||
image: fcb_photo_review
|
||||
volumes:
|
||||
- ./log:/app/log
|
||||
restart: always
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
import argparse
|
||||
import logging.config
|
||||
import traceback
|
||||
|
||||
from sqlalchemy import update
|
||||
|
||||
from auto_email.error_email import send_error_email
|
||||
from db import MysqlSession
|
||||
from db.mysql import ZxPhhd
|
||||
from log import LOGGING_CONFIG
|
||||
from photo_review import photo_review, SEND_ERROR_EMAIL, RETRY_TIME
|
||||
|
||||
@@ -10,8 +15,19 @@ if __name__ == '__main__':
|
||||
program_name = '照片审核自动识别脚本'
|
||||
logging.config.dictConfig(LOGGING_CONFIG)
|
||||
|
||||
# 崩溃后的重试次数
|
||||
for _ in range(RETRY_TIME + 1):
|
||||
for i in range(RETRY_TIME + 1):
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--clean", default=False, type=bool, help="是否将识别中的案子改为待识别状态")
|
||||
args = parser.parse_args()
|
||||
if args.clean or i > 0:
|
||||
# 主要用于启动时,清除仍在涂抹中的案子
|
||||
session = MysqlSession()
|
||||
update_flag = (update(ZxPhhd).where(ZxPhhd.exsuccess_flag == "2").values(exsuccess_flag="1"))
|
||||
session.execute(update_flag)
|
||||
session.commit()
|
||||
session.close()
|
||||
logging.info("已释放残余的识别案子!")
|
||||
|
||||
try:
|
||||
logging.info(f"【{program_name}】开始运行")
|
||||
photo_review.main()
|
||||
|
||||
Reference in New Issue
Block a user