-
Notifications
You must be signed in to change notification settings - Fork 0
/
eval.py
28 lines (20 loc) · 858 Bytes
/
eval.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from model import Model
import pandas as pd
import os
def load_test_paths(base_path):
label_dict={'NORMAL':0,'PNEUMONIA':1}
filenames = os.walk(base_path)
files=list(filenames)[0][2]
files=[file for file in files if file.endswith(".jpeg")]
labels=[label_dict[file.split('_')[0]] for file in files]
file_df=pd.DataFrame({"file":files,"label":labels})
file_df["file"]=file_df.file.map(lambda x: os.path.join(base_path,x))
return file_df
if __name__ == "__main__":
#load data
Test_data=load_test_paths('./chest_xray_dataset/test/')
#load model
model=Model()
Test_data['prediction']=Test_data.file.map(model.predict)
accuracy=(Test_data['label']==Test_data['prediction']).sum()/Test_data.shape[0]
print("You got {}% accuracy".format(round(accuracy*100,2)))