I am following a tutorial to load data from a local file using Google Colaboratory.
Here is my code:
import numpy as np #To do relay operations
import matplotlib.pyplot as plt #to show image
import os #Iterate through directories and join paths
import cv2 #To do image operations
DATADIR = "C:\\Users\\Family\\Desktop\\Nottingham\\Year 4\\FYP\\Software\\Datasets\\PetImages"
CATEGORIES = ["Dog","Cat"]
for category in CATEGORIES:
path = os.path.join(DATADIR,category) #path to cats or dogs dir
print(category)
print(path)
for img in os.listdir(path):
print(img)
img_array = cv2.imread(os.path.join(path,img), cv2.IMREAD_GRAYSCALE)
plt.imshow(img_array, cmap = "gray")
plt.show()
break
break
However, I am getting the following error in Line 13:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\Family\Desktop\Nottingham\Year 4\FYP\Software\Datasets\PetImages/Dog'`
I have verified multiple times that this directory indeed exists, yet the same error continues to happen.
I tried changing the format of the directory in DATADIR, by trying these three methods:
DATADIR = "C:\\Users\\Family\\Desktop\\Nottingham\\Year 4\\FYP\\Software\\Datasets\\PetImages"
DATADIR = "C:/Users/Family/Desktop/Nottingham/Year 4/FYP/Software/Datasets/PetImages"
DATADIR = r"C:\Users\Family\Desktop\Nottingham\Year 4\FYP\Software\Datasets\PetImages"
However, none of these methods seemed to work. What else can I try?