About my project I'm trying to train images for text detection using python and tensorflow on pycharm MacOS
now I'm working on splitting the data into training. There are 2 files inside of TrainingData file. Each image folder has 4 images.(I know it's quiet few, but I'll add more images later)
path = 'TrainingData'
images = []
classNo = []
myList = os.listdir(path)
print('Total No of Classes Detected...', len(myList))
noOfClasses = len(myList)
print('Importing Classes...')
for x in range(0, noOfClasses):
myPicList = os.listdir(path+'/'+str(x))
for y in myPicList:
curImg = cv2.imread(path+'/'+str(x)+'/'+y)
classNo.append(x)
print(x, end=' ')
print(' ')
However, the result returns
File "/Users/myname/PycharmProjects/TextDetection/Playernames.py",line 37, in <module>
myPicList = os.listdir(path+"/"+str(x))
FileNotFoundError: [Errno 2] No such file or directory: 'TrainingData/0'
Total No of Classes Detected... 2
Importing Classes...
What I tried to solve the problem
1.Checked if the path exists
path = 'TrainingData'
if os.path.isfile(path):
print('File exists')
else:
print('Failed')
result shows Failed so I think the path doesn't exist in the file.
2: Checked the tree of the files
tree of TrainingDAta↓
/Users/myname/PycharmProjects/TextDetection/TrainingData
├── File Name 1
│ ├── IMG_1754.jpg
│ ├── IMG_1755.jpg
│ ├── IMG_1756.jpg
│ └── IMG_1757.jpg
└── File Name 2
├── IMG_1751.jpg
├── IMG_1752.jpg
├── IMG_1753.jpg
└── IMG_1758.jpg
2 directories, 8 files
Tree of the project file itself
/Users/myname/PycharmProjects/TextDetection/Playernames.py [error opening dir]
0 directories, 0 files
What I wanna know
According to the tree, I guess I need to change the location of the TrainingData, because the project shows it doesn't have any directories or files. And I wanna know how to change that.
I'm a beginner so I'm not sure if my attempt is right or wrong.