Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐞 v1 - MPS accelerator does not work when generating the visualizers #1621

Closed
1 task done
samet-akcay opened this issue Jan 11, 2024 · 1 comment
Closed
1 task done
Labels
Bug Something isn't working Visualization

Comments

@samet-akcay
Copy link
Contributor

Describe the bug

When training a default model and dataset, visualization stage does not work with mps accelerator

Dataset

MVTec

Model

PADiM

Steps to reproduce the behavior

On a Macbook M* machine, run the following CLI command:

anomalib train --model Padim --data MVTec

OS information

OS information:

  • OS: MacOS
  • Python version: 3.10
  • Anomalib version: 1.0.0
  • PyTorch version: 2.1.2
  • CUDA/cuDNN version: mps
  • GPU models and configuration: M3 Max
  • Any other relevant information: N/A

Expected behavior

  • Visualizer to properly generate the output figure.

Screenshots

No response

Pip/GitHub

GitHub

What version/branch did you use?

v1.0.0

Configuration YAML

N/A

Logs

❯
anomalib train --model Padim --data MVTec
Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
Could not find torch. To use this feature, ensure that you have torch installed.
2024-01-11 08:10:13,873 - anomalib.utils.exceptions.imports - WARNING - Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
[01/11/24 08:10:13] WARNING  Could not find comet_ml. To use this feature, ensure that you have comet_ml      imports.py:25
                             installed.
Seed set to 4150399376
2024-01-11 08:10:14,272 - anomalib.utils.config - WARNING - Anomalib currently does not support multi-gpu training. Setting devices to 1.
[01/11/24 08:10:14] WARNING  Anomalib currently does not support multi-gpu training. Setting devices to 1.    config.py:239
[01/11/24 08:10:14] WARNING  Anomalib currently does not support multi-gpu training. Setting devices to 1.    config.py:239
2024-01-11 08:10:14,273 - anomalib.utils.config - INFO -  Setting model input size (256, 256) to dataset size (256, 256).
                    INFO      Setting model input size (256, 256) to dataset size (256, 256).                 config.py:180
                    INFO      Setting model input size (256, 256) to dataset size (256, 256).                 config.py:180
2024-01-11 08:10:14,274 - anomalib.utils.config - INFO - Project path set to results/padim/mvtec/bottle
                    INFO     Project path set to results/padim/mvtec/bottle                                   config.py:116
                    INFO     Project path set to results/padim/mvtec/bottle                                   config.py:116
2024-01-11 08:10:14,305 - anomalib.models.components.base.anomaly_module - INFO - Initializing Padim model.
                    INFO     Initializing Padim model.                                                 anomaly_module.py:36
                    INFO     Initializing Padim model.                                                 anomaly_module.py:36
2024-01-11 08:10:14,533 - timm.models.helpers - INFO - Loading pretrained weights from url (https://download.pytorch.org/models/resnet18-5c106cde.pth)
                    INFO     Loading pretrained weights from url                                             helpers.py:247
                             (https://download.pytorch.org/models/resnet18-5c106cde.pth)
                    INFO     Loading pretrained weights from url                                             helpers.py:247
                             (https://download.pytorch.org/models/resnet18-5c106cde.pth)
2024-01-11 08:10:14,610 - anomalib.data.utils.transforms - INFO - No config file has been provided. Using default transforms.
                    INFO     No config file has been provided. Using default transforms.                  transforms.py:130
                    INFO     No config file has been provided. Using default transforms.                  transforms.py:130
2024-01-11 08:10:14,611 - anomalib.data.utils.transforms - INFO - No config file has been provided. Using default transforms.
                    INFO     No config file has been provided. Using default transforms.                  transforms.py:130
                    INFO     No config file has been provided. Using default transforms.                  transforms.py:130
2024-01-11 08:10:14,612 - anomalib.callbacks - INFO - Loading the callbacks
                    INFO     Loading the callbacks                                                           __init__.py:45
                    INFO     Loading the callbacks                                                           __init__.py:45
2024-01-11 08:10:14,614 - anomalib.engine.engine - INFO - Overriding max_epochs from None with 1 for Padim
                    INFO     Overriding max_epochs from None with 1 for Padim                                  engine.py:81
                    INFO     Overriding max_epochs from None with 1 for Padim                                  engine.py:81
2024-01-11 08:10:14,614 - anomalib.engine.engine - INFO - Overriding val_check_interval from None with 1.0 for Padim
                    INFO     Overriding val_check_interval from None with 1.0 for Padim                        engine.py:81
                    INFO     Overriding val_check_interval from None with 1.0 for Padim                        engine.py:81
2024-01-11 08:10:14,615 - anomalib.engine.engine - INFO - Overriding num_sanity_val_steps from None with 0 for Padim
                    INFO     Overriding num_sanity_val_steps from None with 0 for Padim                        engine.py:81
                    INFO     Overriding num_sanity_val_steps from None with 0 for Padim                        engine.py:81
2024-01-11 08:10:14,741 - anomalib.data.image.mvtec - INFO - Found the dataset.
                    INFO     Found the dataset.                                                                mvtec.py:413
                    INFO     Found the dataset.                                                                mvtec.py:413
Epoch 0:   0%|                                                                                       | 0/7 [00:00<?, ?it/s]Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
Could not find torch. To use this feature, ensure that you have torch installed.
Could not find torch. To use this feature, ensure that you have torch installed.
Could not find torch. To use this feature, ensure that you have torch installed.
Could not find torch. To use this feature, ensure that you have torch installed.
Could not find torch. To use this feature, ensure that you have torch installed.
Could not find torch. To use this feature, ensure that you have torch installed.
Could not find torch. To use this feature, ensure that you have torch installed.
Could not find torch. To use this feature, ensure that you have torch installed.
2024-01-11 08:10:21,052 - anomalib.utils.exceptions.imports - WARNING - Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
2024-01-11 08:10:21,052 - anomalib.utils.exceptions.imports - WARNING - Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
2024-01-11 08:10:21,053 - anomalib.utils.exceptions.imports - WARNING - Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
2024-01-11 08:10:21,053 - anomalib.utils.exceptions.imports - WARNING - Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
2024-01-11 08:10:21,053 - anomalib.utils.exceptions.imports - WARNING - Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
2024-01-11 08:10:21,053 - anomalib.utils.exceptions.imports - WARNING - Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
2024-01-11 08:10:21,053 - anomalib.utils.exceptions.imports - WA2024-01-11 08:10:21,053 - anomalib.utils.exceptions.imports - WARNING - Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
RNING - Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
[01/11/24 08:10:21] WARNING  Could not find comet_ml. To use this feature, ensure that you have comet_ml      imports.py:25
                             installed.
[01/11/24 08:10:21] WARNING  Could not find comet_ml. To use this feature, ensure that you have comet_ml      imports.py:25
                             installed.
[01/11/24 08:10:21] WARNING  Could not find comet_ml. To use this feature, ensure that you have comet_ml      imports.py:25
                             installed.
[01/11/24 08:10:21] WARNING  Could not find comet_ml. To use this feature, ensure that you have comet_ml      imports.py:25
                             installed.
[01/11/24 08:10:21] WARNING  Could not find comet_ml. To use this feature, ensure that you have comet_ml      imports.py:25
                             installed.
[01/11/24 08:10:21] WARNING  Could not find comet_ml. To use this feature, ensure that you have comet_ml      imports.py:25
                             installed.
[01/11/24 08:10:21] WARNING  Could not find comet_ml. To use this feature, ensure that you have comet_ml      imports.py:25
                             installed.
[01/11/24 08:10:21] WARNING  Could not find comet_ml. To use this feature, ensure that you have comet_ml      imports.py:25
                             installed.
Epoch 0: 100%|██████████████████████████████████████████████████████████████████████| 7/7 [00:06<00:00,  1.02it/s, v_num=42024-01-11 08:10:22,039 - anomalib.models.image.padim.lightning_model - INFO - Aggregating the embedding extracted from the training set.
[01/11/24 08:10:22] INFO     Aggregating the embedding extracted from the training set.               lightning_model.py:88
[01/11/24 08:10:22] INFO     Aggregating the embedding extracted from the training set.               lightning_model.py:88
2024-01-11 08:10:22,068 - anomalib.models.image.padim.lightning_model - INFO - Fitting a Gaussian to the embedding collected from the training set.
                    INFO     Fitting a Gaussian to the embedding collected from the training set.     lightning_model.py:91
                    INFO     Fitting a Gaussian to the embedding collected from the training set.     lightning_model.py:91
Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
Could not find torch. To use this feature, ensure that you have torch installed.
Could not find torch. To use this feature, ensure that you have torch installed.
Could not find torch. To use this feature, ensure that you have torch installed.
Could not find torch. To use this feature, ensure that you have torch installed.
Could not find torch. To use this feature, ensure that you have torch installed.
Could not find torch. To use this feature, ensure that you have torch installed.
Could not find torch. To use this feature, ensure that you have torch installed.
Could not find torch. To use this feature, ensure that you have torch installed.
2024-01-11 08:10:28,254 - anomalib.utils.exceptions.imports - WARNING - Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
2024-01-11 08:10:28,255 - anomalib.utils.exceptions.imports - WARNING - Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
2024-01-11 08:10:28,255 - anomalib.utils.exceptions.imports - WARNING - Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
2024-01-11 08:10:28,255 - anomalib.utils.exceptions.imports - WARNING - Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
2024-01-11 08:10:28,255 - anomalib.utils.exceptions.imports - WARNING - Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
2024-01-11 08:10:28,255 - anomalib.utils.exceptions.imports - WARNING - Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
2024-01-11 08:10:28,255 - anomalib.utils.exceptions.imports - WARNING - Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
2024-01-11 08:10:28,255 - anomalib.utils.exceptions.imports - WARNING - Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
[01/11/24 08:10:28] WARNING  Could not find comet_ml. To use this feature, ensure that you have comet_ml      imports.py:25
                             installed.
[01/11/24 08:10:28] WARNING  Could not find comet_ml. To use this feature, ensure that you have comet_ml      imports.py:25
                             installed.                                                         [01/11/24 08:10:28] WARNING  Could not find comet_ml. To use this feature, ensure that you have comet_ml      imports.py:25
                             installed.
[01/11/24 08:10:28] WARNING  Could not find comet_ml. To use this feature, ensure that you have comet_ml      imports.py:25
                             installed.
[01/11/24 08:10:28] WARNING  Could not find comet_ml. To use this feature, ensure that you have comet_ml      imports.py:25
                             installed.

[01/11/24 08:10:28] WARNING  Could not find comet_ml. To use this feature, ensure that you have comet_ml      imports.py:25
                             installed.
[01/11/24 08:10:28] WARNING  Could not find comet_ml. To use this feature, ensure that you have comet_ml      imports.py:25
                             installed.
[01/11/24 08:10:28] WARNING  Could not find comet_ml. To use this feature, ensure that you have comet_ml      imports.py:25
                             installed.
Epoch 0: 100%|██████████████████████████████████████████████████████████████████████| 7/7 [00:14<00:00,  0.47it/s, v_num=4]
2024-01-11 08:11:19,842 - anomalib.callbacks.timer - INFO - Training took 64.93 seconds
[01/11/24 08:11:19] INFO     Training took 64.93 seconds                                                        timer.py:59
[01/11/24 08:11:19] INFO     Training took 64.93 seconds                                                        timer.py:59
2024-01-11 08:11:19,861 - anomalib.data.image.mvtec - INFO - Found the dataset.
                    INFO     Found the dataset.                                                                mvtec.py:413
                    INFO     Found the dataset.                                                                mvtec.py:413
Testing: |                                                                                           | 0/? [00:00<?, ?it/s]Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
Could not find torch. To use this feature, ensure that you have torch installed.
Could not find torch. To use this feature, ensure that you have torch installed.
Could not find torch. To use this feature, ensure that you have torch installed.
Could not find torch. To use this feature, ensure that you have torch installed.
Could not find torch. To use this feature, ensure that you have torch installed.
Could not find torch. To use this feature, ensure that you have torch installed.
Could not find torch. To use this feature, ensure that you have torch installed.
Could not find torch. To use this feature, ensure that you have torch installed.
2024-01-11 08:11:26,520 - anomalib.utils.exceptions.imports - WARNING - Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
2024-01-11 08:11:26,520 - anomalib.utils.exceptions.imports - WARNING - Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
2024-01-11 08:11:26,521 - anomalib.utils.exceptions.imports - WARNING - Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
2024-01-11 08:11:26,521 - anomalib.utils.exceptions.imports - WARNING - Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
2024-01-11 08:11:26,521 - anomalib.utils.exceptions.imports - WARNING - Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
2024-01-11 08:11:26,521 - anomalib.utils.exceptions.imports - WARNING - Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
2024-01-11 08:11:26,521 - anomalib.utils.exceptions.imports - WARNING - Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
2024-01-11 08:11:26,521 - anomalib.utils.exceptions.imports - WARNING - Could not find comet_ml. To use this feature, ensure that you have comet_ml installed.
[01/11/24 08:11:26] WARNING  Could not find comet_ml. To use this feature, ensure that you have comet_ml      imports.py:25
                             installed.
[01/11/24 08:11:26] WARNING  Could not find comet_ml. To use this feature, ensure that you have comet_ml      imports.py:25
                             installed.
[01/11/24 08:11:26] WARNING  Could not find comet_ml. To use this feature, ensure that you have comet_ml      imports.py:25
                             installed.
[01/11/24 08:11:26] WARNING  Could not find comet_ml. To use this feature, ensure that you have comet_ml      imports.py:25
                             installed.
[01/11/24 08:11:26] WARNING  Could not find comet_ml. To use this feature, ensure that you have comet_ml      imports.py:25
                             installed.                  [01/11/24 08:11:26] WARNING  Could not find comet_ml. To use this feature, ensure that you have comet_ml      imports.py:25
                             installed.

[01/11/24 08:11:26] WARNING  Could not find comet_ml. To use this feature, ensure that you have comet_ml      imports.py:25
                             installed.
[01/11/24 08:11:26] WARNING  Could not find comet_ml. To use this feature, ensure that you have comet_ml      imports.py:25
                             installed.
Testing DataLoader 0:  33%|██████████████████████                                            | 1/3 [00:00<00:00, 16.92it/s]╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /Users/sakcay/.pyenv/versions/anomalib_env/bin/anomalib:8 in <module>                            │
│                                                                                                  │
│   5 from anomalib.cli.cli import main                                                            │
│   6 if __name__ == '__main__':                                                                   │
│   7 │   sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])                         │
│ ❱ 8 │   sys.exit(main())                                                                         │
│   9                                                                                              │
│                                                                                                  │
│ /Users/sakcay/Projects/anomalib/src/anomalib/cli/cli.py:377 in main                              │
│                                                                                                  │
│   374 def main() -> None:                                                                        │
│   375 │   """Trainer via Anomalib CLI."""                                                        │
│   376 │   configure_logger()                                                                     │
│ ❱ 377 │   AnomalibCLI()                                                                          │
│   378                                                                                            │
│   379                                                                                            │
│   380 if __name__ == "__main__":                                                                 │
│                                                                                                  │
│ /Users/sakcay/Projects/anomalib/src/anomalib/cli/cli.py:65 in __init__                           │
│                                                                                                  │
│    62 │   │   run: bool = True,                                                                  │
│    63 │   │   auto_configure_optimizers: bool = True,                                            │
│    64 │   ) -> None:                                                                             │
│ ❱  65 │   │   super().__init__(                                                                  │
│    66 │   │   │   AnomalyModule,                                                                 │
│    67 │   │   │   AnomalibDataModule,                                                            │
│    68 │   │   │   save_config_callback,                                                          │
│                                                                                                  │
│ /Users/sakcay/.pyenv/versions/3.10.13/envs/anomalib_env/lib/python3.10/site-packages/lightning/p │
│ ytorch/cli.py:386 in __init__                                                                    │
│                                                                                                  │
│   383 │   │   self.instantiate_classes()                                                         │
│   384 │   │                                                                                      │
│   385 │   │   if self.subcommand is not None:                                                    │
│ ❱ 386 │   │   │   self._run_subcommand(self.subcommand)                                          │
│   387 │                                                                                          │
│   388 │   def _setup_parser_kwargs(self, parser_kwargs: Dict[str, Any]) -> Tuple[Dict[str, Any   │
│   389 │   │   subcommand_names = self.subcommands().keys()                                       │
│                                                                                                  │
│ /Users/sakcay/Projects/anomalib/src/anomalib/cli/cli.py:295 in _run_subcommand                   │
│                                                                                                  │
│   292 │   │   if self.config["subcommand"] in (*self.subcommands(), "train", "export", "predic   │
│   293 │   │   │   fn = getattr(self.engine, subcommand)                                          │
│   294 │   │   │   fn_kwargs = self._prepare_subcommand_kwargs(subcommand)                        │
│ ❱ 295 │   │   │   fn(**fn_kwargs)                                                                │
│   296 │   │   else:                                                                              │
│   297 │   │   │   self.config_init = self.parser.instantiate_classes(self.config)                │
│   298 │   │   │   getattr(self, f"{subcommand}")()                                               │
│                                                                                                  │
│ /Users/sakcay/Projects/anomalib/src/anomalib/engine/engine.py:475 in train                       │
│                                                                                                  │
│   472 │   │   self._setup_trainer(model)                                                         │
│   473 │   │   self._setup_dataset_task(train_dataloaders, val_dataloaders, test_dataloaders, d   │
│   474 │   │   self.trainer.fit(model, train_dataloaders, val_dataloaders, datamodule, ckpt_pat   │
│ ❱ 475 │   │   self.trainer.test(model, test_dataloaders, ckpt_path=ckpt_path, datamodule=datam   │
│   476 │                                                                                          │
│   477 │   def export(                                                                            │
│   478 │   │   self,                                                                              │
│                                                                                                  │
│ /Users/sakcay/.pyenv/versions/3.10.13/envs/anomalib_env/lib/python3.10/site-packages/lightning/p │
│ ytorch/trainer/trainer.py:754 in test                                                            │
│                                                                                                  │
│    751 │   │   self.state.fn = TrainerFn.TESTING                                                 │
│    752 │   │   self.state.status = TrainerStatus.RUNNING                                         │
│    753 │   │   self.testing = True                                                               │
│ ❱  754 │   │   return call._call_and_handle_interrupt(                                           │
│    755 │   │   │   self, self._test_impl, model, dataloaders, ckpt_path, verbose, datamodule     │
│    756 │   │   )                                                                                 │
│    757                                                                                           │
│                                                                                                  │
│ /Users/sakcay/.pyenv/versions/3.10.13/envs/anomalib_env/lib/python3.10/site-packages/lightning/p │
│ ytorch/trainer/call.py:44 in _call_and_handle_interrupt                                          │
│                                                                                                  │
│    41 │   try:                                                                                   │
│    42 │   │   if trainer.strategy.launcher is not None:                                          │
│    43 │   │   │   return trainer.strategy.launcher.launch(trainer_fn, *args, trainer=trainer,    │
│ ❱  44 │   │   return trainer_fn(*args, **kwargs)                                                 │
│    45 │                                                                                          │
│    46 │   except _TunerExitException:                                                            │
│    47 │   │   _call_teardown_hook(trainer)                                                       │
│                                                                                                  │
│ /Users/sakcay/.pyenv/versions/3.10.13/envs/anomalib_env/lib/python3.10/site-packages/lightning/p │
│ ytorch/trainer/trainer.py:794 in _test_impl                                                      │
│                                                                                                  │
│    791 │   │   ckpt_path = self._checkpoint_connector._select_ckpt_path(                         │
│    792 │   │   │   self.state.fn, ckpt_path, model_provided=model_provided, model_connected=sel  │
│    793 │   │   )                                                                                 │
│ ❱  794 │   │   results = self._run(model, ckpt_path=ckpt_path)                                   │
│    795 │   │   # remove the tensors from the test results                                        │
│    796 │   │   results = convert_tensors_to_scalars(results)                                     │
│    797                                                                                           │
│                                                                                                  │
│ /Users/sakcay/.pyenv/versions/3.10.13/envs/anomalib_env/lib/python3.10/site-packages/lightning/p │
│ ytorch/trainer/trainer.py:989 in _run                                                            │
│                                                                                                  │
│    986 │   │   # ----------------------------                                                    │
│    987 │   │   # RUN THE TRAINER                                                                 │
│    988 │   │   # ----------------------------                                                    │
│ ❱  989 │   │   results = self._run_stage()                                                       │
│    990 │   │                                                                                     │
│    991 │   │   # ----------------------------                                                    │
│    992 │   │   # POST-Training CLEAN UP                                                          │
│                                                                                                  │
│ /Users/sakcay/.pyenv/versions/3.10.13/envs/anomalib_env/lib/python3.10/site-packages/lightning/p │
│ ytorch/trainer/trainer.py:1028 in _run_stage                                                     │
│                                                                                                  │
│   1025 │   │   self.lightning_module.zero_grad(**zero_grad_kwargs)                               │
│   1026 │   │                                                                                     │
│   1027 │   │   if self.evaluating:                                                               │
│ ❱ 1028 │   │   │   return self._evaluation_loop.run()                                            │
│   1029 │   │   if self.predicting:                                                               │
│   1030 │   │   │   return self.predict_loop.run()                                                │
│   1031 │   │   if self.training:                                                                 │
│                                                                                                  │
│ /Users/sakcay/.pyenv/versions/3.10.13/envs/anomalib_env/lib/python3.10/site-packages/lightning/p │
│ ytorch/loops/utilities.py:182 in _decorator                                                      │
│                                                                                                  │
│   179 │   │   else:                                                                              │
│   180 │   │   │   context_manager = torch.no_grad                                                │
│   181 │   │   with context_manager():                                                            │
│ ❱ 182 │   │   │   return loop_run(self, *args, **kwargs)                                         │
│   183 │                                                                                          │
│   184 │   return _decorator                                                                      │
│   185                                                                                            │
│                                                                                                  │
│ /Users/sakcay/.pyenv/versions/3.10.13/envs/anomalib_env/lib/python3.10/site-packages/lightning/p │
│ ytorch/loops/evaluation_loop.py:134 in run                                                       │
│                                                                                                  │
│   131 │   │   │   │   previous_dataloader_idx = dataloader_idx                                   │
│   132 │   │   │   │   self.batch_progress.is_last_batch = data_fetcher.done                      │
│   133 │   │   │   │   # run step hooks                                                           │
│ ❱ 134 │   │   │   │   self._evaluation_step(batch, batch_idx, dataloader_idx, dataloader_iter)   │
│   135 │   │   │   except StopIteration:                                                          │
│   136 │   │   │   │   # this needs to wrap the `*_step` call too (not just `next`) for `datalo   │
│   137 │   │   │   │   break
│                                                                                                  │
│ /Users/sakcay/.pyenv/versions/3.10.13/envs/anomalib_env/lib/python3.10/site-packages/lightning/p │
│ ytorch/loops/evaluation_loop.py:405 in _evaluation_step                                          │
│                                                                                                  │
│   402 │   │   │   )                                                                              │
│   403 │   │                                                                                      │
│   404 │   │   hook_name = "on_test_batch_end" if trainer.testing else "on_validation_batch_end   │
│ ❱ 405 │   │   call._call_callback_hooks(trainer, hook_name, output, *hook_kwargs.values())       │
│   406 │   │   call._call_lightning_module_hook(trainer, hook_name, output, *hook_kwargs.values   │
│   407 │   │                                                                                      │
│   408 │   │   trainer._logger_connector.on_batch_end()                                           │
│                                                                                                  │
│ /Users/sakcay/.pyenv/versions/3.10.13/envs/anomalib_env/lib/python3.10/site-packages/lightning/p │
│ ytorch/trainer/call.py:208 in _call_callback_hooks                                               │
│                                                                                                  │
│   205 │   │   fn = getattr(callback, hook_name)                                                  │
│   206 │   │   if callable(fn):                                                                   │
│   207 │   │   │   with trainer.profiler.profile(f"[Callback]{callback.state_key}.{hook_name}")   │
│ ❱ 208 │   │   │   │   fn(trainer, trainer.lightning_module, *args, **kwargs)                     │
│   209 │                                                                                          │
│   210 │   if pl_module:                                                                          │
│   211 │   │   # restore current_fx when nested context                                           │
│                                                                                                  │
│ /Users/sakcay/Projects/anomalib/src/anomalib/callbacks/visualizer/visualizer_image.py:99 in      │
│ on_test_batch_end                                                                                │
│                                                                                                  │
│    96 │   │   del batch, batch_idx, dataloader_idx  # These variables are not used.              │
│    97 │   │   assert outputs is not None                                                         │
│    98 │   │                                                                                      │
│ ❱  99 │   │   for i, image in enumerate(self.visualizer.visualize_batch(outputs)):               │
│   100 │   │   │   if "image_path" in outputs:                                                    │
│   101 │   │   │   │   filename = Path(outputs["image_path"][i])                                  │
│   102 │   │   │   elif "video_path" in outputs:                                                  │
│                                                                                                  │
│ /Users/sakcay/Projects/anomalib/src/anomalib/utils/visualization.py:124 in visualize_batch       │
│                                                                                                  │
│   121 │   │   │   │   pred_boxes=batch["pred_boxes"][i].cpu().numpy() if "pred_boxes" in batch   │
│   122 │   │   │   │   box_labels=batch["box_labels"][i].cpu().numpy() if "box_labels" in batch   │
│   123 │   │   │   )                                                                              │
│ ❱ 124 │   │   │   yield self.visualize_image(image_result)                                       │
│   125 │                                                                                          │
│   126 │   def visualize_image(self, image_result: ImageResult) -> np.ndarray:                    │
│   127 │   │   """Generate the visualization for an image.                                        │
│                                                                                                  │
│ /Users/sakcay/Projects/anomalib/src/anomalib/utils/visualization.py:136 in visualize_image       │
│                                                                                                  │
│   133 │   │   │   The full or simple visualization for the image, depending on the specified m   │
│   134 │   │   """
│   135 │   │   if self.mode == VisualizationMode.FULL:                                            │
│ ❱ 136 │   │   │   return self._visualize_full(image_result)                                      │
│   137 │   │   if self.mode == VisualizationMode.SIMPLE:                                          │
│   138 │   │   │   return self._visualize_simple(image_result)                                    │
│   139 │   │   msg = f"Unknown visualization mode: {self.mode}"
│                                                                                                  │
│ /Users/sakcay/Projects/anomalib/src/anomalib/utils/visualization.py:185 in _visualize_full       │
│                                                                                                  │
│   182 │   │   │   │   image_classified = add_normal_label(image_result.image, 1 - image_result   │
│   183 │   │   │   visualization.add_image(image=image_classified, title="Prediction")            │
│   184 │   │                                                                                      │
│ ❱ 185 │   │   return visualization.generate()                                                    │
│   186 │                                                                                          │
│   187 │   def _visualize_simple(self, image_result: ImageResult) -> np.ndarray:                  │
│   188 │   │   """Generate a simple visualization for an image.                                   │
│                                                                                                  │
│ /Users/sakcay/Projects/anomalib/src/anomalib/utils/visualization.py:296 in generate              │
│                                                                                                  │
│   293 │   │   self.figure.canvas.draw()                                                          │
│   294 │   │   # convert canvas to numpy array to prepare for visualization with opencv           │
│   295 │   │   img = np.frombuffer(self.figure.canvas.tostring_rgb(), dtype=np.uint8)             │
│ ❱ 296 │   │   img = img.reshape(self.figure.canvas.get_width_height()[::-1] + (3,))              │
│   297 │   │   plt.close(self.figure)                                                             │
│   298 │   │   return img                                                                         │
│   299                                                                                            │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ValueError: cannot reshape array of size 15000000 into shape (500,2500,3)
Testing DataLoader 0:  33%|███▎      | 1/3 [00:16<00:33,  0.06it/s]

Code of Conduct

  • I agree to follow this project's Code of Conduct
@samet-akcay samet-akcay changed the title 🐞 v1 - M3 Training Visualization Error 🐞 v1 - MPS accelerator does not work when generating the visualizers Jan 11, 2024
@samet-akcay samet-akcay added Bug Something isn't working Visualization labels Jan 11, 2024
@ashwinvaidya17
Copy link
Collaborator

Closing as it will be fixed by #1766

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Visualization
Projects
None yet
Development

No branches or pull requests

2 participants