marialeyvallina / generalized_contrastive_loss

MIT License
87 stars 14 forks source link

Use relative imports for the factory submodule #18

Closed blueted2 closed 1 year ago

blueted2 commented 1 year ago

When attempting to reuse the factory.py module by importing it, Python fails to import other modules such as src.datasets and src.networks. This can be solved by just using a relative import path.

This change now allows me to perform imports such as :

from libs.generalized_contrastive_loss.src import factory
backbone = factory.get_backbone("resnet18")

with the gcl repository in the libs folder.

I have checked (as far as I can tell) that this doesn't impact the extract_predictions.py, train.py or apply_pca.py scripts.