-
Notifications
You must be signed in to change notification settings - Fork 0
/
predict code.txt
65 lines (39 loc) · 1.8 KB
/
predict code.txt
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
from keras.models import load_model
from keras.preprocessing import image
from keras.applications.vgg16 import preprocess_input
import numpy as np
# (1)PREDICTION USING VGG16
model = load_model('C:\\Users\\MCHOME\\Desktop\\PBL B5\\PBL_VGG16\\model_vgg16.h5')
img=image.load_img('E:\\chest_xray\\val\\NORMAL\\NORMAL2-IM-1436-0001.jpeg',target_size=(224,224))
x=image.img_to_array(img)
x=np.expand_dims(x,axis=0)
img_data=preprocess_input(x)
classes=model.predict(img_data)
# (2)PREDICTION USING VGG19
model = load_model('C:\\Users\\MCHOME\\Desktop\\PBL B5\\PBL_VGG19\\model_vgg19.h5')
img=image.load_img('E:\\chest_xray\\val\\NORMAL\\NORMAL2-IM-1436-0001.jpeg',target_size=(224,224))
x=image.img_to_array(img)
x=np.expand_dims(x,axis=0)
img_data=preprocess_input(x)
classes=model.predict(img_data)
# (3)PREDICTION USING iNCEPTION v3
model = load_model('C:\\Users\\MCHOME\\Desktop\\PBL B5\\PBL_InceptionV3\\model_inceptionV3.h5')
img=image.load_img('E:\\chest_xray\\val\\NORMAL\\NORMAL2-IM-1436-0001.jpeg',target_size=(224,224))
x=image.img_to_array(img)
x=np.expand_dims(x,axis=0)
img_data=preprocess_input(x)
classes=model.predict(img_data)
# (4)PREDICTION USING RESNET50
model = load_model('C:\\Users\\MCHOME\\Desktop\\PBL B5\\PBL_Resnet50\\model_resnet50.h5')
img=image.load_img('E:\\chest_xray\\val\\NORMAL\\NORMAL2-IM-1436-0001.jpeg',target_size=(224,224))
x=image.img_to_array(img)
x=np.expand_dims(x,axis=0)
img_data=preprocess_input(x)
classes=model.predict(img_data)
# (5)PREDICTION USING DENSENET121
model = load_model('C:\\Users\\MCHOME\\Desktop\\PBL B5\\PBL_DenseNet121\\model_densenet121.h5')
img=image.load_img('E:\\chest_xray\\val\\NORMAL\\NORMAL2-IM-1436-0001.jpeg',target_size=(224,224))
x=image.img_to_array(img)
x=np.expand_dims(x,axis=0)
img_data=preprocess_input(x)
classes=model.predict(img_data)