MCPcopy Create free account
hub / github.com/MultimediaTechLab/YOLO / _create_trt_model

Method _create_trt_model

yolo/utils/deploy_utils.py:97–106  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

95 return model_trt
96
97 def _create_trt_model(self):
98 from torch2trt import torch2trt
99
100 model = create_model(self.cfg.model, class_num=self.class_num, weight_path=self.cfg.weight).eval()
101 dummy_input = torch.ones((1, 3, *self.cfg.image_size)).cuda()
102 logger.info(f"♻️ Creating TensorRT model")
103 model_trt = torch2trt(model.cuda(), [dummy_input])
104 torch.save(model_trt.state_dict(), self.model_path)
105 logger.info(f":inbox_tray: TensorRT model saved to {self.model_path}")
106 return model_trt

Callers 1

_load_trt_modelMethod · 0.95

Calls 1

create_modelFunction · 0.90

Tested by

no test coverage detected