This commit is contained in:
parent
b094ab43fa
commit
9b328cf259
@ -64,6 +64,7 @@ class ClassifierCache:
|
||||
self._downloaded_files.append(weights_file_path)
|
||||
|
||||
# magic happens here
|
||||
with opentracing.tracer.start_active_span('classifier.loadNewClassifier'):
|
||||
self._current_classifier = Classifier(model_file_path, weights_file_path)
|
||||
|
||||
def get_default_classifier(self) -> Tuple[dict, Classifier]:
|
||||
|
@ -18,14 +18,21 @@ from keras_preprocessing.image import ImageDataGenerator
|
||||
class Classifier(object):
|
||||
|
||||
def __init__(self, model_filename: str, weights_filename: str):
|
||||
with opentracing.tracer.start_active_span('classifier.loadModel'):
|
||||
with open(model_filename, 'r') as f:
|
||||
self.loaded_model = model_from_json(f.read())
|
||||
|
||||
with opentracing.tracer.start_active_span('classifier.loadWeights'):
|
||||
self.loaded_model.load_weights(weights_filename)
|
||||
|
||||
with opentracing.tracer.start_active_span('classifier.loadDatagen'):
|
||||
self.datagen = ImageDataGenerator(rescale=1. / 255., validation_split=0.25)
|
||||
|
||||
with opentracing.tracer.start_active_span('classifier.compile'):
|
||||
self.loaded_model.compile(optimizers.RMSprop(lr=0.0005, decay=1e-6), loss="categorical_crossentropy",
|
||||
metrics=["accuracy"])
|
||||
self.loaded_model.summary()
|
||||
|
||||
self.loaded_model.summary() # prints to stdout??
|
||||
|
||||
@staticmethod
|
||||
def create_spectrogram(wav_filename: str) -> Tuple[str, str]:
|
||||
|
Loading…
Reference in New Issue
Block a user