0

I am trying to load images using opencv in wiki dataset in which the images are organized into 99 folders. I have this code.

def load_images(self,dataframe):
        if dataframe is None:
            return None
        else:
            assert type(dataframe) == pd.core.frame.DataFrame, "argument to load image should be dataframe"
            assert  "file_location" in dataframe.columns, "dataframe should contain file_location column"
            output_images = np.zeros((len(dataframe),self.config.image_shape[0],self.config.image_shape[1],self.config.image_shape[2]))
            for index,row in dataframe.iterrows():
                img = cv2.imread(os.path.join(self.config.dataset_dir,row["file_location"][0]))

                if img is None:
                    Log.WARNING("Unable to read images from "+os.path.join(self.config.dataset_dir,row["file_location"][0]))
                    continue
                face_location = row["face_location"][0].astype(int)
                face_image = img[face_location[1]:face_location[3],face_location[0]:face_location[2]]
                face_image = cv2.cvtColor(face_image,cv2.COLOR_BGR2GRAY)
                face_image = cv2.resize(face_image,(self.config.image_shape[0],self.config.image_shape[1]))
                output_images[index] = face_image.reshape(self.config.image_shape)
            return output_images

I wanted to remove errors like this when I run the code

libpng warning: iCCP: profile 'icc': 'RGB ': RGB color space not permitted on grayscale PNG
Jeru Luke
  • 20,118
  • 13
  • 80
  • 87
Samuel Mideksa
  • 423
  • 8
  • 19

0 Answers0