refactoring

This commit is contained in:
frankknoll
2022-11-22 18:02:03 +01:00
parent c23f61a200
commit 54a9ca52de
2 changed files with 14 additions and 9 deletions

View File

@@ -56,18 +56,23 @@ def decode_batch_predictions(pred):
output_text.append(res)
return output_text
model = None
def _getModel():
global model
if model is None:
print("loading model...")
model = load_model()
model.summary()
return model
def load_model():
_model = keras.models.load_model('model')
model = keras.models.Model(
__model = keras.models.Model(
_model.get_layer(name="image").input,
_model.get_layer(name="dense2").output)
return model
return __model
def getTextInCaptchaImage(captchaImageFile):
batchImages = encode_single_sample(captchaImageFile)
preds = model.predict(batchImages)
preds = _getModel().predict(batchImages)
return decode_batch_predictions(preds)[0]
print("loading model...")
model = load_model()
model.summary()