(self)
| 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 |
no test coverage detected