Skip model download on import
Importing PHash causes the import of the CNN class and triggers the download of the Mobilenet model from torchvision.
Although very small, it's just and extra log that can be distracting in applications.
Can I get rid of it ? This was just introduced in the PR https://github.com/idealo/imagededup/pull/190
It seems to be caused by the import of the class CNN from imagededup.methods.cnn, which downloads the model as part as evaluating the default argument of __init__.
You can do as follow:
def __init__(
self,
verbose: bool = True,
model_config: CustomModel = CustomModel()
# model_config: CustomModel = CustomModel(
# model=MobilenetV3(), transform=MobilenetV3.transform, name=MobilenetV3.name
# ),
And manually select the downloaded model like: https://github.com/idealo/imagededup/blob/master/examples/use_custom_model.ipynb
Addressed in #201