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]: WinCLIP export pytorch model issue #2202

Open
junxnone opened this issue Jul 19, 2024 · 1 comment
Open

[Bug]: WinCLIP export pytorch model issue #2202

junxnone opened this issue Jul 19, 2024 · 1 comment

Comments

@junxnone
Copy link

Describe the bug

WinCLIP cannot export pytorch model

Dataset

MVTec

Model

Other (please specify in the field below)

Steps to reproduce the behavior

from anomalib.data import MVTec
from anomalib.models import WinClip
from anomalib.engine import Engine
from anomalib.deploy import ExportType
      
datamodule = MVTec()
model = WinClip()

engine = Engine()
engine.fit(datamodule=datamodule, model=model)
engine.export(model, export_type=ExportType.TORCH)

OS information

OS information:

  • OS: [e.g. Ubuntu 22.04]
  • Python version: [e.g. 3.10.13]
  • Anomalib version: [e.g. main branch]
  • PyTorch version: [e.g. 2.3.1]
  • CUDA/cuDNN version: [e.g. 12.1]
  • GPU models and configuration: [e.g. 2x GeForce RTX 3060]

Expected behavior

export pytorch model and inference correctly

Screenshots

No response

Pip/GitHub

pip

What version/branch did you use?

main

Configuration YAML

none

Logs

File "/media/xxx/test_winclip/test.py", line 44, in <module>
    engine.export(model, export_type=ExportType.TORCH)
  File "/home/xxx/anomalib/src/anomalib/engine/engine.py", line 944, in export
    exported_model_path = model.to_torch(
  File "/home/xxx/anomalib/src/anomalib/models/components/base/export_mixin.py", line 89, in to_torch
    torch.save(
  File "/home/xxx/winclip_env/lib/python3.10/site-packages/torch/serialization.py", line 628, in save
    _save(obj, opened_zipfile, pickle_module, pickle_protocol, _disable_byteorder_record)
  File "/home/xxx/winclip_env/lib/python3.10/site-packages/torch/serialization.py", line 840, in _save
    pickler.dump(obj)
AttributeError: Can't pickle local object 'WinClipModel.encode_image.<locals>.get_feature_map.<locals>.hook'


### Code of Conduct

- [X] I agree to follow this project's Code of Conduct
@pzqian
Copy link

pzqian commented Aug 26, 2024

hit the same issue - did you find a workaround?

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

2 participants