# Get input and output binding indices
input_binding_idx = self.engine.get_binding_index('images')
output_binding_num_idx = self.engine.get_binding_index('num')
output_binding_boxes_idx = self.engine.get_binding_index('boxes')
output_binding_scores_idx = self.engine.get_binding_index('scores')
output_binding_classes_idx = self.engine.get_binding_index('classes')
# Get input and output shapes
input_shape = self.engine.get_binding_shape(input_binding_idx)
output_shape_num = self.engine.get_binding_shape(output_binding_num_idx)
output_shape_boxes = self.engine.get_binding_shape(output_binding_boxes_idx)
output_shape_scores = self.engine.get_binding_shape(output_binding_scores_idx)
output_shape_classes = self.engine.get_binding_shape(output_binding_classes_idx)
# If buff is of type torch.Tensor, convert to a numpy array
if isinstance(buff, torch.Tensor):
buff = buff.cpu().numpy()
# Allocate input and output memory
d_input = cuda.mem_alloc(buff.nbytes)
d_output_num = cuda.mem_alloc(trt.volume(output_shape_num) * buff.dtype.itemsize)
d_output_boxes = cuda.mem_alloc(trt.volume(output_shape_boxes) * buff.dtype.itemsize)
d_output_scores = cuda.mem_alloc(trt.volume(output_shape_scores) * buff.dtype.itemsize)
d_output_classes = cuda.mem_alloc(trt.volume(output_shape_classes) * buff.dtype.itemsize)
bindings = [int(d_input), int(d_output_num), int(d_output_boxes), int(d_output_scores), int(d_output_classes)]
# If buff is of type torch.Tensor, convert to a numpy array
if isinstance(buff, torch.Tensor):
buff = buff.cpu().numpy()
# Check buff type and size
print(f"buff type: {type(buff)}")
print(f"buff shape: {buff.shape}")
# Copy input data to GPU
cuda.memcpy_htod(d_input, buff)
# Copy input data to GPU
# cuda.memcpy_htod(d_input, buff.numpy())
# Secure output data
output_num = np.empty(output_shape_num, dtype=trt.nptype(self.engine.get_binding_dtype(output_binding_num_idx)))
output_boxes = np.empty(output_shape_boxes, dtype=trt.nptype(self.engine.get_binding_dtype(output_binding_boxes_idx)))
output_scores = np.empty(output_shape_scores, dtype=trt.nptype(self.engine.get_binding_dtype(output_binding_scores_idx)))
output_classes = np.empty(output_shape_classes, dtype=trt.nptype(self.engine.get_binding_dtype(output_binding_classes_idx)))
# Secure output data
self.context.execute_v2(bindings)
# Copy output data from GPU to host
cuda.memcpy_dtoh(output_num, d_output_num)
cuda.memcpy_dtoh(output_boxes, d_output_boxes)
cuda.memcpy_dtoh(output_scores, d_output_scores)
cuda.memcpy_dtoh(output_classes, d_output_classes)
# Post-processing of inference results
outputs = postprocess(
output_num,
output_boxes,
output_scores,
output_classes,
self.exp.num_classes,
self.exp.test_conf,
self.exp.nmsthre,
class_agnostic=True
)
When executing the postprocess function in the “Post-processing inference results” section of this program, I get the exception “postprocess() got multiple values for argument ‘class_agnostic’”.
I have tried everything, but cannot solve the problem.
outputs = postprocess(
output_num, output_boxes, output_boxes
output_boxes, output_scores, output_boxes
output_scores, output_boxes, output_classes, output_scores
output_classes, self.exp.num_classes, self.
self.exp.num_classes, self.exp.test_conf,
self.exp.test_conf, self.exp.test_conf,
self.exp.nmsthre, self.exp.test_conf, self.exp.nmsthre
True
)
and ,
outputs = postprocess(
output_boxes=output_boxes, output_boxes
output_scores=output_scores, output_classes=output_classes, output_classes
output_classes=output_classes, output_classes
num_classes=self.exp.num_classes,
conf_thre=self.exp.test_conf,
nms_thre=self.exp.nmsthre,
class_agnostic=True
)
I have tried the following, but the error persists.
I would appreciate it if you could answer my question.
Thank you in advance.