Getting the following error while using scikit-image to read images "AttributeError: 'PngImageFile' object has no attribute '_PngImageFile__frame' "
I am using scikit-image to load a random image from a folder. OpenCV is being used for operations later on..

Code is as follows (only relevant parts included)

import imageio
import cv2 as cv
import fileinput
from collections import Counter

from data.apple_dataset import AppleDataset
from torchvision.models.detection.faster_rcnn import FastRCNNPredictor
from torchvision.models.detection.mask_rcnn import MaskRCNNPredictor
from torchvision.transforms import functional as F

import utility.utils as utils
import utility.transforms as T

from PIL import Image
import skimage.io
from skimage.viewer import ImageViewer
from matplotlib import pyplot as plt
%matplotlib inline

 APPLE_IMAGE_PATH = r"__mypath__\samples\apples\images"

# Load a random image from the images folder
FILE_NAMES = next(os.walk(APPLE_IMAGE_PATH))[2]
random_apple_in_folder = os.path.join(APPLE_IMAGE_PATH, random.choice(FILE_NAMES))
apple_image = skimage.io.imread(random_apple_in_folder)
apple_image_cv = cv.imread(random_apple_in_folder)
apple_image_cv = cv.cvtColor(apple_image_cv, cv.COLOR_BGR2RGB)


Error is as follows

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
&lt;ipython-input-3-9575eed18f18&gt; in &lt;module&gt;
     11 FILE_NAMES = next(os.walk(APPLE_IMAGE_PATH))[2]
     12 random_apple_in_folder = os.path.join(APPLE_IMAGE_PATH, random.choice(FILE_NAMES))
---&gt; 13 apple_image = skimage.io.imread(random_apple_in_folder)
     14 apple_image_cv = cv.imread(random_apple_in_folder)

    AttributeError: 'PngImageFile' object has no attribute '_PngImageFile__frame'


How do i proceed from here? What should i change???

This is a bug in Pillow 7.1.0. You can upgrade Pillow with pip install -U pillow. See this bug report for more information:

https://github.com/scikit-image/scikit-image/issues/4548
