Last active
December 9, 2020 02:06
-
-
Save PhilipPurwoko/5ecf2c27444a2cb97bd8eedeb10ffb04 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 random | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import tensorflow as tf | |
keras = tf.keras |
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
def loading_data(): | |
dirname = 'dataset/' | |
dirtype = ['train/', 'valid/'] | |
dirclass = ['with_mask/', 'without_mask/'] | |
x_train = [] | |
y_train = [] | |
x_test = [] | |
y_test = [] | |
for typ in dirtype: | |
for cls in dirclass: | |
for i in os.listdir(dirname+typ+cls): | |
if typ == 'train/': | |
x_train.append(dirname+'train/'+cls+i) | |
y_train.append(cls[:-1]) | |
else: | |
x_test.append(dirname+'valid/'+cls+i) | |
y_test.append(cls[:-1]) | |
return np.array(x_train),np.array(y_train),np.array(x_test),np.array(y_test) | |
# Run loading_data() function | |
x_train,y_train,x_test,y_test = loading_data() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment