Semantic Segmentation and the Dataset

https://d2l.ai/chapter_computer-vision/semantic-segmentation-and-dataset.html

Hi, thanks for this great resource. When I tried the notebook, I saw this error:

in read_voc_images(voc_dir, is_train)
4 txt_fname = os.path.join(voc_dir, ‘ImageSets’, ‘Segmentation’,
5 ‘train.txt’ if is_train else ‘val.txt’)
----> 6 mode = torchvision.io.image.ImageReadMode.RGB
7 with open(txt_fname, ‘r’) as f:
8 images = f.read().split()

AttributeError: module ‘torchvision.io.image’ has no attribute ‘ImageReadMode’

Can you please let me know if this is due to a different version of pytorch being used? If so, can you please specify which pytorch version or more specifically torchvision version is used here?

Thanks!

Hi @Chao_Wang,
You’ll need torch==1.8.0 and torchvision==0.9.0 to run this section.

!


hi i didn’t understand this code, why * 256?

If the RGB value in an image is (255,255,255),so 255**3 < (255 * 256 + 255) * 256 + 255 < 256 **3.