99from tensorflow .keras import backend
1010from tensorflow .keras .preprocessing .image import ImageDataGenerator
1111import os
12+ from sklearn .metrics import classification_report
13+ import sklearn .metrics as metrics
14+ import itertools
1215for dirname , _ , filenames in os .walk ('/kaggle/input' ):
1316 for filename in filenames :
1417 print (os .path .join (dirname , filename ))
@@ -48,9 +51,9 @@ def data_set(dir_data):
4851 data = np .array (data , dtype = "float" ) / 255.0
4952 target = tf .keras .utils .to_categorical (np .array (target ), num_classes = 2 )
5053 return data , target
51- training_data , training_target = data_set ('/kaggle/input/face-mask-detection/train/' )
52- testing_data , testing_target = data_set ('/kaggle/input/face-mask-detection/test/' )
53- valid_data , valid_target = data_set ('/kaggle/input/face-mask-detection/valid/' )
54+ training_target = data_set ('./Face-Mask-Detection /kaggle/input/face-mask-detection/train/' )
55+ testing_target = data_set ('./Face-Mask-Detection /kaggle/input/face-mask-detection/test/' )
56+ valid_target = data_set ('./Face-Mask-Detection /kaggle/input/face-mask-detection/valid/' )
5457plt .figure (0 , figsize = (100 ,100 ))
5558for i in range (1 ,10 ):
5659 plt .subplot (10 ,5 ,i )
@@ -105,9 +108,6 @@ def data_set(dir_data):
105108yhat = model .predict (testing_data )
106109test_pred = np .argmax (yhat ,axis = 1 )
107110testing_target = np .argmax (testing_target ,axis = 1 )
108- from sklearn .metrics import classification_report
109- import sklearn .metrics as metrics
110- import itertools
111111report = classification_report (testing_target , test_pred )
112112print (report )
113113def plot_confusion_matrix (cm , classes ,
@@ -133,4 +133,4 @@ def plot_confusion_matrix(cm, classes,
133133
134134confusion = metrics .confusion_matrix (testing_target , test_pred )
135135plt .figure ()
136- plot_confusion_matrix (confusion , classes = ['without_mask' ,'with_mask' ], title = 'Confusion matrix' )
136+ plot_confusion_matrix (confusion , classes = ['without_mask' ,'with_mask' ], title = 'Confusion matrix' )
0 commit comments