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]: Failed download weights for patchcore #2555

Open
1 task done
LorenzoF6 opened this issue Feb 9, 2025 · 4 comments
Open
1 task done

[Bug]: Failed download weights for patchcore #2555

LorenzoF6 opened this issue Feb 9, 2025 · 4 comments

Comments

@LorenzoF6
Copy link

Describe the bug

I'm working with anomalib v2 on a jupyter notebook and when i create a new patchcore model i think that the download failed. Infact when i try the fit the model don't create a symbolinc path with the weights because there aren't in the results (i change the default_root_dir but with the default the outcome is the same) folder

Dataset

N/A

Model

N/A

Steps to reproduce the behavior

eng_patchcore = Engine(default_root_dir = 'risultati')
md_patchcore = Patchcore(evaluator = ev_DISCHITOP)
eng_patchcore.fit(model = md_patchcore, datamodule = datamodule_DISCHITOP)

OS information

OS information:

  • OS: [e.g. Ubuntu 20.04]
  • Python version: [e.g. 3.10.0]
  • Anomalib version: [e.g. 0.3.6]
  • PyTorch version: [e.g. 1.9.0]
  • CUDA/cuDNN version: [e.g. 11.1]
  • GPU models and configuration: [e.g. 2x GeForce RTX 3090]
  • Any other relevant information: [e.g. I'm using a custom dataset]

Expected behavior

correct download of the weights and placed in results

Screenshots

No response

Pip/GitHub

pip

What version/branch did you use?

main

Configuration YAML

N/A

Logs

this is when i create the model :
INFO:anomalib.models.components.base.anomalib_module:Initializing Patchcore model.
INFO:timm.models._builder:Loading pretrained weights from Hugging Face hub (timm/wide_resnet50_2.racm_in1k)
INFO:timm.models._hub:[timm/wide_resnet50_2.racm_in1k] Safe alternative available for 'pytorch_model.bin' (as 'model.safetensors'). Loading weights using safetensors.
INFO:timm.models._builder:Missing keys (fc.weight, fc.bias) discovered while loading pretrained weights. This is expected if model is being adapted.

This is the error when i try the fit:
OSError                                   Traceback (most recent call last)
Cell In[26], line 2
      1 # Fit del modello : Patchcore è zero shot perchè pre addestrato
----> 2 eng_patchcore.fit(model = md_patchcore, datamodule = datamodule_DISCHITOP)

File /workspace/anomalib/src/anomalib/engine/engine.py:404, in Engine.fit(self, model, train_dataloaders, val_dataloaders, datamodule, ckpt_path)
    401 if ckpt_path:
    402     ckpt_path = Path(ckpt_path).resolve()
--> 404 self._setup_workspace(
    405     model=model,
    406     train_dataloaders=train_dataloaders,
    407     val_dataloaders=val_dataloaders,
    408     datamodule=datamodule,
    409     versioned_dir=True,
    410 )
    411 self._setup_trainer(model)
    412 if model.learning_type in {LearningType.ZERO_SHOT, LearningType.FEW_SHOT}:
    413     # if the model is zero-shot or few-shot, we only need to run validate for normalization and thresholding

File /workspace/anomalib/src/anomalib/engine/engine.py:298, in Engine._setup_workspace(self, model, train_dataloaders, val_dataloaders, test_dataloaders, datamodule, dataset, versioned_dir)
    295 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
    296 # 2. Update the default root directory
    297 root_dir = Path(self._cache.args["default_root_dir"]) / model.name / dataset_name / category
--> 298 self._cache.args["default_root_dir"] = create_versioned_dir(root_dir) if versioned_dir else root_dir / "latest"

File /workspace/anomalib/src/anomalib/utils/path.py:102, in create_versioned_dir(root_dir)
    100 if latest_link_path.is_symlink() or latest_link_path.exists():
    101     latest_link_path.unlink()
--> 102 latest_link_path.symlink_to(new_version_dir, target_is_directory=True)
    104 return latest_link_path

File /opt/conda/lib/python3.11/pathlib.py:1198, in Path.symlink_to(self, target, target_is_directory)
   1196 if not hasattr(os, "symlink"):
   1197     raise NotImplementedError("os.symlink() not available on this system")
-> 1198 os.symlink(target, self, target_is_directory)

OSError: [Errno 5] Input/output error: '/workspace/risultati/Patchcore/DISCHITOP/v1' -> '/workspace/risultati/Patchcore/DISCHITOP/latest'

Code of Conduct

  • I agree to follow this project's Code of Conduct
@alexriedel1
Copy link
Contributor

alexriedel1 commented Feb 10, 2025

Hi!
I guess that #2554 is a duplicate of this?

Unfortunately I cannot reproduce the error. Are you running your code on a server? Can you tell a bit more about on what machine you are running this and what exact version of anomalib you are using?

@LorenzoF6
Copy link
Author

Hi, yep sorry i duplicated and i forgot instead to update the #2554.
I'm working with the the latest branch main of anomalib (v2). I've installed it for development with all dependencies
(pip install -e .[full])

I'm using a jupyter notebook which is located inside a docker (i have all the privileges in that) and the docker is mounted on a private storage system which belong to the company where i am currently doing the job.

In this the 'results' folder isn't populated with the weights of patchcore or padim but if i try colab the 'results' folder is instead populated (unfortunately i cannot use colab for my work due to the limited ram). I might think that the problem is some missing permission for access to download the weights and create the correct 'results' folder but i don't know which

@alexriedel1
Copy link
Contributor

alexriedel1 commented Feb 10, 2025

I guess it's a permission issue in your docker, you should try to make sure that you have write permissions in your docker.
Anomalib tries to create a symbolic link inside your docker and fails

@LorenzoF6
Copy link
Author

Ok thanks, yes i'm the root of the docker and have persmission of writng in it. So i think that i've to update the permission of the anomalib forlder to write and modify folders in my docker.

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