-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtempCodeRunnerFile.py
More file actions
88 lines (59 loc) · 2.6 KB
/
Copy pathtempCodeRunnerFile.py
File metadata and controls
88 lines (59 loc) · 2.6 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
def test_model_proc(fn):
from keras.models import load_model
IMAGE_SIZE = 64
LEARN_RATE = 1.0e-4
CH=3
print(fn)
if fn!="":
# Model Architecture and Compilation
model = load_model('S:/Project Code latest - Copy/Project Code latest - Copy/cell_model.h5', compile=False)
img = Image.open(fn)
img = img.resize((IMAGE_SIZE,IMAGE_SIZE))
img = np.array(img)
img = img.reshape(1,IMAGE_SIZE,IMAGE_SIZE,3)
img = img.astype('float32')
img = img / 255.0
print('img shape:',img)
prediction = model.predict(img)
print(np.argmax(prediction))
cell=np.argmax(prediction)
print(cell)
if cell == 0:
Cd="Sickeled Cell Detected \n Doctor Consultation Required \nReport Generated by (laboratory name) \n ---End of Report--- "
elif cell == 1:
Cd="LYMPHOCYTE Deficiency Detected\n Doctor Consultation Required \nReport Generated by (laboratory name) \n ---End of Report--- "
elif cell == 2:
Cd="MONOCYTE Deficiency Detected\n Doctor Consultation Required \nReport Generated by (laboratory name) \n ---End of Report--- "
elif cell == 3:
Cd="NEUTROPHIL Cell Detected \n Doctor Consultation Required \nReport Generated by (laboratory name) \n ---End of Report--- "
A=Cd
return A
else:
return "Please select a valid image."
# def clear_img():
# img11 = tk.Label(frame_display, background='lightblue4',width=160,height=120)
# img11.place(x=0, y=0)
def update_label(str_T):
#clear_img()
result_label = tk.Label(root, text=str_T, width=60, font=("bold", 25), bg='bisque2', fg='black')
result_label.place(x=290, y=420)
# def train_model():
# update_label("Model Training Start...............")
# start = time.time()
# X=Model_frm.main()
# end = time.time()
# ET="Execution Time: {0:.4} seconds \n".format(end-start)
# msg="Model Training Completed.."+'\n'+ X + '\n'+ ET
# update_label(msg)
def test_model():
global fn
if fn != "":
update_label("Model Testing Start...............")
start = time.time()
X, percentage_detected = test_model_proc(fn)
end = time.time()
ET = "Detected Cell Percentage: {:.2f}% \n".format(percentage_detected)
msg = "Image Testing Completed.."+'\n'+ X + '\n'+ ET
else:
msg = "Please Select Image For Prediction...."
update_label(msg)