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

[Bug]: Tiling does not work with ReverseDistillation #2077

Open
1 task done
smhewenz opened this issue May 21, 2024 · 0 comments
Open
1 task done

[Bug]: Tiling does not work with ReverseDistillation #2077

smhewenz opened this issue May 21, 2024 · 0 comments

Comments

@smhewenz
Copy link

Describe the bug

The attribute 'model' does not exist in the pl_module. Therefore information about the tiler are missing.
With other networks such as Padim the tiling works.

Dataset

Other (please specify in the text field below)

Model

Reverse Distillation

Steps to reproduce the behavior

tiler_config_callback = TilerConfigurationCallback(enable=True, tile_size=[256,256], stride=256)

folder_datamodule = Folder(
name="Name",
normal_dir="C:/Users/healthy",
abnormal_dir="C:/Users/unhealthy,
task=TaskType.CLASSIFICATION,
image_size = (512,512),
num_workers=0,
train_batch_size= 2,
eval_batch_size=2,
seed=40
)

model = ReverseDistillation()

engine = Engine(task=TaskType.CLASSIFICATION,
callbacks = [tiler_config_callback],
max_epochs = 200,
check_val_every_n_epoch= 1,
logger=logger)

output = engine.fit(model=model, datamodule=folder_datamodule)

OS information

OS information:

  • OS: Windows11
  • Python version: 3.10
  • Anomalib version: 1.0.1
  • GPU models and configuration: MX240
  • I'm using a custom dataset

Expected behavior

Tiling should work as it is working with other listed networks.

Screenshots

AttributeError: 'ReverseDistillation' object has no attribute 'model'

Pip/GitHub

GitHub

What version/branch did you use?

No response

Configuration YAML

n

Logs

File "Experiment1_TiledImages.py", line 50, in <module>
    output = engine.fit(model=model, datamodule=folder_datamodule)
  File "engine.py", line 533, in fit
    self._setup_trainer(model)
  File "engine.py", line 331, in _setup_trainer
    self._trainer = Trainer(**self._cache.args)
  File "argparse.py", line 70, in insert_env_defaults
    return fn(self, **kwargs)
  File "trainer.py", line 431, in __init__
    self._callback_connector.on_trainer_init(
  File "callback_connector.py", line 79, in on_trainer_init
    _validate_callbacks_list(self.trainer.callbacks)
  File "callback_connector.py", line 227, in _validate_callbacks_list
    stateful_callbacks = [cb for cb in callbacks if is_overridden("state_dict", instance=cb)]
  File "callback_connector.py", line 227, in <listcomp>
    stateful_callbacks = [cb for cb in callbacks if is_overridden("state_dict", instance=cb)]
  File "model_helpers.py", line 42, in is_overridden
    raise ValueError("Expected a parent")
ValueError: Expected a parent
PS> & python.exe Experiment1_TiledImages.py
GPU available: True (cuda), used: True
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
HPU available: False, using: 0 HPUs
No implementation of `configure_transforms` was provided in the Lightning model. Using default transforms from the base class. This may not be suitable for your use case. Please override `configure_transforms` in your model.
F1Score class exists for backwards compatibility. It will be removed in v1.1. Please use BinaryF1Score from torchmetrics instead
Traceback (most recent call last):
  File "Experiment1_TiledImages.py", line 50, in <module>
    output = engine.fit(model=model, datamodule=folder_datamodule)
  File "engine.py", line 540, in fit
    self.trainer.fit(model, train_dataloaders, val_dataloaders, datamodule, ckpt_path)
  File "trainer.py", line 544, in fit
    call._call_and_handle_interrupt(
  File "call.py", line 44, in _call_and_handle_interrupt
    return trainer_fn(*args, **kwargs)
  File "trainer.py", line 580, in _fit_impl
    self._run(model, ckpt_path=ckpt_path)
  File "trainer.py", line 949, in _run
    call._call_setup_hook(self)  # allow user to set up LightningModule in accelerator environment
  File "call.py", line 93, in _call_setup_hook
    _call_callback_hooks(trainer, "setup", stage=fn)
  File "call.py", line 208, in _call_callback_hooks
    fn(trainer, trainer.lightning_module, *args, **kwargs)
  File "tiler_configuration.py", line 65, in setup
    if isinstance(pl_module, AnomalyModule) and hasattr(pl_module.model, "tiler"):
  File "module.py", line 1709, in __getattr__
    raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")
AttributeError: 'ReverseDistillation' object has no attribute 'model'

Code of Conduct

  • I agree to follow this project's Code of Conduct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant