From b2aac528108d02e292351cbab75a1c2ca006d3c4 Mon Sep 17 00:00:00 2001 From: NaQi <76849182+IamNaQi@users.noreply.github.com> Date: Fri, 29 Apr 2022 09:26:35 +0500 Subject: [PATCH 1/2] Update y_tensorrt.py for windows inference This is an update about to tensorrt python inference on windows: import yolort before pytorch, this resolve issue in python inference on windows. --- yolort/runtime/y_tensorrt.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/yolort/runtime/y_tensorrt.py b/yolort/runtime/y_tensorrt.py index 5a542674..087657e7 100644 --- a/yolort/runtime/y_tensorrt.py +++ b/yolort/runtime/y_tensorrt.py @@ -3,17 +3,19 @@ import logging from collections import OrderedDict, namedtuple from typing import Any, Dict, List, Callable, Optional, Tuple +#import yolort before pytorch: this may cause issue in python inference on windows +import yolort.utils.dependency as _dependency +if _dependency.is_module_available("tensorrt"): + import tensorrt as trt import numpy as np import torch -import yolort.utils.dependency as _dependency + from torch import Tensor from torchvision.io import read_image from yolort.models.transform import YOLOTransform from yolort.utils import contains_any_tensor -if _dependency.is_module_available("tensorrt"): - import tensorrt as trt logging.basicConfig(level=logging.INFO) logging.getLogger("PredictorTRT").setLevel(logging.INFO) From 39e1d301146f9e798051058704a96c4f97b42e8e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 29 Apr 2022 04:28:53 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- yolort/runtime/y_tensorrt.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/yolort/runtime/y_tensorrt.py b/yolort/runtime/y_tensorrt.py index 087657e7..0bb973e7 100644 --- a/yolort/runtime/y_tensorrt.py +++ b/yolort/runtime/y_tensorrt.py @@ -3,14 +3,15 @@ import logging from collections import OrderedDict, namedtuple from typing import Any, Dict, List, Callable, Optional, Tuple -#import yolort before pytorch: this may cause issue in python inference on windows + +# import yolort before pytorch: this may cause issue in python inference on windows import yolort.utils.dependency as _dependency + if _dependency.is_module_available("tensorrt"): import tensorrt as trt import numpy as np import torch - from torch import Tensor from torchvision.io import read_image from yolort.models.transform import YOLOTransform