# Facing resize error

**URL:** <https://discuss.pytorch.org/t/facing-resize-error/16291>\
**Category:** vision\
**Created:** [April 12, 2018, 1:42am UTC](https://discuss.pytorch.org/t/facing-resize-error/16291 "2018-04-12T01:42:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kartikey\_Upadhyay](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/kartikey_upadhyay/32/4306_2.png) [@Kartikey\_Upadhyay](https://discuss.pytorch.org/u/Kartikey_Upadhyay)\
**Post date:** [April 12, 2018, 1:42am UTC](https://discuss.pytorch.org/t/facing-resize-error/16291/1 "2018-04-12T01:42:21Z")

</div>

while going through theses steps:

trainloader = torch.utils.data.DataLoader(custom\_data\_loader(img\_root = img\_root, image\_list = train\_list\_file, crop=False,  
resize = True, resize\_shape=[128,128], classes = ‘IIC’),  
batch\_size=8, num\_workers=8, shuffle = True, pin\_memory=True)  
**for batch\_idx, (inputs, targets) in enumerate(trainloader):**

I face this error:

```
image = cv2.resize(image, (self.resize_shape[1], self.resize_shape[0])) ### resize_shape is in [rows, cols]

```

cv2.error: /opencv-3.4.0/modules/imgproc/src/resize.cpp:4044: error: (-215) ssize.width \> 0 && ssize.height \> 0 in function resize

How to make sure image is not None in trainloader?

---

<div class="post-metadata">

**Author:** ![ptrblck](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/32/1823_2.png) [@ptrblck](https://discuss.pytorch.org/u/ptrblck)\
**Post date:** [April 12, 2018, 5:48am UTC](https://discuss.pytorch.org/t/facing-resize-error/16291/2 "2018-04-12T05:48:57Z")

</div>

You could check if the `image` is `None` before the `resize` call.  
If that’s the case you could randomly pick a new `index` and load another image. That will make things unclear, e.g. when `shuffle=False`, but for the moment your `DataLoader` does not crash.  
Try to find the image using its `index` and fix it or delete it.
