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

problem about SSD model in ecosystem running with Google Colab #77

Closed
I-M-Russell opened this issue Jan 13, 2020 · 3 comments
Closed

problem about SSD model in ecosystem running with Google Colab #77

I-M-Russell opened this issue Jan 13, 2020 · 3 comments

Comments

@I-M-Russell
Copy link

I-M-Russell commented Jan 13, 2020

when running this part in SSD|PyTorch
inputs = [utils.prepare_input(uri) for uri in uris] tensor = utils.prepare_tensor(inputs, precision == 'fp16')
on Google Colab, it gives these error:
`---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
in ()
----> 1 inputs = [utils.prepare_input(uri) for uri in uris]
2 tensor = utils.prepare_tensor(inputs, precision == 'fp16')

2 frames
/root/.cache/torch/hub/NVIDIA_DeepLearningExamples_torchhub/hubconf.py in load_image(image_path)
235 def load_image(image_path):
236 """Code from Loading_Pretrained_Models.ipynb - a Caffe2 tutorial"""
--> 237 img = skimage.img_as_float(skimage.io.imread(image_path))
238 if len(img.shape) == 2:
239 img = np.array([img, img, img]).swapaxes(0, 2)

AttributeError: module 'skimage' has no attribute 'io'`
How do I solve it?

@bilalsal
Copy link

bilalsal commented Mar 11, 2020

The following fix to nvidia_ssd_processing_utils in NVIDIA_DeepLearningExamples_torchhub/hubconf.py worked for me in Python 3 (see PR NVIDIA/DeepLearningExamples#418)

def nvidia_ssd_processing_utils():
import numpy as np
import skimage
from skimage import io, transform
from PyTorch.Detection.SSD.src.utils import dboxes300_coco, Encoder

class Processing:
    @staticmethod
    def load_image(image_path):
        """Code from Loading_Pretrained_Models.ipynb - a Caffe2 tutorial"""
        img = skimage.img_as_float(io.imread(image_path))
        if len(img.shape) == 2:
            img = np.array([img, img, img]).swapaxes(0, 2)
        return img

    @staticmethod
    def rescale(img, input_height, input_width):
        """Code from Loading_Pretrained_Models.ipynb - a Caffe2 tutorial"""
        aspect = img.shape[1] / float(img.shape[0])
        if (aspect > 1):
            # landscape orientation - wide image
            res = int(aspect * input_height)
            imgScaled = transform.resize(img, (input_width, res))
        if (aspect < 1):
            # portrait orientation - tall image
            res = int(input_width / aspect)
            imgScaled = transform.resize(img, (res, input_height))
        if (aspect == 1):
            imgScaled = transform.resize(img, (input_width, input_height))
        return imgScaled

bilalsal added a commit to bilalsal/DeepLearningExamples that referenced this issue Mar 11, 2020
The PyTorch SSD implemented by NVIDIA relies on the nvidia_ssd_processing_utils() routines in this module
(see https://pytorch.org/hub/nvidia_deeplearningexamples_ssd/).
Python 3 has issues accessing skimage's io and transform in the original code (issue reported in issue pytorch/hub#77).
@skierat
Copy link

skierat commented Mar 13, 2020

@I-M-Russell does the fix work you? Can we close the issue

@ailzhang
Copy link
Contributor

Closing as I confirmed this works in Colab now. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants