diff --git a/image_decoder.py b/image_decoder.py index 1f48070..5527ee0 100644 --- a/image_decoder.py +++ b/image_decoder.py @@ -40,11 +40,17 @@ class ImageDecoder(PyOperator): def __init__(self): self._nvjpeg = create_pynvjpeg() - def to_device(self, device): - if self._nvjpeg is not None: - if not self._nvjpeg.bind_device(device): + def to_device(self): + if self._nvjpeg is not None and self.device >= 0: + if not self._nvjpeg.bind_device(self.device): self._nvjpeg = None + @property + def device(self): + if hasattr(self, '_device'): + return self._device + return -1 + def _download_image(self, image_url): image_type = image_url.split('?')[0].split('.')[-1].lower() is_jpeg = True if image_type == 'jpeg' or image_type == 'jpg' else False