部分小问题的修改

This commit is contained in:
2025-05-20 17:03:14 +08:00
parent 6dd18ae1e0
commit 86c6669593
7 changed files with 32 additions and 17 deletions

View File

@ -114,7 +114,7 @@ async def run_detect_img(
while process.poll() is None:
line = process.stdout.readline()
process.stdout.flush() # 刷新缓存,防止缓存过多造成卡死
if line != '\n':
if line != '\n' and 'yolo' not in line:
await room_manager.send_to_room(room, line + '\n')
# 等待进程结束并获取返回码
return_code = process.wait()
@ -178,7 +178,14 @@ async def run_detect_rtsp(weights_pt: str, rtsp_url: str, data: str, detect_id:
time.sleep(3) # 等待3s等待websocket进入
start_time = time.time()
for path, im, im0s, vid_cap, s in dataset:
# 检查是否已经超过10分钟600秒
elapsed_time = time.time() - start_time
if elapsed_time > 600: # 600 seconds = 10 minutes
print(room, "已达到最大执行时间,结束推理。")
break
if room_manager.rooms.get(room):
im = torch.from_numpy(im).to(model.device)
im = im.half() if model.fp16 else im.float() # uint8 to fp16/32