0

Im a beginner with python,i was trying to classify images into two classes using svm. For image classification I have created a small dataset in'home/my_works/datasets/images/' and im using this code

from keras.layers import Dense, Dropout, Flatten
from keras.layers import Conv2D, MaxPooling2D
from keras.utils import to_categorical
from keras.preprocessing import image
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from tqdm import tqdm
#matplotlib inline

train = pd.read_csv('train1.csv')    # reading the csv file
train.head()      # printing first five rows of the file
train.columns

train_image = []
for i in tqdm(range(train.shape[0])):
img = image.load_img('Home/my_works/datasets/images/'+train['label'][i]+'.jpg',target_size=(3264,2448,3))
img = image.img_to_array(img)
img = img/255
train_image.append(img)
X = np.array(train_image)
X.shape
plt.imshow(X[2])
train['type'][2]

but im getting the error as 'FileNotFoundError: [Errno 2] No such file or directory: 'Home/my_works/datasets/images/edge(1).jpg.jpg' Please help me

1 Answers1

1

Maybe you just forgot the / at the beginning of the path?

img = image.load_img('/Home/my_works/datasets/images/'+train['label'][i]+'.jpg',target_size=(3264,2448,3))
jpl
  • 367
  • 2
  • 11