-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathclassifier_inception_v3.py
More file actions
27 lines (22 loc) · 1.05 KB
/
classifier_inception_v3.py
File metadata and controls
27 lines (22 loc) · 1.05 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
from classifier_base import BaseClassifier
from keras.applications import *
from keras.layers import *
from keras.engine import *
from config import *
class InceptionV3Classifier(BaseClassifier):
def __init__(self, name='inception_v3', lr=1e-3, batch_size=BATCH_SIZE, weights_mode='loss', optimizer=None):
BaseClassifier.__init__(self, name, IM_SIZE_299,
lr, batch_size, weights_mode, optimizer)
def create_model(self):
weights = 'imagenet' if self.context['load_imagenet_weights'] else None
model_xception = InceptionV3(include_top=False, weights=weights,
input_shape=(self.im_size, self.im_size, 3), pooling='avg')
for layer in model_xception.layers[:-20]:
layer.trainable = False
x = model_xception.output
x = Dense(CLASSES, activation='softmax')(x)
model = Model(inputs=model_xception.inputs, outputs=x)
return model
if __name__ == '__main__':
classifier = InceptionV3Classifier(lr=1e-5)
classifier.train()