qurator-spk / sbb_binarization

Document Image Binarization
Apache License 2.0
67 stars 14 forks source link

Model path problem #42

Closed rettinghaus closed 1 year ago

rettinghaus commented 1 year ago

Why is it is not looking in the given --model-dir for the model but rather in it's model subdirectory?

mikegerber commented 1 year ago

It is looking for *.h5 files in --model-dir. Could you give more information, like the exact command you tried to execute and an ls of the --model-dir?

rettinghaus commented 1 year ago

When I do -m model I get

OSError: SavedModel file does not exist at: model/model/model_bin_sbb_ens.h5/{saved_model.pbtxt|saved_model.pb}

With -m ./model

OSError: SavedModel file does not exist at: ./model/./model/model_bin_sbb_ens.h5/{saved_model.pbtxt|saved_model.pb}

That's because you do a glob with the given path on init, and then join the file path with model_dir in load_model. This cannot work.

mikegerber commented 1 year ago

Interesting is why I could not reproduce this problem at first:

>>> import os.path
>>> os.path.join("/home/mike/devel/qurator-data/sbb_binarization/2022-08-16/", "/home/mike/devel/qurator-data/sbb_binarization/2022-08-16/model_bin_hybrid_trans_cnn_sbb_ens.h5")
'/home/mike/devel/qurator-data/sbb_binarization/2022-08-16/model_bin_hybrid_trans_cnn_sbb_ens.h5'

@kba 👀

So the bug only occurs if using a relative path because os.path.join has the unexpected (but documented!) behaviour of throwing away the first component if the second one is an absolute path.

rettinghaus commented 1 year ago

Yes, it's only working for absolute paths, not relative ones. Maybe better to use proper path objects here instead of os.path?

bertsky commented 1 year ago

Looks like this is fixed, right?

rettinghaus commented 1 year ago

It is.

vahidrezanezhad commented 1 year ago

Looks like this is fixed, right?

Sorry for late response. Yes it is already fixed.