(args)
| 125 | |
| 126 | |
| 127 | def main(args): |
| 128 | trt_infer = TensorRTInfer(args.engine) |
| 129 | batcher = ImageBatcher(args.input, *trt_infer.input_spec(), preprocessor=args.preprocessor) |
| 130 | for batch, images in batcher.get_batch(): |
| 131 | classes, scores, top = trt_infer.infer(batch) |
| 132 | for i in range(len(images)): |
| 133 | if args.top == 1: |
| 134 | print(images[i], classes[i], scores[i], sep=args.separator) |
| 135 | else: |
| 136 | line = [images[i]] |
| 137 | assert args.top <= top[0].shape[1] |
| 138 | for t in range(args.top): |
| 139 | line.append(str(top[0][i][t])) |
| 140 | for t in range(args.top): |
| 141 | line.append(str(top[1][i][t])) |
| 142 | print(args.separator.join(line)) |
| 143 | |
| 144 | |
| 145 | if __name__ == "__main__": |
no test coverage detected