| 589 | return torch.from_numpy(x).to(self.device) if isinstance(x, np.ndarray) else x |
| 590 | |
| 591 | def warmup(self, imgsz=(1, 3, 640, 640)): |
| 592 | # Warmup model by running inference once |
| 593 | warmup_types = self.pt, self.jit, self.onnx, self.engine, self.saved_model, self.pb, self.triton |
| 594 | if any(warmup_types) and (self.device.type != 'cpu' or self.triton): |
| 595 | im = torch.empty(*imgsz, dtype=torch.half if self.fp16 else torch.float, device=self.device) # input |
| 596 | for _ in range(2 if self.jit else 1): # |
| 597 | self.forward(im) # warmup |
| 598 | |
| 599 | @staticmethod |
| 600 | def _model_type(p='path/to/model.pt'): |