31 lines
842 B
Python
31 lines
842 B
Python
|
|
from m import *
|
||
|
|
from sklearn.metrics import f1_score, precision_score, recall_score, accuracy_score
|
||
|
|
|
||
|
|
|
||
|
|
ds = tf.keras.preprocessing.image_dataset_from_directory(
|
||
|
|
'../dataset-orig-aug-1-mini-1/',
|
||
|
|
labels = 'inferred',
|
||
|
|
label_mode = 'categorical',
|
||
|
|
color_mode = 'rgb',
|
||
|
|
image_size = (300, 300),
|
||
|
|
batch_size = 32,
|
||
|
|
verbose = True
|
||
|
|
)
|
||
|
|
|
||
|
|
p = []
|
||
|
|
r = []
|
||
|
|
|
||
|
|
with open('results.txt', 'r') as f:
|
||
|
|
for i in f.read().split('\n'):
|
||
|
|
if i == '':
|
||
|
|
continue
|
||
|
|
|
||
|
|
res = tuple(map(float, i.split()))
|
||
|
|
p.append([res[0] > 0.5, res[1] > 0.5])
|
||
|
|
r.append([res[2], res[3]])
|
||
|
|
|
||
|
|
print(f"Accuracy : {accuracy_score(p, r)}")
|
||
|
|
print(f"Precision : {precision_score(p, r, average = 'micro')}")
|
||
|
|
print(f"Recall : {recall_score(p, r, average = 'micro')}")
|
||
|
|
print(f"F1 Score : {f1_score(p, r, average = 'micro')}")
|