From 54041911da8e72e1f0f5e2599aa5bf74a6b70889 Mon Sep 17 00:00:00 2001 From: "junjie.jiang" Date: Thu, 11 Aug 2022 13:55:39 +0800 Subject: [PATCH] update Signed-off-by: junjie.jiang --- image_decoder.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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