Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created November 24, 2020 08:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amankharwal/d8c23cfb2e899a7f89ffc2dafb72acdb to your computer and use it in GitHub Desktop.
Save amankharwal/d8c23cfb2e899a7f89ffc2dafb72acdb to your computer and use it in GitHub Desktop.
data = []
label = []
SIZE = 128 #Crop the image to 128x128
for folder in os.listdir(folder_dir):
for file in os.listdir(os.path.join(folder_dir, folder)):
if file.endswith("jpg"):
label.append(folder)
img = cv2.imread(os.path.join(folder_dir, folder, file))
img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
im = cv2.resize(img_rgb, (SIZE,SIZE))
data.append(im)
else:
continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment