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

(PatchCore test error) AttributeError: 'NoneType' object has no attribute 'search' #29

Open
ValoraY opened this issue Oct 19, 2024 · 2 comments

Comments

@ValoraY
Copy link

ValoraY commented Oct 19, 2024

when I run CUDA_VISIBLE_DIVICES=0 python run.py -c configs/benchmark/patchcore/patchcore_256_100e.py -m test, I got message like this:

Traceback (most recent call last):
File "/data/xxx/PROJECTS/ADer/run.py", line 31, in
main()
File "/data/xxx/PROJECTS/ADer/run.py", line 27, in main
trainer.run()
File "/data/xxx/PROJECTS/ADer/trainer/patchcore_trainer.py", line 346, in run
self.test()
File "/home/xxx/anaconda3/envs/ader/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "/data/xxx/PROJECTS/ADer/trainer/patchcore_trainer.py", line 233, in test
self.scores, self.preds = self.net.net_patchcore.predict(self.imgs)
File "/data/xxx/PROJECTS/ADer/model/patchcore.py", line 747, in predict
patch_scores = image_scores = self.anomaly_scorer.predict([features])[0]
File "/data/xxx/PROJECTS/ADer/model/patchcore.py", line 542, in predict
query_distances, query_nns = self.imagelevel_nn(query_features)
File "/data/xxx/PROJECTS/ADer/model/patchcore.py", line 505, in
self.imagelevel_nn = lambda query: self.nn_method.run(
File "/data/xxx/PROJECTS/ADer/model/patchcore.py", line 275, in run
return self.search_index.search(query_features, n_nearest_neighbours)
AttributeError: 'NoneType' object has no attribute 'search'

@fozeke
Copy link

fozeke commented Oct 28, 2024

same question

@zhangzjn
Copy link
Owner

The following command can be used:
CUDA_VISIBLE_DEVICES=0 python run.py -c configs/benchmark/patchcore_256_100e.py -m train trainer.checkpoint=runs/benchmark/patchcore_256_100e/mvtec data.root=data/mvtec.
Currently, the PatchCore only supports 'train' mode. Since this method lacks a training process, it is equivalent to the test process.

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

3 participants