From d22295efbee253e29a8ff6c58e6cb57f44eccc6a Mon Sep 17 00:00:00 2001 From: Kushashwa Ravi Shrimali Date: Thu, 4 Aug 2022 08:24:56 +0530 Subject: [PATCH 01/29] Fix Flash CI: in case of converting functions to classes --- flash/core/utilities/lightning_cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flash/core/utilities/lightning_cli.py b/flash/core/utilities/lightning_cli.py index 99a5e11153..743d219737 100644 --- a/flash/core/utilities/lightning_cli.py +++ b/flash/core/utilities/lightning_cli.py @@ -97,7 +97,7 @@ def add_lightning_class_args( lightning_class = class_from_function(lightning_class) if inspect.isclass(lightning_class) and issubclass( - cast(type, lightning_class), (Trainer, LightningModule, LightningDataModule, Callback) + cast(type, lightning_class), (Trainer, LightningModule, LightningDataModule, Callback, ClassFromFunctionBase) ): if issubclass(cast(type, lightning_class), Callback): self.callback_keys.append(nested_key) From b7256200a45fd7e929bd8fd44e457f09af5ed8fd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 4 Aug 2022 02:56:55 +0000 Subject: [PATCH 02/29] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- flash/core/utilities/lightning_cli.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flash/core/utilities/lightning_cli.py b/flash/core/utilities/lightning_cli.py index 743d219737..ecfaf52589 100644 --- a/flash/core/utilities/lightning_cli.py +++ b/flash/core/utilities/lightning_cli.py @@ -97,7 +97,8 @@ def add_lightning_class_args( lightning_class = class_from_function(lightning_class) if inspect.isclass(lightning_class) and issubclass( - cast(type, lightning_class), (Trainer, LightningModule, LightningDataModule, Callback, ClassFromFunctionBase) + cast(type, lightning_class), + (Trainer, LightningModule, LightningDataModule, Callback, ClassFromFunctionBase), ): if issubclass(cast(type, lightning_class), Callback): self.callback_keys.append(nested_key) From 6d2c63603594ca02f03ea75eff238ee81ef34a78 Mon Sep 17 00:00:00 2001 From: Kushashwa Ravi Shrimali Date: Thu, 4 Aug 2022 09:31:08 +0530 Subject: [PATCH 03/29] Attach Trainer to model for jit tracing --- tests/helpers/task_tester.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/helpers/task_tester.py b/tests/helpers/task_tester.py index 8ee6797b17..aac4d37f9c 100644 --- a/tests/helpers/task_tester.py +++ b/tests/helpers/task_tester.py @@ -102,8 +102,10 @@ def _test_jit_trace(self, tmpdir): path = os.path.join(tmpdir, "test.pt") model = self.instantiated_task + trainer = self.instantiated_trainer model.eval() + model.trainer = trainer model = torch.jit.trace(model, self.example_forward_input) torch.jit.save(model, path) @@ -261,10 +263,17 @@ class TaskTester(metaclass=TaskTesterMeta): "test_cli": [pytest.mark.parametrize("extra_args", [[]])], } + trainer_args: Tuple = () + trainer_kwargs: Dict = {} + @property def instantiated_task(self): return self.task(*self.task_args, **self.task_kwargs) + @property + def instantiated_trainer(self): + return flash.Trainer(*self.trainer_args, **self.trainer_kwargs) + @property def example_forward_input(self): pass From 41fd8454e0c8bbd02ec3e936a819660751aa9993 Mon Sep 17 00:00:00 2001 From: Kushashwa Ravi Shrimali Date: Thu, 4 Aug 2022 11:05:10 +0530 Subject: [PATCH 04/29] on_<>_dataloader were deprecated, and were removed in v1.7 - remove --- flash/image/classification/integrations/baal/data.py | 2 +- flash/image/classification/integrations/baal/loop.py | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/flash/image/classification/integrations/baal/data.py b/flash/image/classification/integrations/baal/data.py index f427b13f60..f1ca83799d 100644 --- a/flash/image/classification/integrations/baal/data.py +++ b/flash/image/classification/integrations/baal/data.py @@ -180,7 +180,7 @@ def label(self, probabilities: List[Tensor] = None, indices=None): raise MisconfigurationException( "The `probabilities` and `indices` are mutually exclusive, pass only of one them." ) - if probabilities is not None: + if probabilities is not None and len(probabilities) != 0: probabilities = torch.cat([p[0].unsqueeze(0) for p in probabilities], dim=0) uncertainties = self.heuristic.get_uncertainties(probabilities) indices = np.argsort(uncertainties) diff --git a/flash/image/classification/integrations/baal/loop.py b/flash/image/classification/integrations/baal/loop.py index 2a1142a011..c9deb9a0ed 100644 --- a/flash/image/classification/integrations/baal/loop.py +++ b/flash/image/classification/integrations/baal/loop.py @@ -165,21 +165,18 @@ def _connect(self, model: LightningModule): def _reset_fitting(self): self.trainer.state.fn = TrainerFn.FITTING self.trainer.training = True - self.trainer.lightning_module.on_train_dataloader() self._connect(self._lightning_module) self.fit_loop.epoch_progress = Progress() def _reset_predicting(self): self.trainer.state.fn = TrainerFn.PREDICTING self.trainer.predicting = True - self.trainer.lightning_module.on_predict_dataloader() self._connect(self.inference_model) def _reset_testing(self): self.trainer.state.fn = TrainerFn.TESTING self.trainer.state.status = TrainerStatus.RUNNING self.trainer.testing = True - self.trainer.lightning_module.on_test_dataloader() self._connect(self._lightning_module) def _reset_dataloader_for_stage(self, running_state: RunningStage): From df9f48bba61a8e7551c96d2581a8600f85cc7833 Mon Sep 17 00:00:00 2001 From: Kushashwa Ravi Shrimali Date: Thu, 4 Aug 2022 11:15:06 +0530 Subject: [PATCH 05/29] Fix jit_script test --- tests/helpers/task_tester.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/helpers/task_tester.py b/tests/helpers/task_tester.py index aac4d37f9c..9e0026007e 100644 --- a/tests/helpers/task_tester.py +++ b/tests/helpers/task_tester.py @@ -119,8 +119,10 @@ def _test_jit_script(self, tmpdir): path = os.path.join(tmpdir, "test.pt") model = self.instantiated_task + trainer = self.instantiated_trainer model.eval() + model.trainer = trainer model = torch.jit.script(model) torch.jit.save(model, path) From 4c8c0fb517119d1411a7d40abe73acb0bdfe7d0e Mon Sep 17 00:00:00 2001 From: rohitgr7 Date: Mon, 8 Aug 2022 14:54:53 +0530 Subject: [PATCH 06/29] fix --- flash/image/classification/integrations/baal/loop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flash/image/classification/integrations/baal/loop.py b/flash/image/classification/integrations/baal/loop.py index c9deb9a0ed..15c0615f21 100644 --- a/flash/image/classification/integrations/baal/loop.py +++ b/flash/image/classification/integrations/baal/loop.py @@ -91,7 +91,7 @@ def on_run_start(self, *args: Any, **kwargs: Any) -> None: assert isinstance(self.trainer.datamodule, ActiveLearningDataModule) if self._datamodule_state_dict is not None: self.trainer.datamodule.load_state_dict(self._datamodule_state_dict) - self.trainer.predict_loop._return_predictions = True + self.trainer.predict_loop.return_predictions = True self._lightning_module = self.trainer.lightning_module self._model_state_dict = deepcopy(self._lightning_module.state_dict()) self.inference_model = InferenceMCDropoutTask(self._lightning_module, self.inference_iteration) From 76764e71c4a1df2549207c6ceddfb2abaf08d279 Mon Sep 17 00:00:00 2001 From: Kushashwa Ravi Shrimali Date: Wed, 10 Aug 2022 09:16:54 +0530 Subject: [PATCH 07/29] Try upgrading torchtext to 0.13.1 to support latest pytorch --- requirements/datatype_text.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements/datatype_text.txt b/requirements/datatype_text.txt index 1c1c18535f..52807e213b 100644 --- a/requirements/datatype_text.txt +++ b/requirements/datatype_text.txt @@ -4,3 +4,4 @@ transformers>=4.5 torchmetrics[text]>=0.5.1 datasets>=1.8 sentence-transformers +torchtext==0.13.1 \ No newline at end of file From 05c15ba6db1736fbe787c5b0401935f27a9fba8d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 10 Aug 2022 03:47:37 +0000 Subject: [PATCH 08/29] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- requirements/datatype_text.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/datatype_text.txt b/requirements/datatype_text.txt index 52807e213b..086d34b851 100644 --- a/requirements/datatype_text.txt +++ b/requirements/datatype_text.txt @@ -4,4 +4,4 @@ transformers>=4.5 torchmetrics[text]>=0.5.1 datasets>=1.8 sentence-transformers -torchtext==0.13.1 \ No newline at end of file +torchtext==0.13.1 From 2fc3d828e60bc1e30828e0934fd990e50cd66b73 Mon Sep 17 00:00:00 2001 From: Kushashwa Ravi Shrimali Date: Wed, 10 Aug 2022 09:22:06 +0530 Subject: [PATCH 09/29] Update requirements/datatype_text.txt --- requirements/datatype_text.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements/datatype_text.txt b/requirements/datatype_text.txt index 086d34b851..1c1c18535f 100644 --- a/requirements/datatype_text.txt +++ b/requirements/datatype_text.txt @@ -4,4 +4,3 @@ transformers>=4.5 torchmetrics[text]>=0.5.1 datasets>=1.8 sentence-transformers -torchtext==0.13.1 From 18e714430e4ae72036423772c41b515d057ec401 Mon Sep 17 00:00:00 2001 From: Kushashwa Ravi Shrimali Date: Wed, 10 Aug 2022 11:56:24 +0530 Subject: [PATCH 10/29] dont allow 1.7.0 until issues are fixed --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 6230dcff95..02c60a621b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,7 @@ setuptools<=59.5.0 # Prevent install bug with tensorboard numpy torch>=1.7.1 torchmetrics>=0.5.0,!=0.5.1 -pytorch-lightning>=1.3.6 +pytorch-lightning>=1.3.6, <=1.6.5 pyDeprecate pandas>=1.1.0 jsonargparse[signatures]>=3.17.0, <=4.9.0 From 74e73459d703df0dec6e79957bbc1a8ad2a0c129 Mon Sep 17 00:00:00 2001 From: Kushashwa Ravi Shrimali Date: Wed, 10 Aug 2022 15:15:20 +0530 Subject: [PATCH 11/29] Requirements: go back to PL 1.7 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 02c60a621b..6230dcff95 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,7 @@ setuptools<=59.5.0 # Prevent install bug with tensorboard numpy torch>=1.7.1 torchmetrics>=0.5.0,!=0.5.1 -pytorch-lightning>=1.3.6, <=1.6.5 +pytorch-lightning>=1.3.6 pyDeprecate pandas>=1.1.0 jsonargparse[signatures]>=3.17.0, <=4.9.0 From f04a274ce069b5b2dacfd2e14876c59a93f1b3ab Mon Sep 17 00:00:00 2001 From: Kushashwa Ravi Shrimali Date: Wed, 10 Aug 2022 15:30:31 +0530 Subject: [PATCH 12/29] CI Fix: manually setattr for collate_fn after DataLoader is initialized --- flash/core/integrations/icevision/adapter.py | 21 +++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/flash/core/integrations/icevision/adapter.py b/flash/core/integrations/icevision/adapter.py index fc2a43ad03..9ece3a5cfa 100644 --- a/flash/core/integrations/icevision/adapter.py +++ b/flash/core/integrations/icevision/adapter.py @@ -110,6 +110,17 @@ def _wrap_collate_fn(collate_fn, samples): DataKeys.METADATA: metadata, } + def change_collate_fn_dataloader(self, data_loader): + # Starting PL 1.7.0 - changing attributes after the DataLoader is initialized - will not work + # So we manually set the collate_fn to the wrapped version, for now. + new_kwargs = getattr(data_loader, "__pl_saved_kwargs", None) + new_collate_fn = functools.partial(self._wrap_collate_fn, data_loader.collate_fn) + if new_kwargs: + new_kwargs["collate_fn"] = new_collate_fn + setattr(data_loader, "__pl_saved_kwargs", new_kwargs) + data_loader.collate_fn = new_collate_fn + return data_loader + def process_train_dataset( self, dataset: InputBase, @@ -134,7 +145,7 @@ def process_train_dataset( persistent_workers=persistent_workers, ) - data_loader.collate_fn = functools.partial(self._wrap_collate_fn, data_loader.collate_fn) + data_loader = self.change_collate_fn_dataloader(data_loader) input_transform = input_transform or self.input_transform if input_transform is not None: @@ -166,7 +177,7 @@ def process_val_dataset( persistent_workers=persistent_workers, ) - data_loader.collate_fn = functools.partial(self._wrap_collate_fn, data_loader.collate_fn) + data_loader = self.change_collate_fn_dataloader(data_loader) input_transform = input_transform or self.input_transform if input_transform is not None: @@ -198,7 +209,7 @@ def process_test_dataset( persistent_workers=persistent_workers, ) - data_loader.collate_fn = functools.partial(self._wrap_collate_fn, data_loader.collate_fn) + data_loader = self.change_collate_fn_dataloader(data_loader) input_transform = input_transform or self.input_transform if input_transform is not None: @@ -230,13 +241,13 @@ def process_predict_dataset( persistent_workers=persistent_workers, ) - data_loader.collate_fn = functools.partial(self._wrap_collate_fn, data_loader.collate_fn) + data_loader = self.change_collate_fn_dataloader(data_loader) input_transform = input_transform or self.input_transform if input_transform is not None: input_transform.inject_collate_fn(data_loader.collate_fn) data_loader.collate_fn = create_worker_input_transform_processor(RunningStage.PREDICTING, input_transform) - return data_loader + return data_loader def training_step(self, batch, batch_idx) -> Any: return self.icevision_adapter.training_step(batch[DataKeys.INPUT], batch_idx) From cdbaefdc1572c67a3abeba282c976160759f23a3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 10 Aug 2022 10:01:19 +0000 Subject: [PATCH 13/29] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- flash/core/integrations/icevision/adapter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flash/core/integrations/icevision/adapter.py b/flash/core/integrations/icevision/adapter.py index 9ece3a5cfa..5c226be46e 100644 --- a/flash/core/integrations/icevision/adapter.py +++ b/flash/core/integrations/icevision/adapter.py @@ -247,7 +247,7 @@ def process_predict_dataset( if input_transform is not None: input_transform.inject_collate_fn(data_loader.collate_fn) data_loader.collate_fn = create_worker_input_transform_processor(RunningStage.PREDICTING, input_transform) - return data_loader + return data_loader def training_step(self, batch, batch_idx) -> Any: return self.icevision_adapter.training_step(batch[DataKeys.INPUT], batch_idx) From b410d316f2dd21764574c9c8df37cee8d85b868d Mon Sep 17 00:00:00 2001 From: Kushashwa Ravi Shrimali Date: Fri, 12 Aug 2022 09:50:34 +0530 Subject: [PATCH 14/29] install effdet from latest commit hash, fix object_detection --- .github/workflows/ci-testing.yml | 2 +- flash/core/utilities/imports.py | 2 +- requirements/datatype_effdet.txt | 1 + requirements/datatype_image_extras.txt | 1 - 4 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 requirements/datatype_effdet.txt diff --git a/.github/workflows/ci-testing.yml b/.github/workflows/ci-testing.yml index 46e1870aae..ea991862e3 100644 --- a/.github/workflows/ci-testing.yml +++ b/.github/workflows/ci-testing.yml @@ -32,7 +32,7 @@ jobs: include: - { os: 'ubuntu-20.04', python-version: 3.9, requires: 'latest', release: 'pre', topic: [ 'core' ] } - { os: 'ubuntu-20.04', python-version: 3.9, requires: 'latest', release: 'stable', topic: [ 'image' ] } - - { os: 'ubuntu-20.04', python-version: 3.9, requires: 'latest', release: 'stable', topic: [ 'image','image_extras' ] } + - { os: 'ubuntu-20.04', python-version: 3.9, requires: 'latest', release: 'stable', topic: [ 'image','image_extras','effdet' ] } - { os: 'ubuntu-20.04', python-version: 3.9, requires: 'latest', release: 'stable', topic: [ 'image','image_extras_baal' ] } - { os: 'ubuntu-20.04', python-version: 3.9, requires: 'latest', release: 'stable', topic: [ 'video' ] } - { os: 'ubuntu-20.04', python-version: 3.9, requires: 'latest', release: 'stable', topic: [ 'video','video_extras' ] } diff --git a/flash/core/utilities/imports.py b/flash/core/utilities/imports.py index ce48639b71..d58d1b9c43 100644 --- a/flash/core/utilities/imports.py +++ b/flash/core/utilities/imports.py @@ -301,7 +301,7 @@ def _import_module(self): topic = os.environ["FLASH_TEST_TOPIC"] _CORE_TESTING = topic == "core" _IMAGE_TESTING = topic == "image" - _IMAGE_EXTRAS_TESTING = topic == "image,image_extras" or topic == "icevision" or topic == "vissl" + _IMAGE_EXTRAS_TESTING = topic == "image,image_extras,effdet" or topic == "icevision" or topic == "vissl" _VIDEO_TESTING = topic == "video" _VIDEO_EXTRAS_TESTING = topic == "video,video_extras" _TABULAR_TESTING = topic == "tabular" diff --git a/requirements/datatype_effdet.txt b/requirements/datatype_effdet.txt new file mode 100644 index 0000000000..d176f4a150 --- /dev/null +++ b/requirements/datatype_effdet.txt @@ -0,0 +1 @@ +git+https://github.com/rwightman/efficientdet-pytorch.git@79d26d8982b9f8e1f27d9f896e38012ac250fd26 diff --git a/requirements/datatype_image_extras.txt b/requirements/datatype_image_extras.txt index ed1c2f386f..1538709895 100644 --- a/requirements/datatype_image_extras.txt +++ b/requirements/datatype_image_extras.txt @@ -4,7 +4,6 @@ classy_vision vissl>=0.1.5 icevision>=0.8 icedata -effdet albumentations learn2learn fastface From a8f57ad43c0376a1c1a6bf7d8cac0c410497d3fe Mon Sep 17 00:00:00 2001 From: Kushashwa Ravi Shrimali Date: Fri, 12 Aug 2022 10:20:17 +0530 Subject: [PATCH 15/29] Force install effdet 0.3.0 --- .github/workflows/ci-testing.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-testing.yml b/.github/workflows/ci-testing.yml index ea991862e3..2a63201a85 100644 --- a/.github/workflows/ci-testing.yml +++ b/.github/workflows/ci-testing.yml @@ -128,7 +128,8 @@ jobs: if: contains( matrix.topic , 'serve' ) run: | sudo apt-get install libsndfile1 - pip install '.[all,audio]' icevision effdet --upgrade + pip install '.[all,audio]' icevision --upgrade + pip install -e git+https://github.com/rwightman/efficientdet-pytorch.git@79d26d8982b9f8e1f27d9f896e38012ac250fd26#egg=effdet - name: Install audio test dependencies if: contains( matrix.topic , 'audio' ) From 598d97813ac6291580c10c0db4c879c8306651da Mon Sep 17 00:00:00 2001 From: Kushashwa Ravi Shrimali Date: Fri, 12 Aug 2022 10:27:32 +0530 Subject: [PATCH 16/29] Remove dataloader_idx from on_train_batch_end hooks --- flash/image/embedding/model.py | 4 ++-- flash/image/embedding/vissl/hooks.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/flash/image/embedding/model.py b/flash/image/embedding/model.py index 5b19a69d95..9f13079c7f 100644 --- a/flash/image/embedding/model.py +++ b/flash/image/embedding/model.py @@ -154,8 +154,8 @@ def on_train_start(self) -> None: def on_train_epoch_end(self) -> None: self.adapter.on_train_epoch_end() - def on_train_batch_end(self, outputs: Any, batch: Any, batch_idx: int, dataloader_idx: int) -> None: - self.adapter.on_train_batch_end(outputs, batch, batch_idx, dataloader_idx) + def on_train_batch_end(self, outputs: Any, batch: Any, batch_idx: int) -> None: + self.adapter.on_train_batch_end(outputs, batch, batch_idx) @classmethod @requires("image", "vissl", "fairscale") diff --git a/flash/image/embedding/vissl/hooks.py b/flash/image/embedding/vissl/hooks.py index 9176883f59..cb082c1e91 100644 --- a/flash/image/embedding/vissl/hooks.py +++ b/flash/image/embedding/vissl/hooks.py @@ -96,7 +96,7 @@ def on_train_start(self) -> None: for hook in self.hooks: hook.on_start(self.task) - def on_train_batch_end(self, outputs: Any, batch: Any, batch_idx: int, dataloader_idx: int) -> None: + def on_train_batch_end(self, outputs: Any, batch: Any, batch_idx: int) -> None: self.task.iteration += 1 def on_train_epoch_end(self) -> None: From 02826a36792830f550edb20a5040d88fcaf0b60b Mon Sep 17 00:00:00 2001 From: Kushashwa Ravi Shrimali Date: Fri, 12 Aug 2022 12:14:52 +0530 Subject: [PATCH 17/29] rename, attempt to support previous PL versions --- .azure-pipelines/testing-template.yml | 3 ++- .github/workflows/ci-testing.yml | 3 ++- flash/core/utilities/imports.py | 2 +- flash/image/embedding/model.py | 4 ++-- flash/image/embedding/vissl/hooks.py | 2 +- requirements/datatype_effdet.txt | 1 - 6 files changed, 8 insertions(+), 7 deletions(-) delete mode 100644 requirements/datatype_effdet.txt diff --git a/.azure-pipelines/testing-template.yml b/.azure-pipelines/testing-template.yml index 6c69b810f5..11dc3c6c9e 100644 --- a/.azure-pipelines/testing-template.yml +++ b/.azure-pipelines/testing-template.yml @@ -36,7 +36,8 @@ jobs: - bash: | # python -m pip install "pip==20.1" - if [ "${{config}}" == "icevision" ]; then pip install '.[image]' icevision effdet icedata; elif [ "${{config}}" == "vissl" ]; then pip install '.[image]'; else pip install '.[${{config}}]'; fi + if [ "${{config}}" == "icevision" ]; then pip install '.[image]' icevision icedata elif [ "${{config}}" == "vissl" ]; then pip install '.[image]'; else pip install '.[${{config}}]'; fi + if [ "${{config}}" == "icevision" ]; then pip install git+https://github.com/rwightman/efficientdet-pytorch.git@79d26d8982b9f8e1f27d9f896e38012ac250fd26; fi pip install '.[test]' --upgrade-strategy only-if-needed pip list displayName: 'Install dependencies' diff --git a/.github/workflows/ci-testing.yml b/.github/workflows/ci-testing.yml index 2a63201a85..011b5bca28 100644 --- a/.github/workflows/ci-testing.yml +++ b/.github/workflows/ci-testing.yml @@ -32,7 +32,8 @@ jobs: include: - { os: 'ubuntu-20.04', python-version: 3.9, requires: 'latest', release: 'pre', topic: [ 'core' ] } - { os: 'ubuntu-20.04', python-version: 3.9, requires: 'latest', release: 'stable', topic: [ 'image' ] } - - { os: 'ubuntu-20.04', python-version: 3.9, requires: 'latest', release: 'stable', topic: [ 'image','image_extras','effdet' ] } + - { os: 'ubuntu-20.04', python-version: 3.9, requires: 'latest', release: 'stable', topic: [ 'image','image_extras' ] } + - { os: 'ubuntu-20.04', python-version: 3.9, requires: 'latest', release: 'stable', topic: [ 'image','image_extras_effdet' ] } - { os: 'ubuntu-20.04', python-version: 3.9, requires: 'latest', release: 'stable', topic: [ 'image','image_extras_baal' ] } - { os: 'ubuntu-20.04', python-version: 3.9, requires: 'latest', release: 'stable', topic: [ 'video' ] } - { os: 'ubuntu-20.04', python-version: 3.9, requires: 'latest', release: 'stable', topic: [ 'video','video_extras' ] } diff --git a/flash/core/utilities/imports.py b/flash/core/utilities/imports.py index d58d1b9c43..5a6324a6a1 100644 --- a/flash/core/utilities/imports.py +++ b/flash/core/utilities/imports.py @@ -301,7 +301,7 @@ def _import_module(self): topic = os.environ["FLASH_TEST_TOPIC"] _CORE_TESTING = topic == "core" _IMAGE_TESTING = topic == "image" - _IMAGE_EXTRAS_TESTING = topic == "image,image_extras,effdet" or topic == "icevision" or topic == "vissl" + _IMAGE_EXTRAS_TESTING = topic == "image,image_extras,image_extras_effdet" or topic == "icevision" or topic == "vissl" _VIDEO_TESTING = topic == "video" _VIDEO_EXTRAS_TESTING = topic == "video,video_extras" _TABULAR_TESTING = topic == "tabular" diff --git a/flash/image/embedding/model.py b/flash/image/embedding/model.py index 9f13079c7f..cc2ee0203b 100644 --- a/flash/image/embedding/model.py +++ b/flash/image/embedding/model.py @@ -154,8 +154,8 @@ def on_train_start(self) -> None: def on_train_epoch_end(self) -> None: self.adapter.on_train_epoch_end() - def on_train_batch_end(self, outputs: Any, batch: Any, batch_idx: int) -> None: - self.adapter.on_train_batch_end(outputs, batch, batch_idx) + def on_train_batch_end(self, outputs: Any, batch: Any, batch_idx: int, *args) -> None: + self.adapter.on_train_batch_end(outputs, batch, batch_idx, *args) @classmethod @requires("image", "vissl", "fairscale") diff --git a/flash/image/embedding/vissl/hooks.py b/flash/image/embedding/vissl/hooks.py index cb082c1e91..e8ecd801a9 100644 --- a/flash/image/embedding/vissl/hooks.py +++ b/flash/image/embedding/vissl/hooks.py @@ -96,7 +96,7 @@ def on_train_start(self) -> None: for hook in self.hooks: hook.on_start(self.task) - def on_train_batch_end(self, outputs: Any, batch: Any, batch_idx: int) -> None: + def on_train_batch_end(self, outputs: Any, batch: Any, batch_idx: int, *args) -> None: self.task.iteration += 1 def on_train_epoch_end(self) -> None: diff --git a/requirements/datatype_effdet.txt b/requirements/datatype_effdet.txt deleted file mode 100644 index d176f4a150..0000000000 --- a/requirements/datatype_effdet.txt +++ /dev/null @@ -1 +0,0 @@ -git+https://github.com/rwightman/efficientdet-pytorch.git@79d26d8982b9f8e1f27d9f896e38012ac250fd26 From cf1d6e9455a9eaee19e8155773a161ab4dde13c4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 12 Aug 2022 06:46:25 +0000 Subject: [PATCH 18/29] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- flash/core/utilities/imports.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/flash/core/utilities/imports.py b/flash/core/utilities/imports.py index 5a6324a6a1..a493492865 100644 --- a/flash/core/utilities/imports.py +++ b/flash/core/utilities/imports.py @@ -301,7 +301,9 @@ def _import_module(self): topic = os.environ["FLASH_TEST_TOPIC"] _CORE_TESTING = topic == "core" _IMAGE_TESTING = topic == "image" - _IMAGE_EXTRAS_TESTING = topic == "image,image_extras,image_extras_effdet" or topic == "icevision" or topic == "vissl" + _IMAGE_EXTRAS_TESTING = ( + topic == "image,image_extras,image_extras_effdet" or topic == "icevision" or topic == "vissl" + ) _VIDEO_TESTING = topic == "video" _VIDEO_EXTRAS_TESTING = topic == "video,video_extras" _TABULAR_TESTING = topic == "tabular" From ea2679ebbde58f771da0f547396941179b113db6 Mon Sep 17 00:00:00 2001 From: Kushashwa Ravi Shrimali Date: Fri, 12 Aug 2022 12:44:14 +0530 Subject: [PATCH 19/29] syntax error fix --- .azure-pipelines/testing-template.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/testing-template.yml b/.azure-pipelines/testing-template.yml index 11dc3c6c9e..ca25b7f61b 100644 --- a/.azure-pipelines/testing-template.yml +++ b/.azure-pipelines/testing-template.yml @@ -36,7 +36,7 @@ jobs: - bash: | # python -m pip install "pip==20.1" - if [ "${{config}}" == "icevision" ]; then pip install '.[image]' icevision icedata elif [ "${{config}}" == "vissl" ]; then pip install '.[image]'; else pip install '.[${{config}}]'; fi + if [ "${{config}}" == "icevision" ]; then pip install '.[image]' icevision icedata; elif [ "${{config}}" == "vissl" ]; then pip install '.[image]'; else pip install '.[${{config}}]'; fi if [ "${{config}}" == "icevision" ]; then pip install git+https://github.com/rwightman/efficientdet-pytorch.git@79d26d8982b9f8e1f27d9f896e38012ac250fd26; fi pip install '.[test]' --upgrade-strategy only-if-needed pip list From 4241ac90565466e6ac39188698c842c4b4bc9284 Mon Sep 17 00:00:00 2001 From: Kushashwa Ravi Shrimali Date: Fri, 12 Aug 2022 15:39:46 +0530 Subject: [PATCH 20/29] Fix updating collate fn if input_transform is not None (icevision) --- flash/core/integrations/icevision/adapter.py | 23 ++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/flash/core/integrations/icevision/adapter.py b/flash/core/integrations/icevision/adapter.py index 5c226be46e..5a7a3f2c72 100644 --- a/flash/core/integrations/icevision/adapter.py +++ b/flash/core/integrations/icevision/adapter.py @@ -121,6 +121,17 @@ def change_collate_fn_dataloader(self, data_loader): data_loader.collate_fn = new_collate_fn return data_loader + def update_collate_fn_dataloader(self, new_collate_fn, data_loader): + # Starting PL 1.7.0 - changing attributes after the DataLoader is initialized - will not work + # So we manually update the collate_fn for the dataloader, for now. + new_kwargs = getattr(data_loader, "__pl_saved_kwargs", None) + if new_kwargs: + new_kwargs["collate_fn"] = new_collate_fn + setattr(data_loader, "__pl_saved_kwargs", new_kwargs) + data_loader.collate_fn = new_collate_fn + return data_loader + + def process_train_dataset( self, dataset: InputBase, @@ -150,7 +161,8 @@ def process_train_dataset( input_transform = input_transform or self.input_transform if input_transform is not None: input_transform.inject_collate_fn(data_loader.collate_fn) - data_loader.collate_fn = create_worker_input_transform_processor(RunningStage.TRAINING, input_transform) + new_collate_fn = create_worker_input_transform_processor(RunningStage.TRAINING, input_transform) + data_loader = self.update_collate_fn_dataloader(new_collate_fn, data_loader) return data_loader def process_val_dataset( @@ -182,7 +194,8 @@ def process_val_dataset( input_transform = input_transform or self.input_transform if input_transform is not None: input_transform.inject_collate_fn(data_loader.collate_fn) - data_loader.collate_fn = create_worker_input_transform_processor(RunningStage.VALIDATING, input_transform) + new_collate_fn = create_worker_input_transform_processor(RunningStage.VALIDATING, input_transform) + data_loader = self.update_collate_fn_dataloader(new_collate_fn, data_loader) return data_loader def process_test_dataset( @@ -214,7 +227,8 @@ def process_test_dataset( input_transform = input_transform or self.input_transform if input_transform is not None: input_transform.inject_collate_fn(data_loader.collate_fn) - data_loader.collate_fn = create_worker_input_transform_processor(RunningStage.TESTING, input_transform) + new_collate_fn = create_worker_input_transform_processor(RunningStage.TESTING, input_transform) + data_loader = self.update_collate_fn_dataloader(new_collate_fn, data_loader) return data_loader def process_predict_dataset( @@ -246,7 +260,8 @@ def process_predict_dataset( input_transform = input_transform or self.input_transform if input_transform is not None: input_transform.inject_collate_fn(data_loader.collate_fn) - data_loader.collate_fn = create_worker_input_transform_processor(RunningStage.PREDICTING, input_transform) + new_collate_fn = create_worker_input_transform_processor(RunningStage.PREDICTING, input_transform) + data_loader = self.update_collate_fn_dataloader(new_collate_fn, data_loader) return data_loader def training_step(self, batch, batch_idx) -> Any: From 802ab2b0ca41b5215edb1234c777b811e835ca01 Mon Sep 17 00:00:00 2001 From: Kushashwa Ravi Shrimali Date: Fri, 12 Aug 2022 15:42:09 +0530 Subject: [PATCH 21/29] pep8 fix --- flash/core/integrations/icevision/adapter.py | 1 - 1 file changed, 1 deletion(-) diff --git a/flash/core/integrations/icevision/adapter.py b/flash/core/integrations/icevision/adapter.py index 5a7a3f2c72..0afe84f626 100644 --- a/flash/core/integrations/icevision/adapter.py +++ b/flash/core/integrations/icevision/adapter.py @@ -131,7 +131,6 @@ def update_collate_fn_dataloader(self, new_collate_fn, data_loader): data_loader.collate_fn = new_collate_fn return data_loader - def process_train_dataset( self, dataset: InputBase, From 23de0a4095bf58411ee56917b5b16bcbe0fad1b7 Mon Sep 17 00:00:00 2001 From: Kushashwa Ravi Shrimali Date: Fri, 12 Aug 2022 16:47:12 +0530 Subject: [PATCH 22/29] Revert effdet changes, address reviews --- .github/workflows/ci-testing.yml | 4 +-- flash/core/integrations/icevision/adapter.py | 33 ++++++++------------ flash/core/utilities/imports.py | 2 +- requirements/datatype_image_extras.txt | 3 ++ 4 files changed, 18 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci-testing.yml b/.github/workflows/ci-testing.yml index 011b5bca28..f51790cbea 100644 --- a/.github/workflows/ci-testing.yml +++ b/.github/workflows/ci-testing.yml @@ -33,7 +33,6 @@ jobs: - { os: 'ubuntu-20.04', python-version: 3.9, requires: 'latest', release: 'pre', topic: [ 'core' ] } - { os: 'ubuntu-20.04', python-version: 3.9, requires: 'latest', release: 'stable', topic: [ 'image' ] } - { os: 'ubuntu-20.04', python-version: 3.9, requires: 'latest', release: 'stable', topic: [ 'image','image_extras' ] } - - { os: 'ubuntu-20.04', python-version: 3.9, requires: 'latest', release: 'stable', topic: [ 'image','image_extras_effdet' ] } - { os: 'ubuntu-20.04', python-version: 3.9, requires: 'latest', release: 'stable', topic: [ 'image','image_extras_baal' ] } - { os: 'ubuntu-20.04', python-version: 3.9, requires: 'latest', release: 'stable', topic: [ 'video' ] } - { os: 'ubuntu-20.04', python-version: 3.9, requires: 'latest', release: 'stable', topic: [ 'video','video_extras' ] } @@ -129,8 +128,7 @@ jobs: if: contains( matrix.topic , 'serve' ) run: | sudo apt-get install libsndfile1 - pip install '.[all,audio]' icevision --upgrade - pip install -e git+https://github.com/rwightman/efficientdet-pytorch.git@79d26d8982b9f8e1f27d9f896e38012ac250fd26#egg=effdet + pip install '.[all,audio]' effdet icevision --upgrade - name: Install audio test dependencies if: contains( matrix.topic , 'audio' ) diff --git a/flash/core/integrations/icevision/adapter.py b/flash/core/integrations/icevision/adapter.py index 0afe84f626..f21726af71 100644 --- a/flash/core/integrations/icevision/adapter.py +++ b/flash/core/integrations/icevision/adapter.py @@ -110,18 +110,7 @@ def _wrap_collate_fn(collate_fn, samples): DataKeys.METADATA: metadata, } - def change_collate_fn_dataloader(self, data_loader): - # Starting PL 1.7.0 - changing attributes after the DataLoader is initialized - will not work - # So we manually set the collate_fn to the wrapped version, for now. - new_kwargs = getattr(data_loader, "__pl_saved_kwargs", None) - new_collate_fn = functools.partial(self._wrap_collate_fn, data_loader.collate_fn) - if new_kwargs: - new_kwargs["collate_fn"] = new_collate_fn - setattr(data_loader, "__pl_saved_kwargs", new_kwargs) - data_loader.collate_fn = new_collate_fn - return data_loader - - def update_collate_fn_dataloader(self, new_collate_fn, data_loader): + def _update_collate_fn_dataloader(self, new_collate_fn, data_loader): # Starting PL 1.7.0 - changing attributes after the DataLoader is initialized - will not work # So we manually update the collate_fn for the dataloader, for now. new_kwargs = getattr(data_loader, "__pl_saved_kwargs", None) @@ -155,13 +144,14 @@ def process_train_dataset( persistent_workers=persistent_workers, ) - data_loader = self.change_collate_fn_dataloader(data_loader) + new_collate_fn = functools.partial(self._wrap_collate_fn, data_loader.collate_fn) + data_loader = self._update_collate_fn_dataloader(new_collate_fn, data_loader) input_transform = input_transform or self.input_transform if input_transform is not None: input_transform.inject_collate_fn(data_loader.collate_fn) new_collate_fn = create_worker_input_transform_processor(RunningStage.TRAINING, input_transform) - data_loader = self.update_collate_fn_dataloader(new_collate_fn, data_loader) + data_loader = self._update_collate_fn_dataloader(new_collate_fn, data_loader) return data_loader def process_val_dataset( @@ -188,13 +178,14 @@ def process_val_dataset( persistent_workers=persistent_workers, ) - data_loader = self.change_collate_fn_dataloader(data_loader) + new_collate_fn = functools.partial(self._wrap_collate_fn, data_loader.collate_fn) + data_loader = self._update_collate_fn_dataloader(new_collate_fn, data_loader) input_transform = input_transform or self.input_transform if input_transform is not None: input_transform.inject_collate_fn(data_loader.collate_fn) new_collate_fn = create_worker_input_transform_processor(RunningStage.VALIDATING, input_transform) - data_loader = self.update_collate_fn_dataloader(new_collate_fn, data_loader) + data_loader = self._update_collate_fn_dataloader(new_collate_fn, data_loader) return data_loader def process_test_dataset( @@ -221,13 +212,14 @@ def process_test_dataset( persistent_workers=persistent_workers, ) - data_loader = self.change_collate_fn_dataloader(data_loader) + new_collate_fn = functools.partial(self._wrap_collate_fn, data_loader.collate_fn) + data_loader = self._update_collate_fn_dataloader(new_collate_fn, data_loader) input_transform = input_transform or self.input_transform if input_transform is not None: input_transform.inject_collate_fn(data_loader.collate_fn) new_collate_fn = create_worker_input_transform_processor(RunningStage.TESTING, input_transform) - data_loader = self.update_collate_fn_dataloader(new_collate_fn, data_loader) + data_loader = self._update_collate_fn_dataloader(new_collate_fn, data_loader) return data_loader def process_predict_dataset( @@ -254,13 +246,14 @@ def process_predict_dataset( persistent_workers=persistent_workers, ) - data_loader = self.change_collate_fn_dataloader(data_loader) + new_collate_fn = functools.partial(self._wrap_collate_fn, data_loader.collate_fn) + data_loader = self._update_collate_fn_dataloader(new_collate_fn, data_loader) input_transform = input_transform or self.input_transform if input_transform is not None: input_transform.inject_collate_fn(data_loader.collate_fn) new_collate_fn = create_worker_input_transform_processor(RunningStage.PREDICTING, input_transform) - data_loader = self.update_collate_fn_dataloader(new_collate_fn, data_loader) + data_loader = self._update_collate_fn_dataloader(new_collate_fn, data_loader) return data_loader def training_step(self, batch, batch_idx) -> Any: diff --git a/flash/core/utilities/imports.py b/flash/core/utilities/imports.py index a493492865..92e1754598 100644 --- a/flash/core/utilities/imports.py +++ b/flash/core/utilities/imports.py @@ -302,7 +302,7 @@ def _import_module(self): _CORE_TESTING = topic == "core" _IMAGE_TESTING = topic == "image" _IMAGE_EXTRAS_TESTING = ( - topic == "image,image_extras,image_extras_effdet" or topic == "icevision" or topic == "vissl" + topic == "image,image_extras" or topic == "icevision" or topic == "vissl" ) _VIDEO_TESTING = topic == "video" _VIDEO_EXTRAS_TESTING = topic == "video,video_extras" diff --git a/requirements/datatype_image_extras.txt b/requirements/datatype_image_extras.txt index 1538709895..34fed43bee 100644 --- a/requirements/datatype_image_extras.txt +++ b/requirements/datatype_image_extras.txt @@ -4,6 +4,7 @@ classy_vision vissl>=0.1.5 icevision>=0.8 icedata +effdet albumentations learn2learn fastface @@ -12,3 +13,5 @@ fairscale # pin PL for testing, remove when fastface is updated pytorch-lightning<1.5.0 torchmetrics<0.8.0 # pinned PL so we force a compatible TM version +# effdet had an issue with PL 1.12, and icevision doesn't support effdet's latest version yet (0.3.0) +torch<1.12 From f609ef634bec80a1bbf53f60255deb2568e889b8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 12 Aug 2022 11:18:02 +0000 Subject: [PATCH 23/29] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- flash/core/utilities/imports.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/flash/core/utilities/imports.py b/flash/core/utilities/imports.py index 92e1754598..ce48639b71 100644 --- a/flash/core/utilities/imports.py +++ b/flash/core/utilities/imports.py @@ -301,9 +301,7 @@ def _import_module(self): topic = os.environ["FLASH_TEST_TOPIC"] _CORE_TESTING = topic == "core" _IMAGE_TESTING = topic == "image" - _IMAGE_EXTRAS_TESTING = ( - topic == "image,image_extras" or topic == "icevision" or topic == "vissl" - ) + _IMAGE_EXTRAS_TESTING = topic == "image,image_extras" or topic == "icevision" or topic == "vissl" _VIDEO_TESTING = topic == "video" _VIDEO_EXTRAS_TESTING = topic == "video,video_extras" _TABULAR_TESTING = topic == "tabular" From 7a247672e03048a8458862c5b64f5737633553ca Mon Sep 17 00:00:00 2001 From: Kushashwa Ravi Shrimali Date: Fri, 12 Aug 2022 16:52:33 +0530 Subject: [PATCH 24/29] Apply suggestions from code review --- .github/workflows/ci-testing.yml | 2 +- flash/core/integrations/icevision/adapter.py | 24 +++++++------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci-testing.yml b/.github/workflows/ci-testing.yml index f51790cbea..46e1870aae 100644 --- a/.github/workflows/ci-testing.yml +++ b/.github/workflows/ci-testing.yml @@ -128,7 +128,7 @@ jobs: if: contains( matrix.topic , 'serve' ) run: | sudo apt-get install libsndfile1 - pip install '.[all,audio]' effdet icevision --upgrade + pip install '.[all,audio]' icevision effdet --upgrade - name: Install audio test dependencies if: contains( matrix.topic , 'audio' ) diff --git a/flash/core/integrations/icevision/adapter.py b/flash/core/integrations/icevision/adapter.py index f21726af71..2feee65e44 100644 --- a/flash/core/integrations/icevision/adapter.py +++ b/flash/core/integrations/icevision/adapter.py @@ -144,14 +144,12 @@ def process_train_dataset( persistent_workers=persistent_workers, ) - new_collate_fn = functools.partial(self._wrap_collate_fn, data_loader.collate_fn) - data_loader = self._update_collate_fn_dataloader(new_collate_fn, data_loader) + data_loader = self._update_collate_fn_dataloader(functools.partial(self._wrap_collate_fn, data_loader.collate_fn), data_loader) input_transform = input_transform or self.input_transform if input_transform is not None: input_transform.inject_collate_fn(data_loader.collate_fn) - new_collate_fn = create_worker_input_transform_processor(RunningStage.TRAINING, input_transform) - data_loader = self._update_collate_fn_dataloader(new_collate_fn, data_loader) + data_loader = self._update_collate_fn_dataloader(create_worker_input_transform_processor(RunningStage.TRAINING, input_transform), data_loader) return data_loader def process_val_dataset( @@ -178,14 +176,12 @@ def process_val_dataset( persistent_workers=persistent_workers, ) - new_collate_fn = functools.partial(self._wrap_collate_fn, data_loader.collate_fn) - data_loader = self._update_collate_fn_dataloader(new_collate_fn, data_loader) + data_loader = self._update_collate_fn_dataloader(functools.partial(self._wrap_collate_fn, data_loader.collate_fn), data_loader) input_transform = input_transform or self.input_transform if input_transform is not None: input_transform.inject_collate_fn(data_loader.collate_fn) - new_collate_fn = create_worker_input_transform_processor(RunningStage.VALIDATING, input_transform) - data_loader = self._update_collate_fn_dataloader(new_collate_fn, data_loader) + data_loader = self._update_collate_fn_dataloader(create_worker_input_transform_processor(RunningStage.VALIDATING, input_transform), data_loader) return data_loader def process_test_dataset( @@ -212,14 +208,12 @@ def process_test_dataset( persistent_workers=persistent_workers, ) - new_collate_fn = functools.partial(self._wrap_collate_fn, data_loader.collate_fn) - data_loader = self._update_collate_fn_dataloader(new_collate_fn, data_loader) + data_loader = self._update_collate_fn_dataloader(functools.partial(self._wrap_collate_fn, data_loader.collate_fn), data_loader) input_transform = input_transform or self.input_transform if input_transform is not None: input_transform.inject_collate_fn(data_loader.collate_fn) - new_collate_fn = create_worker_input_transform_processor(RunningStage.TESTING, input_transform) - data_loader = self._update_collate_fn_dataloader(new_collate_fn, data_loader) + data_loader = self._update_collate_fn_dataloader(create_worker_input_transform_processor(RunningStage.TESTING, input_transform), data_loader) return data_loader def process_predict_dataset( @@ -246,14 +240,12 @@ def process_predict_dataset( persistent_workers=persistent_workers, ) - new_collate_fn = functools.partial(self._wrap_collate_fn, data_loader.collate_fn) - data_loader = self._update_collate_fn_dataloader(new_collate_fn, data_loader) + data_loader = self._update_collate_fn_dataloader(functools.partial(self._wrap_collate_fn, data_loader.collate_fn), data_loader) input_transform = input_transform or self.input_transform if input_transform is not None: input_transform.inject_collate_fn(data_loader.collate_fn) - new_collate_fn = create_worker_input_transform_processor(RunningStage.PREDICTING, input_transform) - data_loader = self._update_collate_fn_dataloader(new_collate_fn, data_loader) + data_loader = self._update_collate_fn_dataloader(create_worker_input_transform_processor(RunningStage.PREDICTING, input_transform), data_loader) return data_loader def training_step(self, batch, batch_idx) -> Any: From e58b1d572bdfe9e6873bc60f81f842e8bcefd37e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 12 Aug 2022 11:23:15 +0000 Subject: [PATCH 25/29] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- flash/core/integrations/icevision/adapter.py | 32 +++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/flash/core/integrations/icevision/adapter.py b/flash/core/integrations/icevision/adapter.py index 2feee65e44..2ad0fedc03 100644 --- a/flash/core/integrations/icevision/adapter.py +++ b/flash/core/integrations/icevision/adapter.py @@ -144,12 +144,16 @@ def process_train_dataset( persistent_workers=persistent_workers, ) - data_loader = self._update_collate_fn_dataloader(functools.partial(self._wrap_collate_fn, data_loader.collate_fn), data_loader) + data_loader = self._update_collate_fn_dataloader( + functools.partial(self._wrap_collate_fn, data_loader.collate_fn), data_loader + ) input_transform = input_transform or self.input_transform if input_transform is not None: input_transform.inject_collate_fn(data_loader.collate_fn) - data_loader = self._update_collate_fn_dataloader(create_worker_input_transform_processor(RunningStage.TRAINING, input_transform), data_loader) + data_loader = self._update_collate_fn_dataloader( + create_worker_input_transform_processor(RunningStage.TRAINING, input_transform), data_loader + ) return data_loader def process_val_dataset( @@ -176,12 +180,16 @@ def process_val_dataset( persistent_workers=persistent_workers, ) - data_loader = self._update_collate_fn_dataloader(functools.partial(self._wrap_collate_fn, data_loader.collate_fn), data_loader) + data_loader = self._update_collate_fn_dataloader( + functools.partial(self._wrap_collate_fn, data_loader.collate_fn), data_loader + ) input_transform = input_transform or self.input_transform if input_transform is not None: input_transform.inject_collate_fn(data_loader.collate_fn) - data_loader = self._update_collate_fn_dataloader(create_worker_input_transform_processor(RunningStage.VALIDATING, input_transform), data_loader) + data_loader = self._update_collate_fn_dataloader( + create_worker_input_transform_processor(RunningStage.VALIDATING, input_transform), data_loader + ) return data_loader def process_test_dataset( @@ -208,12 +216,16 @@ def process_test_dataset( persistent_workers=persistent_workers, ) - data_loader = self._update_collate_fn_dataloader(functools.partial(self._wrap_collate_fn, data_loader.collate_fn), data_loader) + data_loader = self._update_collate_fn_dataloader( + functools.partial(self._wrap_collate_fn, data_loader.collate_fn), data_loader + ) input_transform = input_transform or self.input_transform if input_transform is not None: input_transform.inject_collate_fn(data_loader.collate_fn) - data_loader = self._update_collate_fn_dataloader(create_worker_input_transform_processor(RunningStage.TESTING, input_transform), data_loader) + data_loader = self._update_collate_fn_dataloader( + create_worker_input_transform_processor(RunningStage.TESTING, input_transform), data_loader + ) return data_loader def process_predict_dataset( @@ -240,12 +252,16 @@ def process_predict_dataset( persistent_workers=persistent_workers, ) - data_loader = self._update_collate_fn_dataloader(functools.partial(self._wrap_collate_fn, data_loader.collate_fn), data_loader) + data_loader = self._update_collate_fn_dataloader( + functools.partial(self._wrap_collate_fn, data_loader.collate_fn), data_loader + ) input_transform = input_transform or self.input_transform if input_transform is not None: input_transform.inject_collate_fn(data_loader.collate_fn) - data_loader = self._update_collate_fn_dataloader(create_worker_input_transform_processor(RunningStage.PREDICTING, input_transform), data_loader) + data_loader = self._update_collate_fn_dataloader( + create_worker_input_transform_processor(RunningStage.PREDICTING, input_transform), data_loader + ) return data_loader def training_step(self, batch, batch_idx) -> Any: From 4b329040c62b5931df476b45017effca8a969e5a Mon Sep 17 00:00:00 2001 From: Kushashwa Ravi Shrimali Date: Fri, 12 Aug 2022 17:25:30 +0530 Subject: [PATCH 26/29] indentation fix --- flash/core/integrations/icevision/adapter.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/flash/core/integrations/icevision/adapter.py b/flash/core/integrations/icevision/adapter.py index 2ad0fedc03..bf06ae1b38 100644 --- a/flash/core/integrations/icevision/adapter.py +++ b/flash/core/integrations/icevision/adapter.py @@ -151,9 +151,9 @@ def process_train_dataset( input_transform = input_transform or self.input_transform if input_transform is not None: input_transform.inject_collate_fn(data_loader.collate_fn) - data_loader = self._update_collate_fn_dataloader( - create_worker_input_transform_processor(RunningStage.TRAINING, input_transform), data_loader - ) + data_loader = self._update_collate_fn_dataloader( + create_worker_input_transform_processor(RunningStage.TRAINING, input_transform), data_loader + ) return data_loader def process_val_dataset( @@ -187,9 +187,9 @@ def process_val_dataset( input_transform = input_transform or self.input_transform if input_transform is not None: input_transform.inject_collate_fn(data_loader.collate_fn) - data_loader = self._update_collate_fn_dataloader( - create_worker_input_transform_processor(RunningStage.VALIDATING, input_transform), data_loader - ) + data_loader = self._update_collate_fn_dataloader( + create_worker_input_transform_processor(RunningStage.VALIDATING, input_transform), data_loader + ) return data_loader def process_test_dataset( From 2c8947802248a231585b3f64feb4caa5bb222388 Mon Sep 17 00:00:00 2001 From: Kushashwa Ravi Shrimali Date: Fri, 12 Aug 2022 18:43:27 +0530 Subject: [PATCH 27/29] Update .azure-pipelines/testing-template.yml --- .azure-pipelines/testing-template.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.azure-pipelines/testing-template.yml b/.azure-pipelines/testing-template.yml index ca25b7f61b..105943c1fe 100644 --- a/.azure-pipelines/testing-template.yml +++ b/.azure-pipelines/testing-template.yml @@ -37,7 +37,6 @@ jobs: - bash: | # python -m pip install "pip==20.1" if [ "${{config}}" == "icevision" ]; then pip install '.[image]' icevision icedata; elif [ "${{config}}" == "vissl" ]; then pip install '.[image]'; else pip install '.[${{config}}]'; fi - if [ "${{config}}" == "icevision" ]; then pip install git+https://github.com/rwightman/efficientdet-pytorch.git@79d26d8982b9f8e1f27d9f896e38012ac250fd26; fi pip install '.[test]' --upgrade-strategy only-if-needed pip list displayName: 'Install dependencies' From ccc7e24e83713fd3aab84102d899b98bf3197116 Mon Sep 17 00:00:00 2001 From: Kushashwa Ravi Shrimali Date: Fri, 12 Aug 2022 18:43:49 +0530 Subject: [PATCH 28/29] Update .azure-pipelines/testing-template.yml --- .azure-pipelines/testing-template.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/testing-template.yml b/.azure-pipelines/testing-template.yml index 105943c1fe..6c69b810f5 100644 --- a/.azure-pipelines/testing-template.yml +++ b/.azure-pipelines/testing-template.yml @@ -36,7 +36,7 @@ jobs: - bash: | # python -m pip install "pip==20.1" - if [ "${{config}}" == "icevision" ]; then pip install '.[image]' icevision icedata; elif [ "${{config}}" == "vissl" ]; then pip install '.[image]'; else pip install '.[${{config}}]'; fi + if [ "${{config}}" == "icevision" ]; then pip install '.[image]' icevision effdet icedata; elif [ "${{config}}" == "vissl" ]; then pip install '.[image]'; else pip install '.[${{config}}]'; fi pip install '.[test]' --upgrade-strategy only-if-needed pip list displayName: 'Install dependencies' From ef9b0c0256e273e5778e69e0ebc29720780632a2 Mon Sep 17 00:00:00 2001 From: Kushashwa Ravi Shrimali Date: Fri, 12 Aug 2022 18:46:13 +0530 Subject: [PATCH 29/29] Add CHANGELOG entries --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 804b60dd19..cc038e9a92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ### Fixed +- Fixed JIT tracing tests where the model class was not attached to the `Trainer` class ([#1410](https://github.com/Lightning-AI/lightning-flash/pull/1410)) + +- Fixed examples for BaaL integration by removing usage of `on__dataloader` hooks (removed in PL 1.7.0) ([#1410](https://github.com/Lightning-AI/lightning-flash/pull/1410)) + +- Fixed examples for BaaL integration for the case when `probabilities` list is empty ([#1410](https://github.com/Lightning-AI/lightning-flash/pull/1410)) + +- Fixed a bug where collate functions were not being attached successfully after the `DataLoader` is initialized (in PL 1.7.0 changing attributes after initialization doesn't do anything) ([#1410](https://github.com/Lightning-AI/lightning-flash/pull/1410)) + - Fixed a bug where grayscale images were not properly converted to RGB when loaded. ([#1394](https://github.com/PyTorchLightning/lightning-flash/pull/1394)) - Fixed a bug where size of mask for instance segmentation doesn't match to size of original image. ([#1353](https://github.com/PyTorchLightning/lightning-flash/pull/1353))