model_path = "./model.engine"
import tensorrt as trt
verbose = True
IN_NAME = 'input' #输入节点名字
OUT_NAME = 'output' #输出节点名字
IN_H = 512
IN_W = 512
BATCH_SIZE = 1
EXPLICIT_BATCH = 1 << (int)(
trt.NetworkDefinitionCreationFlag.EXPLICIT_BATCH)
import tensorrt as trt #必须安装
import pycuda.driver as cuda #必须安装
import pycuda.autoinit
import numpy as np
import time
import cv2
import os
from tensorflow import keras
import threading
# 加载TRT引擎
class OxfordPets1(keras.utils.Sequence):
# 在__init__方法中指定batch_size,img_size,input_img_paths,target_img_paths
def __init__(self, batch_size, img_size, input_img_paths):
self.batch_size = batch_size # 批量大小
self.img_size = img_size # 图像大小
self.input_img_paths = input_img_paths # 输入图像路径
#self.target_img_paths = target_img_paths # 标注图像路径
#self.on_epoch_end()
def __len__(self):
Tensorrt python版本的推理实例
最新推荐文章于 2025-04-11 21:09:36 发布