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 in data transformations #12

Open
rabiaali95 opened this issue Oct 14, 2019 · 1 comment
Open

Problem in data transformations #12

rabiaali95 opened this issue Oct 14, 2019 · 1 comment

Comments

@rabiaali95
Copy link

In dataloader.py when preparing rotated images
rotated_imgs = [

                self.transform(img0),
                self.transform(rotate_img(img0,  90)),
                self.transform(rotate_img(img0, 180)),
                self.transform(rotate_img(img0, 270))
            ]

the following error arises.
ValueError: some of the strides of a given numpy array are negative. This is currently not supported, but will be added in future releases.

How to solve this error?

@rxqy
Copy link

rxqy commented Oct 23, 2019

Hi, a simple solution would be to add a .copy() to all of the output of rotate_img

From

def rotate_img(img, rot):
if rot == 0: # 0 degrees rotation
return img
elif rot == 90: # 90 degrees rotation
return np.flipud(np.transpose(img, (1,0,2)))
elif rot == 180: # 90 degrees rotation
return np.fliplr(np.flipud(img))
elif rot == 270: # 270 degrees rotation / or -90
return np.transpose(np.flipud(img), (1,0,2))
else:
raise ValueError('rotation should be 0, 90, 180, or 270 degrees')

To
return np.flipud(...),copy()
return np.fliplr(...).copy()
return np.transpose(...).copy()

For more details of this problem, you can check this thread from the pytorch form

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

2 participants