-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathServerSide.py
More file actions
30 lines (22 loc) · 808 Bytes
/
ServerSide.py
File metadata and controls
30 lines (22 loc) · 808 Bytes
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
from tensorflow.keras.models import model_from_json
from keras.preprocessing import image
import numpy as np
import os
def predict_class(path):
with open("Model/model.json") as json_file:
model = model_from_json(json_file.read())
model.load_weights("Model/weight.h5")
img_width, img_height = 150, 150
img = image.load_img(path, target_size = (img_width, img_height))
x = image.img_to_array(img)
x /= 255
x = np.expand_dims(x, axis = 0)
images = np.vstack([x])
classes = model.predict(images, batch_size = 16)
return classes
'''
c = predict_class(os.getcwd()+'/chest_xray/chest_xray/train/NORMAL/IM-0149-0001.jpeg')
print(c[0][0])
c = predict_class(os.getcwd()+'/chest_xray/chest_xray/train/PNEUMONIA/person1000_virus_1681.jpeg')
print(c[0][0])
'''