diff --git a/config/datasets/detection-3d/lep_3d_dataset.yaml b/config/datasets/detection-3d/lep_3d_dataset.yaml index 54f5775b..164e53e3 100644 --- a/config/datasets/detection-3d/lep_3d_dataset.yaml +++ b/config/datasets/detection-3d/lep_3d_dataset.yaml @@ -11,15 +11,15 @@ _target_: innofw.core.integrations.mmdetection.datamodule.Mmdetection3DDataModul train: source: https://api.blackhole.ai.innopolis.university/public-datasets/lep_3d_detection/train.zip - target: /home/karim/workdir/innofw/data/lep3d + target: ./data/lep3d test: source: https://api.blackhole.ai.innopolis.university/public-datasets/lep_3d_detection/test.zip - target: /home/karim/workdir/innofw/data/lep3d + target: ./data/lep3d infer: source: https://api.blackhole.ai.innopolis.university/public-datasets/lep_3d_detection/test.zip - target: /home/karim/workdir/innofw/data/lep3d + target: ./data/lep3d num_workers: 8 diff --git a/innofw/core/integrations/mmdetection/datamodule.py b/innofw/core/integrations/mmdetection/datamodule.py index c4f382c8..d3050d1c 100644 --- a/innofw/core/integrations/mmdetection/datamodule.py +++ b/innofw/core/integrations/mmdetection/datamodule.py @@ -24,6 +24,7 @@ target_maxes = np.array([[136.7853946685791, 135.2938232421875, 45.29965019226074]]) target_mins = np.array([[-136.7853946685791, -135.2938232421875, -45.29965019226074]]) + class Mmdetection3DDataModuleAdapter(BaseDataModule, ABC): """ ... diff --git a/innofw/core/integrations/mmdetection/model_adapter.py b/innofw/core/integrations/mmdetection/model_adapter.py index 1e8300f2..91f453cd 100644 --- a/innofw/core/integrations/mmdetection/model_adapter.py +++ b/innofw/core/integrations/mmdetection/model_adapter.py @@ -126,8 +126,8 @@ def predict(self, data, ckpt_path=None): def setup_mmdetection(): - logging.info('mmdetection-3d found') if os.path.exists('../mmdetection3d'): + logging.info('mmdetection-3d found') os.environ['MMDET_FOR_INNOFW'] = os.path.join(Path(os.getcwd()).parent, 'mmdetection3d') if 'MMDET_FOR_INNOFW' not in os.environ: logging.info("Cloning mmdetection-3d") @@ -138,5 +138,6 @@ def setup_mmdetection(): return os.environ['MMDET_FOR_INNOFW'] + def map_optimizer_to_mmdet_optim(optim_name): - return {'adam': 'Adam', 'adamw': 'AdamW', 'sgd': 'SGD'}[optim_name] \ No newline at end of file + return {'adam': 'Adam', 'adamw': 'AdamW', 'sgd': 'SGD'}[optim_name] diff --git a/run_tests.sh b/run_tests.sh index b4efc69c..a8b6e9a2 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -1,4 +1,8 @@ #!/bin/bash +python -m pip install -U openmim +mim install mmengine +mim install 'mmcv>=2.0.0rc4' +mim install 'mmdet>=3.0.0' export PYTHONPATH=. python -m pytest --cov=innofw --cov-report=xml --junitxml=out_report.xml --cov-fail-under=10 # not percents if [ $? -ne 0 ]; then diff --git a/tests/fixtures/config/trainers.py b/tests/fixtures/config/trainers.py index 959dabeb..2d8f4f41 100644 --- a/tests/fixtures/config/trainers.py +++ b/tests/fixtures/config/trainers.py @@ -23,6 +23,9 @@ trainer_cfg_w_gpu_devices_1 = base_trainer_on_gpu_cfg.copy() trainer_cfg_w_gpu_devices_1["devices"] = 1 +trainer_cfg_w_gpu_devices_0 = base_trainer_on_gpu_cfg.copy() +trainer_cfg_w_gpu_devices_0["devices"] = 0 + # case: accelerator = 'gpu', devices = 2 # uses two gpu devices trainer_cfg_w_gpu_devices_2 = base_trainer_on_gpu_cfg.copy() trainer_cfg_w_gpu_devices_2["devices"] = 2 diff --git a/tests/integration/models/test_mmdetection3d.py b/tests/integration/models/test_mmdetection3d.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/integration/models/torch/lighting_modules/test_mmdetection3d.py b/tests/integration/models/torch/lighting_modules/test_mmdetection3d.py new file mode 100644 index 00000000..ae704654 --- /dev/null +++ b/tests/integration/models/torch/lighting_modules/test_mmdetection3d.py @@ -0,0 +1,39 @@ +import shutil + +from omegaconf import DictConfig + +from innofw.constants import Stages +from innofw.core.integrations.mmdetection.datamodule import Mmdetection3DDataModuleAdapter +from innofw.core.integrations.mmdetection.model_adapter import Mmdetection3DDataModel, \ + BaseMmdetModel +from tests.fixtures.config import optimizers as fixt_optimizers +from tests.fixtures.config import trainers as fixt_trainers + + +def test_integration(): + data_path = { + 'source': 'https://api.blackhole.ai.innopolis.university/public-datasets/lep_3d_detection/test.zip', + 'target': './tmp'} + datamodule = Mmdetection3DDataModuleAdapter(data_path, data_path, data_path, 4) + datamodule.setup_train_test_val() + datamodule.setup_infer() + assert datamodule.predict_dataloader() is None + assert datamodule.train_dataloader() is None + assert datamodule.test_dataloader() is None + assert datamodule.save_preds(None, Stages.test, '') is None + + optimizer_cfg = DictConfig(fixt_optimizers.adam_optim_w_target) + model = Mmdetection3DDataModel(BaseMmdetModel(), './tmp/logs', + fixt_trainers.trainer_cfg_w_gpu_devices_0, + optimizers_cfg=optimizer_cfg) + model.train(datamodule) + ckpt_path = model.mmdet_path + '/work_dirs/pointpillars_hv_secfpn_8xb6_custom/epoch_10.pth' + model.test(datamodule, ckpt_path=ckpt_path) + model.predict(datamodule, ckpt_path=ckpt_path) + + for i in range(3): + try: + shutil.rmtree('./tmp') + break + except: + pass