Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional trt import #215

Merged
merged 2 commits into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion alonet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
from . import detr_panoptic
from . import deformable_detr_panoptic

from . import torch2trt

10 changes: 5 additions & 5 deletions alonet/torch2trt/calibrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ class DataBatchStreamer:
>>> s_dataStreamer = DataBatchStreamer(dataset=s_calib)
>>> m_dataStreamer = DataBatchStreamer(dataset=m_calib)
"""
FTYPES = ["torch.Tensor", "ndarray", "aloscene.Frame"]

def __init__(
self,
dataset=None,
Expand All @@ -76,7 +74,8 @@ def __init__(
):
for sample in dataset[0]:
if not isinstance(sample, (torch.Tensor, np.ndarray, Frame)):
raise TypeError(f"unknown sample type, expected samples to be instance of {' or '.join(self.FTYPES)} got {sample.__class__.__name__} instead")
ftypes = ["torch.Tensor", "ndarray", "aloscene.Frame"]
raise TypeError(f"unknown sample type, expected samples to be instance of {' or '.join(ftypes)} got {sample.__class__.__name__} instead")

self.batch_idx = 0
self.dataset = dataset
Expand Down Expand Up @@ -105,7 +104,8 @@ def convert_frame(frame):
elif isinstance(frame, np.ndarray):
pass
else:
raise TypeError(f"Unknown sample type, expected samples to be instance of {' or '.join(self.FTYPES)} got {frame.__class__.__name__}.")
ftypes = ["torch.Tensor", "ndarray", "aloscene.Frame"]
raise TypeError(f"Unknown sample type, expected samples to be instance of {' or '.join(ftypes)} got {frame.__class__.__name__}.")
return frame

def next_(self):
Expand All @@ -127,7 +127,7 @@ def next_(self):
return None

def __len__(self):
return max_batch
return self.max_batch


class BaseCalibrator:
Expand Down