imagededup icon indicating copy to clipboard operation
imagededup copied to clipboard

Skip model download on import

Open bogdan-galileo opened this issue 2 years ago • 1 comments

Importing PHash causes the import of the CNN class and triggers the download of the Mobilenet model from torchvision.

Screenshot 2023-07-26 at 3 25 33 PM

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__.

bogdan-galileo avatar Jul 26 '23 19:07 bogdan-galileo

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

nibnahzuh avatar Nov 06 '24 08:11 nibnahzuh

Addressed in #201

tanujjain avatar Jul 28 '25 13:07 tanujjain