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) output_text.append(res)
return output_text return output_text
def load_model(): model = None
_model = keras.models.load_model('model') def _getModel():
model = keras.models.Model( global model
_model.get_layer(name="image").input, if model is None:
_model.get_layer(name="dense2").output)
return model
def getTextInCaptchaImage(captchaImageFile):
batchImages = encode_single_sample(captchaImageFile)
preds = model.predict(batchImages)
return decode_batch_predictions(preds)[0]
print("loading model...") print("loading model...")
model = load_model() model = load_model()
model.summary() model.summary()
return model
def load_model():
_model = keras.models.load_model('model')
__model = keras.models.Model(
_model.get_layer(name="image").input,
_model.get_layer(name="dense2").output)
return __model
def getTextInCaptchaImage(captchaImageFile):
batchImages = encode_single_sample(captchaImageFile)
preds = _getModel().predict(batchImages)
return decode_batch_predictions(preds)[0]

View File

@@ -81,7 +81,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"updateVAERSFiles(\n", "updateVAERSFiles(\n",
" needsUpdate,\n", " needsUpdate = needsUpdate,\n",
" years = [2022],\n", " years = [2022],\n",
" workingDirectory = getWorkingDirectory())" " workingDirectory = getWorkingDirectory())"
] ]