The code i was trying to run is:
import numpy as np
import os
import cv2
import matplotlib.pyplot as plt
from os import listdir
from pathlib import Path
all_images = list(Path(r'D:/face/train').glob('**/*.jpg'))
np.array([np.array(cv2.imread(str(file))).flatten() for file in all_images])
Path = r'D:\face\train'
print(all_images[0])
the output is: D:\face\train\F0002\MID1\P00009_face3.jpg
train_images = ([x for x in all_images if val_families not in x])
val_images = ([x for x in all_images if val_families in x])
i'm getting the following error.
TypeError Traceback (most recent call last)
<ipython-input-8-8de97a2e12c1> in <module>
----> 1 train_images = ([x for x in all_images if val_families not in x])
2 val_images = ([x for x in all_images if val_families in x])
<ipython-input-8-8de97a2e12c1> in <listcomp>(.0)
----> 1 train_images = ([x for x in all_images if val_families not in x])
2 val_images = ([x for x in all_images if val_families in x])
TypeError: argument of type 'WindowsPath' is not iterable
first of all i didnt use the Path class instead i was using the following command
all_images = glob(train_folders_path + "*/*/*.jpg")
print(all_images[0])
but here i was getting an index error. later i imported Path and tried the first code which gave me the output i wanted. but i'm getting error as i mentioned in the next line. Please help me solve this.
machine-learning
orjupyter-notebook
- kindly do not spam irrelevant tags (removed).