赞
踩
本脚本主要参考了yolov5工程文件夹下面的detect.py,将yolov5算法封装成了一个在线的http推理服务,可以接受app请求,然后推理图片,并将检测结果以json返回。
-
- from flask import *
- import shutil
- import json
- import os
- import pynvml
- import pandas as pd
- import glob
- import time
- import cv2
- import base64
- import subprocess
- import socket
-
-
- #下面的是yolov5需要import的库。直接从detect.py复制过来的。
- import argparse
- import os
- import sys
- from pathlib import Path
-
- import cv2
- import torch
- import torch.backends.cudnn as cudnn
-
- FILE = Path(__file__).resolve()
- ROOT = FILE.parents[0] # YOLOv5 root directory
- if str(ROOT) not in sys.path:
- sys.path.append(str(ROOT)) # add ROOT to PATH
- ROOT = Path(os.path.relpath(ROOT, Path.cwd())) # relative
-
- from models.common import DetectMultiBackend
- from utils.datasets import IMG_FORMATS, VID_FORMATS, LoadImages, LoadStreams
- from utils.general import (LOGGER, check_file, check_img_size, check_imshow, check_requirements, colorstr,
- increment
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。