Im trying to load an image to Jupyter notebook to use it in Tensorflow, Im using this Code below :
import numpy as np
from pathlib import Path    
import pandas as pd    
import matplotlib.pyplot as plt    
import sklearn.model_selection as train_test_split    
import tensorflow as tf    
from PIL import Image    
import os    
from keras.utils import to_categorical    
from keras.models import Sequential    
from keras.layers import Conv2D, MaxPool2D, Dense,Flatten, Dropout 
data= []    
labels = []    
classes = 43    
cur_path = os.getcwd()
for i in range(classes) :     
    path = os.path.join(cur_path,'Dataset\Train', str(i))    
    images = os.listdir(path)
for a in images :        
    try: 
        image = Image.open(path + '\\'  + a)    
        image.resize(30,30)    
        image.show()    
        image = np.array(image)    
        data.append(image)    
        labels.append(i)
    except:    
        print("error loading image")
data = np.array(data)    
labels = np.array(labels)
Unfortunately im having this error message :error loading image
Does anyone have any idea?
Update : Removed the try and except ,
for a in images :
 image = Image.open(path + '\\' + a) 
 image.resize(30,30) 
 display(image) 
 image = np.array(image) 
 data = np.array(data) 
 labels = np.array(labels)
error :
ValueError
Traceback (most recent call last)
 in 
2
3         image = Image.open(path + '\'  + a)
----> 4 image.resize(30,30)
  5         display(image)
  6         image = np.array(image)
~\anaconda3\lib\site-packages\PIL\Image.py in resize(self, size, resample, box, reducing_gap) 1883 ) 1884 ] -> 1885 raise ValueError(
1886 message + " Use " + ", ".join(filters[:-1]) + " or " + filters[-1]
1887 )
ValueError: Unknown resampling filter (30). Use Image.NEAREST (0),
Image.LANCZOS (1), Image.BILINEAR (2), Image.BICUBIC (3), Image.BOX (4) or
Image.HAMMING (5)
