Skip to content

Commit

Permalink
Merge pull request #96 from Kohulan/development
Browse files Browse the repository at this point in the history
fix: bug with incorrect size of DECIMER_HandDrawn model
  • Loading branch information
Kohulan authored Apr 12, 2024
2 parents 73cdb01 + c0b1f0d commit e7d4583
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions DECIMER/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,23 @@ def ensure_models(default_path: str, model_urls: dict) -> dict:
dict: A dictionary containing model names as keys and their local paths as values
"""
model_paths = {}

# Store st_size of each model
model_sizes = {
"DECIMER": 28080309,
"DECIMER_HandDrawn": 28080328,
}
for model_name, model_url in model_urls.items():
model_path = os.path.join(default_path, f"{model_name}_model")
if (
os.path.exists(model_path)
and os.stat(os.path.join(model_path, "saved_model.pb")).st_size != 28080309
os.path.exists(model_path)
and os.stat(os.path.join(model_path, "saved_model.pb")).st_size != model_sizes.get(model_name)
):
print(f'Working with model {model_name}')
shutil.rmtree(model_path)
config.download_trained_weights(model_url, default_path)
elif not os.path.exists(model_path):
config.download_trained_weights(model_url, default_path)

# Store the model path
model_paths[model_name] = model_path

return model_paths

0 comments on commit e7d4583

Please sign in to comment.