查询训练报告接口
This commit is contained in:
@ -11,6 +11,7 @@ from app.config.config_reader import detect_url
|
||||
from app.util import os_utils as os
|
||||
from app.util import random_utils as ru
|
||||
from app.config.config_reader import yolo_url
|
||||
from app.websocket.web_socket_server import room_manager
|
||||
|
||||
|
||||
def add_detect(detect_in: ProjectDetectIn, session: Session):
|
||||
@ -133,14 +134,12 @@ def run_commend(weights: str, source: str, project: str, name: str,
|
||||
:return:
|
||||
"""
|
||||
yolo_path = os.file_path(yolo_url, 'detect.py')
|
||||
yield f"stdout: 模型推理开始,请稍等。。。 \n"
|
||||
room = 'detect_' + str(detect_id)
|
||||
await room_manager.send_to_room(room, f"stdout: 模型训练开始,请稍等。。。\n")
|
||||
commend = ["python", '-u', yolo_path, "--weights", weights, "--source", source, "--name", name, "--project", project, "--save-txt"]
|
||||
# 启动子进程
|
||||
with subprocess.Popen(
|
||||
["python", '-u', yolo_path,
|
||||
"--weights", weights,
|
||||
"--source", source,
|
||||
"--name", name,
|
||||
"--project", project],
|
||||
commend,
|
||||
bufsize=1, # bufsize=0时,为不缓存;bufsize=1时,按行缓存;bufsize为其他正整数时,为按照近似该正整数的字节数缓存
|
||||
shell=False,
|
||||
stdout=subprocess.PIPE,
|
||||
@ -152,13 +151,14 @@ def run_commend(weights: str, source: str, project: str, name: str,
|
||||
line = process.stdout.readline()
|
||||
process.stdout.flush() # 刷新缓存,防止缓存过多造成卡死
|
||||
if line != '\n':
|
||||
yield line
|
||||
await room_manager.send_to_room(room, line + '\n')
|
||||
|
||||
# 等待进程结束并获取返回码
|
||||
return_code = process.wait()
|
||||
if return_code != 0:
|
||||
pdc.update_detect_status(detect_id, -1, session)
|
||||
else:
|
||||
await room_manager.send_to_room(room, 'success')
|
||||
pdc.update_detect_status(detect_id, 2, session)
|
||||
detect_imgs = pdc.get_img_list(detect_id, session)
|
||||
detect_log_imgs = []
|
||||
|
Reference in New Issue
Block a user