openvinotoolkit / anomalib

An anomaly detection library comprising state-of-the-art algorithms and features such as experiment management, hyper-parameter optimization, and edge inference.
https://anomalib.readthedocs.io/en/latest/
Apache License 2.0
3.67k stars 653 forks source link

[Bug]: anomalib==v1.0.0 EfficientAdModelSize.S Enum does not resolve correctly #2291

Closed kaspar-gestalt closed 2 weeks ago

kaspar-gestalt commented 2 weeks ago

Describe the bug

FileNotFoundError: [Errno 2] No such file or directory: 'pre_trained/efficientad_pretrained_weights/pretrained_teacher_EfficientAdModelSize.S.pth'

Dataset

Other (please specify in the text field below)

Model

Other (please specify in the field below)

Steps to reproduce the behavior

Run engine.fit(model=EfficientAdModel())

OS information

Ubuntu20.04

Expected behavior

load pre_trained model weights

It should resolve to 'pre_trained/efficientad_pretrained_weights/pretrained_teacher_small.pth'

Screenshots

No response

Pip/GitHub

pip

What version/branch did you use?

No response

Configuration YAML

........

Logs

(most recent call last):

      File "/workspace/.venv/lib/python3.11/site-packages/flytekit/exceptions/scopes.py", line 242, in user_entry_point
        return wrapped(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^
      File "/workspace/.venv/lib/python3.11/site-packages/flytekitplugins/mlflow/tracking.py", line 119, in wrapper
        out = fn(*args, **kwargs)
              ^^^^^^^^^^^^^^^^^^^
      File "/workspace/anomaly_detection/tasks.py", line 207, in train
        engine.fit(datamodule=datamodule, model=model, ckpt_path=config['training']['checkpoint_path'])
      File "/workspace/.venv/lib/python3.11/site-packages/anomalib/engine/engine.py", line 515, in fit
        self.trainer.fit(model, train_dataloaders, val_dataloaders, datamodule, ckpt_path)
      File "/workspace/.venv/lib/python3.11/site-packages/lightning/pytorch/trainer/trainer.py", line 544, in fit
        call._call_and_handle_interrupt(
      File "/workspace/.venv/lib/python3.11/site-packages/lightning/pytorch/trainer/call.py", line 44, in _call_and_handle_interrupt
        return trainer_fn(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/workspace/.venv/lib/python3.11/site-packages/lightning/pytorch/trainer/trainer.py", line 580, in _fit_impl
        self._run(model, ckpt_path=ckpt_path)
      File "/workspace/.venv/lib/python3.11/site-packages/lightning/pytorch/trainer/trainer.py", line 989, in _run
        results = self._run_stage()
                  ^^^^^^^^^^^^^^^^^
      File "/workspace/.venv/lib/python3.11/site-packages/lightning/pytorch/trainer/trainer.py", line 1035, in _run_stage
        self.fit_loop.run()
      File "/workspace/.venv/lib/python3.11/site-packages/lightning/pytorch/loops/fit_loop.py", line 198, in run
        self.on_run_start()
      File "/workspace/.venv/lib/python3.11/site-packages/lightning/pytorch/loops/fit_loop.py", line 324, in on_run_start
        call._call_lightning_module_hook(trainer, "on_train_start")
      File "/workspace/.venv/lib/python3.11/site-packages/lightning/pytorch/trainer/call.py", line 157, in _call_lightning_module_hook
        output = fn(*args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^
      File "/workspace/.venv/lib/python3.11/site-packages/anomalib/models/image/efficient_ad/lightning_model.py", line 240, in on_train_start
        self.prepare_pretrained_model()
      File "/workspace/.venv/lib/python3.11/site-packages/anomalib/models/image/efficient_ad/lightning_model.py", line 95, in prepare_pretrained_model
        self.model.teacher.load_state_dict(torch.load(teacher_path, map_location=torch.device(self.device)))
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/workspace/.venv/lib/python3.11/site-packages/torch/serialization.py", line 986, in load
        with _open_file_like(f, 'rb') as opened_file:
             ^^^^^^^^^^^^^^^^^^^^^^^^
      File "/workspace/.venv/lib/python3.11/site-packages/torch/serialization.py", line 435, in _open_file_like
        return _open_file(name_or_buffer, mode)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/workspace/.venv/lib/python3.11/site-packages/torch/serialization.py", line 416, in __init__
        super().__init__(open(name, mode))
                         ^^^^^^^^^^^^^^^^

Message:

    FileNotFoundError: [Errno 2] No such file or directory: 'pre_trained/efficientad_pretrained_weights/pretrained_teacher_EfficientAdModelSize.S.pth'

User error.

Code of Conduct

kaspar-gestalt commented 2 weeks ago

It's resolved in 1.1.0