ShusenTang / Dive-into-DL-PyTorch

本项目将《动手学深度学习》(Dive into Deep Learning)原书中的MXNet实现改为PyTorch实现。
http://tangshusen.me/Dive-into-DL-PyTorch
Apache License 2.0
18.17k stars 5.38k forks source link

9.9 语义分割和数据集过滤宽高顺序问题 #109

Closed dwyzzy closed 4 years ago

dwyzzy commented 4 years ago

自定义语义分割数据集中过滤函数是否有误?

        return [img for img in imgs if (
            img.size[1] >= self.crop_size[0] and
            img.size[0] >= self.crop_size[1])]

请问一下此处0、1顺序是否颠倒?

dwyzzy commented 4 years ago

自定义语义分割数据集中过滤函数是否有误?

        return [img for img in imgs if (
            img.size[1] >= self.crop_size[0] and
            img.size[0] >= self.crop_size[1])]

请问一下此处0、1顺序是否颠倒?

原文相关代码如下:

    def filter(self, imgs):
        return [img for img in imgs if (
            img.shape[0] >= self.crop_size[0] and
            img.shape[1] >= self.crop_size[1])]
ShusenTang commented 4 years ago

注意这里使用的是Pytorch推荐的PIL读取image,所以img的size是(w, h)而不是(h, w),例:

from PIL import Image
img = Image.open('xxx.png')
img.size #  width, height
dwyzzy commented 4 years ago

注意这里使用的是Pytorch推荐的PIL读取image,所以img的size是(w, h)而不是(h, w),例:

from PIL import Image
img = Image.open('xxx.png')
img.size #  width, height

感谢