You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
936 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# 导入相关依赖
import os
os.environ["KMP_DUPLICATE_LIB_OK"] = "TRUE"
import cv2
import numpy as np
from ultralytics import YOLO
import torch
import argparse
def exec_inference_video(file_path,line):
# 可以使用yolo原始权重也可以用直接使用onnx格式的权重加速推理
# 但请注意目标追踪是建立在目标检测的基础之上,它比单纯的目标检测更耗费算力,用cpu跑很慢,即使是用onnx加速,推理速度也无法比拟在gpu、npu上的速度
# 推荐电脑有gpu的话安装gpu的pytorch在gpu上跑,电脑没有gpu的的话用onnx格式跑
# 特别注意:电脑有gpu的话不要安装成了cpu版本的pytroch,否则根本没有用gpu跑用的还是cpu速度还是很慢
# 特别注意:直接 pip install torch 安装的是cpu版本的torch,即使电脑有显卡因为安装的是cpu版的torch所以还是用的cpu跑的,推理速度照样很慢