Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saved Model does not exist #8

Closed
OFranke opened this issue Aug 8, 2021 · 3 comments · Fixed by #56
Closed

Saved Model does not exist #8

OFranke opened this issue Aug 8, 2021 · 3 comments · Fixed by #56

Comments

@OFranke
Copy link

OFranke commented Aug 8, 2021

I am receiving following error message, it looks like the model used to solve the captchas does not exist in assets/model.h5 directory: OSError: SavedModel file does not exist at: assets/model.h5/{saved_model.pbtxt|saved_model.pb}

Here's my code:

from deutschland import Bundesanzeiger
ba = Bundesanzeiger()
# search term
data = ba.get_reports("Deutsche Bahn AG")
# returns a dictionary with all reports found as fulltext reports
print(data.keys())
# dict_keys(['Jahresabschluss zum Geschäftsjahr vom 01.01.2020 bis zum 31.12.2020', 'Konzernabschluss zum Geschäftsjahr vom 01.01.2020 bis zum 31.12.2020\nErgänzung der Veröffentlichung vom 04.06.2021',

@tmechen
Copy link

tmechen commented Aug 9, 2021

problem: installing the lib places the model in here: /venv/lib/site-packages/assets/model.h5

(hacky) fix:

  • place the model.h5 file into venv/lib/site-packages/deutschland/bundesanzeiger/assets/model.h5
  • replace the load_model() in model.py with:
import os
from pathlib import Path

def load_model():
    parent = Path(os.path.abspath(__file__)).parent
    path = os.path.join(parent, 'assets', 'model.h5')
    return keras.models.load_model(
        path, custom_objects={"my_accuracy": my_accuracy}
    )

no pull request because there might be some better solution than this (i hope), i did never distribute files via libraries.

@shigapov
Copy link

The fix by @tmechen without moving the model:

import os
from pathlib import Path

def load_model():
    parent = Path(os.path.abspath(__file__)).parents[2]
    path = os.path.join(parent, 'assets', 'model.h5')
    return keras.models.load_model(
        path, custom_objects={"my_accuracy": my_accuracy}
    )

@auchtetraborat
Copy link
Contributor

This problem still exists in the compiled versions of the library installed via pip.
Tested with deutschland 0.1.8 on python 3.8.10 & pip 21.2.3.
Works fine when using the sourcecode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants