1234567891011121314151617181920212223242526272829303132333435363738 |
- import sys
- import onnx
- import os
- import argparse
- import numpy as np
- import cv2
- import onnxruntime
- import multiprocessing
- from tool.utils import *
- from tool.darknet2onnx import *
- cfg_file = 'C:\\Users\\VINNO\\Desktop\\新建文件夹 (2)\\pytorch-YOLOv4-master\\yolov4-tiny-breast-anchors--3l---20210901.cfg'
- weight_file = 'C:\\Users\\VINNO\\Desktop\\新建文件夹 (2)\\pytorch-YOLOv4-master\\yolov4-tiny-breast-anchors--3l---20210901_last.weights'
- batch_size = 0
- if batch_size <= 0:
- onnx_path_demo = transform_to_onnx(cfg_file, weight_file, batch_size)
- else:
- # Transform to onnx as specified batch size
- transform_to_onnx(cfg_file, weight_file, batch_size)
- # Transform to onnx as demo
- onnx_path_demo = transform_to_onnx(cfg_file, weight_file, 1)
- session = onnxruntime.InferenceSession(onnx_path_demo)
- cpuCount = os.cpu_count()
- print("Number of CPUs in the system:", cpuCount)
- # file_name = 'C:\\Users\\VINNO\\Desktop\\新建文件夹 (2)\\新建文本文档.txt'
- # dest_name = 'C:\\Users\\VINNO\\Desktop\\新建文件夹 (2)\\1.txt'
- # # 以二进制打开和保存数据
- # with open(dest_name, "a", encoding="utf-8") as data:
- # with open(file_name, "a", encoding="utf-8") as s:
- # data.writelines(s.readlines())
|