DEV Community

Cover image for Images Dataset is not Loading!!!
JesterRexx-ux
JesterRexx-ux

Posted on

1

Images Dataset is not Loading!!!

You can see the given code in the image and the error its giving. I am using ubuntu 18.04 and everytime I try to load the dataset from the image folder it shows an error. Guys if you know how to handle this plz help me. This simple problem is wasting my lot of time!!!

Code:
import numpy as np
import matplotlib.pyplot as plt
import os
import cv2
from tqdm import tqdm

DATADIR = "'/home/akshat/Documents/Cats and Dogs/training_set /training_set/IN/Dog'
"

CATEGORIES = ["Dog", "Cat"]

for category in CATEGORIES: # do dogs and cats
path = os.path.join(DATADIR,category) # create path to dogs and cats
for img in os.listdir(path): # iterate over each image per dogs and cats
img_array = cv2.imread(os.path.join(path,img) ,cv2.IMREAD_GRAYSCALE) # convert to array
plt.imshow(img_array, cmap='gray') # graph it
plt.show() # display!

    break  
break  

Error:
FileNotFoundError: [Errno 2] No such file or directory: '/home/akshat/Documents/Cats and Dogs/training_set/training_set/IN/Dog'

OS:Ubuntu 18.04

Tell me what I am doing wrong???

AWS Security LIVE! Stream

Streaming live from AWS re:Inforce

Join AWS Security LIVE! at re:Inforce for real conversations with AWS Partners.

Learn More

Top comments (0)

Dynatrace image

Frictionless debugging for developers

Debugging in production doesn't have to be a nightmare.

Dynatrace reimagines the developer experience with runtime debugging, native OpenTelemetry support, and IDE integration allowing developers to stay in the flow and focus on building instead of fixing.

Learn more

👋 Kindness is contagious

Discover fresh viewpoints in this insightful post, supported by our vibrant DEV Community. Every developer’s experience matters—add your thoughts and help us grow together.

A simple “thank you” can uplift the author and spark new discussions—leave yours below!

On DEV, knowledge-sharing connects us and drives innovation. Found this useful? A quick note of appreciation makes a real impact.

Okay