Image classification cats dogs

hi guys ! i create a parent folder for my data cats ands dogs …i ve been runnin in vain i get the same error no such file or directory DIRECTORY

import numpy as np
import pandas as pd
from keras.preprocessing.image import ImageDataGenerator, load_img
#from keras.utils import to_categorical
from sklearn.model_selection import train_test_split
import matplotlib.pyplot as plt
import random
import os
import pickle
#print(os.listdir(“…/input”))
#Using Tensorflow backend.
#(‘train’(1).csv’)

=r"\C:\Users\moi\OneDrive\Documents\conv neural l\cats\"

  1 for categorie in CATEGORIES :
  2     folder = os.path.join( DIRECTORY , categorie )

----> 3 for img in os.listdir(folder):
4 img_path = os.path.join (folder,img )
5 img_arr = cv2.imread(img_path )

FileNotFoundError: [Errno 2] No such file or directory: ‘\\C:\\Users\\moi\\OneDrive\\Documents\\conv neural l\\cats\\/cats’

can anyone help?

First of all, to make it easier for us to read your code you should ‘fence’ it with triple backticks (```), then this
```python
def foo(bar):
return bar * 2
```
will look like this

def foo(bar):
    return bar * 2

To your question: Assuming that the line starting with =r"\C... refers to the file path, that file path should probably not end in ...\conv neural I\cats\ and just end in ...\conv neural I\. I believe this because the error states that the file you are trying to look up in the loop ends with \cats\\/cats, i.e. one \\cats too many.

1 Like

ok thank you very much for reply

i exctracted the folder from zip and i get a better path :
C:\Users\moi\Downloads\PARENT_ FOLDER\1577957291_deeplearningwithkerasandtensorflow (5)\data\test\cats

but with :

File “”, line 1
DIRECTORY =r"\C:\Users\moi\Downloads\PARENT_FOLDER\1577957291_deeplearningwithkerasandtensorflow (5)\data\test\cats
^
SyntaxError: EOL while scanning string literal

thank you vm

another try :

DIRECTORY =r"\C:\Users\moi\Downloads\PARENT_FOLDER\1577957291_deeplearningwithkerasandtensorflow (5)\data\test\cats"

i get a worst error :

FileNotFoundError Traceback (most recent call last)
in
1 for categorie in CATEGORIES :
2 folder = os.path.join( DIRECTORY , categorie )
----> 3 for img in os.listdir(folder):
4 img_path = os.path.join (folder,img )
5 img_arr = cv2.imread(img_path )

FileNotFoundError: [Errno 2] No such file or directory: ‘\\C:\\Users\\moi\\Downloads\\PARENT_FOLDER\\1577957291_deeplearningwithkerasandtensorflow (5)\\data\\test\\cats/cats’

another try :
DIRECTORY =r’\C:\Users\moi\Downloads\PARENT_FOLDER\1577957291_deeplearningwithkerasandtensorflow (5)\data\test\cats\’

FileNotFoundError Traceback (most recent call last)
in
1 for categorie in CATEGORIES :
2 folder = os.path.join( DIRECTORY , categorie )
----> 3 for img in os.listdir(folder):
4 img_path = os.path.join (folder,img )
5 img_arr = cv2.imread(img_path )

FileNotFoundError: [Errno 2] No such file or directory: ‘\\C:\\Users\\moi\\Downloads\\PARENT_FOLDER\\1577957291_deeplearningwithkerasandtensorflow (5)\\data\\test\\cats\\/cats’

i m going sad …i don t understand anything