forked from triple-Mu/YOLOv8-TensorRT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.py
56 lines (49 loc) · 1.87 KB
/
build.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import argparse
from models import EngineBuilder
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('--weights',
type=str,
required=True,
help='Weights file')
parser.add_argument('--iou-thres',
type=float,
default=0.65,
help='IOU threshoud for NMS plugin')
parser.add_argument('--conf-thres',
type=float,
default=0.25,
help='CONF threshoud for NMS plugin')
parser.add_argument('--topk',
type=int,
default=100,
help='Max number of detection bboxes')
parser.add_argument('--input-shape',
nargs='+',
type=int,
default=[1, 3, 640, 640],
help='Model input shape only for api builder')
parser.add_argument('--fp16',
action='store_true',
help='Build model with fp16 mode')
parser.add_argument('--device',
type=str,
default='cuda:0',
help='TensorRT builder device')
parser.add_argument('--seg',
action='store_true',
help='Build seg model by onnx')
args = parser.parse_args()
assert len(args.input_shape) == 4
return args
def main(args):
builder = EngineBuilder(args.weights, args.device)
builder.seg = args.seg
builder.build(fp16=args.fp16,
input_shape=args.input_shape,
iou_thres=args.iou_thres,
conf_thres=args.conf_thres,
topk=args.topk)
if __name__ == '__main__':
args = parse_args()
main(args)