diff --git a/lightly/__init__.py b/lightly/__init__.py index 7e9e0b69d..fd2c6c63c 100644 --- a/lightly/__init__.py +++ b/lightly/__init__.py @@ -48,6 +48,8 @@ - MoCo + - SimSiam + - **transforms**: The lightly.transforms module implements custom data transforms. Currently implements: @@ -68,7 +70,7 @@ # All Rights Reserved __name__ = 'lightly' -__version__ = '1.1.0' +__version__ = '1.1.1' try: @@ -97,8 +99,22 @@ def _is_prefetch_generator_available(): return _prefetch_generator_available + from lightly.core import * + from lightly import active_learning + from lightly import api + from lightly import data + from lightly import embedding + from lightly import loss + from lightly import models + from lightly import openapi_generated + from lightly import transforms + from lightly import utils + + # check for latest version - from lightly.api.version_checking import get_latest_version, version_compare, pretty_print_latest_version + from lightly.api.version_checking import get_latest_version + from lightly.api.version_checking import version_compare + from lightly.api.version_checking import pretty_print_latest_version latest_version = get_latest_version(__version__) if latest_version is not None: diff --git a/tests/imports/test_from_imports.py b/tests/imports/test_from_imports.py new file mode 100644 index 000000000..b7cd536a0 --- /dev/null +++ b/tests/imports/test_from_imports.py @@ -0,0 +1,84 @@ +import unittest +import torch + +import lightly + + +class TestFromImports(unittest.TestCase): + + def test_from_imports(self): + # active learning (commented out don't work) + from lightly.active_learning.config.sampler_config import SamplerConfig + from lightly.active_learning.agents.agent import ActiveLearningAgent + from lightly.active_learning.scorers.classification import ScorerClassification + + # api imports + from lightly.api.routes.users import get_quota + from lightly.api.routes.users.docker import get_authorization + from lightly.api.routes.users.docker import get_soft_authorization + from lightly.api.routes.users.docker import post_diagnostics + from lightly.api.api_workflow_client import ApiWorkflowClient + from lightly.api.bitmask import BitMask + + # data imports + from lightly.data import LightlyDataset + from lightly.data.dataset import LightlyDataset + from lightly.data import BaseCollateFunction + from lightly.data.collate import BaseCollateFunction + from lightly.data import ImageCollateFunction + from lightly.data.collate import ImageCollateFunction + from lightly.data import MoCoCollateFunction + from lightly.data.collate import MoCoCollateFunction + from lightly.data import SimCLRCollateFunction + from lightly.data.collate import SimCLRCollateFunction + from lightly.data import imagenet_normalize + from lightly.data.collate import imagenet_normalize + + # embedding imports + from lightly.embedding import BaseEmbedding + from lightly.embedding._base import BaseEmbedding + from lightly.embedding import SelfSupervisedEmbedding + from lightly.embedding.embedding import SelfSupervisedEmbedding + + # loss imports + from lightly.loss import NTXentLoss + from lightly.loss.ntx_ent_loss import NTXentLoss + from lightly.loss import SymNegCosineSimilarityLoss + from lightly.loss.sym_neg_cos_sim_loss import SymNegCosineSimilarityLoss + from lightly.loss.memory_bank import MemoryBankModule + + # models imports + from lightly.models import ResNetGenerator + from lightly.models.resnet import ResNetGenerator + from lightly.models import SimCLR + from lightly.models.simclr import SimCLR + from lightly.models import MoCo + from lightly.models.moco import MoCo + from lightly.models import SimSiam + from lightly.models.simsiam import SimSiam + from lightly.models import ZOO + from lightly.models.zoo import ZOO + from lightly.models import checkpoints + from lightly.models.zoo import checkpoints + from lightly.models.batchnorm import get_norm_layer + + # transforms imports + from lightly.transforms import GaussianBlur + from lightly.transforms.gaussian_blur import GaussianBlur + from lightly.transforms import RandomRotate + from lightly.transforms.rotation import RandomRotate + + # utils imports + from lightly.utils import save_embeddings + from lightly.utils.io import save_embeddings + from lightly.utils import load_embeddings + from lightly.utils.io import load_embeddings + from lightly.utils import load_embeddings_as_dict + from lightly.utils.io import load_embeddings_as_dict + from lightly.utils import fit_pca + from lightly.utils.embeddings_2d import fit_pca + + # core imports + from lightly import train_model_and_embed_images + from lightly import train_embedding_model + from lightly import embed_images \ No newline at end of file diff --git a/tests/imports/test_nested_imports.py b/tests/imports/test_nested_imports.py new file mode 100644 index 000000000..704392f58 --- /dev/null +++ b/tests/imports/test_nested_imports.py @@ -0,0 +1,88 @@ +import unittest +import torch + +import lightly + + +class TestNestedImports(unittest.TestCase): + + def test_nested_imports(self): + # active learning (commented out don't work) + #lightly.active_learning.agents.agent.ActiveLearningAgent + #lightly.active_learning.agents.ActiveLearningAgent + lightly.active_learning.config.sampler_config.SamplerConfig + #lightly.active_learning.scorers.classification.ScorerClassification + + # api imports + lightly.api.routes.users.get_quota + lightly.api.routes.users.docker.get_authorization + lightly.api.routes.users.docker.get_soft_authorization + lightly.api.routes.users.docker.post_diagnostics + lightly.api.api_workflow_client.ApiWorkflowClient + lightly.api.bitmask.BitMask + + # data imports + lightly.data.LightlyDataset + lightly.data.dataset.LightlyDataset + lightly.data.BaseCollateFunction + lightly.data.collate.BaseCollateFunction + lightly.data.ImageCollateFunction + lightly.data.collate.ImageCollateFunction + lightly.data.MoCoCollateFunction + lightly.data.collate.MoCoCollateFunction + lightly.data.SimCLRCollateFunction + lightly.data.collate.SimCLRCollateFunction + lightly.data.imagenet_normalize + lightly.data.collate.imagenet_normalize + + # embedding imports + lightly.embedding.BaseEmbedding + lightly.embedding._base.BaseEmbedding + lightly.embedding.SelfSupervisedEmbedding + lightly.embedding.embedding.SelfSupervisedEmbedding + + # loss imports + lightly.loss.NTXentLoss + lightly.loss.ntx_ent_loss.NTXentLoss + lightly.loss.SymNegCosineSimilarityLoss + lightly.loss.sym_neg_cos_sim_loss.SymNegCosineSimilarityLoss + lightly.loss.memory_bank.MemoryBankModule + + # models imports + lightly.models.ResNetGenerator + lightly.models.resnet.ResNetGenerator + lightly.models.SimCLR + lightly.models.simclr.SimCLR + lightly.models.MoCo + lightly.models.moco.MoCo + lightly.models.SimSiam + lightly.models.simsiam.SimSiam + lightly.models.ZOO + lightly.models.zoo.ZOO + lightly.models.checkpoints + lightly.models.zoo.checkpoints + lightly.models.batchnorm.get_norm_layer + + # transforms imports + lightly.transforms.GaussianBlur + lightly.transforms.gaussian_blur.GaussianBlur + lightly.transforms.RandomRotate + lightly.transforms.rotation.RandomRotate + + # utils imports + lightly.utils.save_embeddings + lightly.utils.io.save_embeddings + lightly.utils.load_embeddings + lightly.utils.io.load_embeddings + lightly.utils.load_embeddings_as_dict + lightly.utils.io.load_embeddings_as_dict + lightly.utils.fit_pca + lightly.utils.embeddings_2d.fit_pca + + # core imports + lightly.train_model_and_embed_images + lightly.core.train_model_and_embed_images + lightly.train_embedding_model + lightly.core.train_embedding_model + lightly.embed_images + lightly.core.embed_images \ No newline at end of file diff --git a/tests/imports/test_seminested_imports.py b/tests/imports/test_seminested_imports.py new file mode 100644 index 000000000..bcdbe8763 --- /dev/null +++ b/tests/imports/test_seminested_imports.py @@ -0,0 +1,88 @@ +import unittest +import torch + +import lightly + + +class TestSemiNestedImports(unittest.TestCase): + + def test_seminested_imports(self): + from lightly import active_learning + # active learning (commented out don't work) + #lightly.active_learning.agents.agent.ActiveLearningAgent + #lightly.active_learning.agents.ActiveLearningAgent + active_learning.config.sampler_config.SamplerConfig + #lightly.active_learning.scorers.classification.ScorerClassification + + # api imports + from lightly import api + api.routes.users.get_quota + api.routes.users.docker.get_authorization + api.routes.users.docker.get_soft_authorization + api.routes.users.docker.post_diagnostics + api.api_workflow_client.ApiWorkflowClient + api.bitmask.BitMask + + # data imports + from lightly import data + data.LightlyDataset + data.dataset.LightlyDataset + data.BaseCollateFunction + data.collate.BaseCollateFunction + data.ImageCollateFunction + data.collate.ImageCollateFunction + data.MoCoCollateFunction + data.collate.MoCoCollateFunction + data.SimCLRCollateFunction + data.collate.SimCLRCollateFunction + data.imagenet_normalize + data.collate.imagenet_normalize + + # embedding imports + from lightly import embedding + embedding.BaseEmbedding + embedding._base.BaseEmbedding + embedding.SelfSupervisedEmbedding + embedding.embedding.SelfSupervisedEmbedding + + # loss imports + from lightly import loss + loss.NTXentLoss + loss.ntx_ent_loss.NTXentLoss + loss.SymNegCosineSimilarityLoss + loss.sym_neg_cos_sim_loss.SymNegCosineSimilarityLoss + loss.memory_bank.MemoryBankModule + + # models imports + from lightly import models + models.ResNetGenerator + models.resnet.ResNetGenerator + models.SimCLR + models.simclr.SimCLR + models.MoCo + models.moco.MoCo + models.SimSiam + models.simsiam.SimSiam + models.ZOO + models.zoo.ZOO + models.checkpoints + models.zoo.checkpoints + models.batchnorm.get_norm_layer + + # transforms imports + from lightly import transforms + transforms.GaussianBlur + transforms.gaussian_blur.GaussianBlur + transforms.RandomRotate + transforms.rotation.RandomRotate + + # utils imports + from lightly import utils + utils.save_embeddings + utils.io.save_embeddings + utils.load_embeddings + utils.io.load_embeddings + utils.load_embeddings_as_dict + utils.io.load_embeddings_as_dict + utils.fit_pca + utils.embeddings_2d.fit_pca