Skip to content

Instantly share code, notes, and snippets.

@jurand71
Created November 14, 2022 14:32
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 jurand71/ad81ed371fce45167ecbab359b47b069 to your computer and use it in GitHub Desktop.
Save jurand71/ad81ed371fce45167ecbab359b47b069 to your computer and use it in GitHub Desktop.
import os
import cv2
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from tensorflow.keras.utils import img_to_array
from sklearn.model_selection import train_test_split
import warnings
warnings.filterwarnings('ignore')
def get_img_paths(path):
paths=[]
labels=[]
for label in os.listdir(path):
img_dir = os.path.join(path,label)
for img in os.listdir(img_dir):
paths.append(os.path.join(img_dir, img))
labels.append(label)
return pd.DataFrame({'path':paths, 'label':labels})
train_path = "\TRAIN"
test_path = "\TEST"
conversion = {'O': 0, 'R': 1}
train = get_img_paths(train_path)
train.label = train.label.map(conversion)
test = get_img_paths(test_path)
test.label = test.label.map(conversion)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment