-
-
Save jurand71/ad81ed371fce45167ecbab359b47b069 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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