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

Visualising segmented images #23

Open
svmaskery opened this issue Jun 8, 2022 · 4 comments
Open

Visualising segmented images #23

svmaskery opened this issue Jun 8, 2022 · 4 comments

Comments

@svmaskery
Copy link

svmaskery commented Jun 8, 2022

When I add the --save_segmentation_images tag as shown below to train the model, I get an error as shown below. The same thing happens when I try to run the evaluation too.

python bin/run_patchcore.py --gpu 0 --seed 0 --save_patchcore_model --save_segmentation_images \
--log_group IM224_WR50_L2-3_P01_D1024-1024_PS-3_AN-1_S0 --log_online --log_project MVTecAD_Results results \
patch_core -b wideresnet50 -le layer2 -le layer3 --faiss_on_gpu \
--pretrain_embed_dimension 1024  --target_embed_dimension 1024 --anomaly_scorer_num_nn 1 --patchsize 3 \
sampler -p 0.1 approx_greedy_coreset dataset --resize 256 --imagesize 224 "${dataset_flags[@]}" mvtec $datapath

Error traceback:

Traceback (most recent call last):                                                                                                                                                                         
  File "bin/run_patchcore.py", line 435, in <module>
    main()
  File "/home/shreevijay/anaconda3/envs/patch_off/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/shreevijay/anaconda3/envs/patch_off/lib/python3.8/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/shreevijay/anaconda3/envs/patch_off/lib/python3.8/site-packages/click/core.py", line 1689, in invoke
    return _process_result(rv)
  File "/home/shreevijay/anaconda3/envs/patch_off/lib/python3.8/site-packages/click/core.py", line 1626, in _process_result
    value = ctx.invoke(self._result_callback, value, **ctx.params)
  File "/home/shreevijay/anaconda3/envs/patch_off/lib/python3.8/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "bin/run_patchcore.py", line 166, in run
    patchcore.utils.plot_segmentation_images(
  File "/home/shreevijay/anaconda3/envs/patch_off/lib/python3.8/site-packages/patchcore/utils.py", line 51, in plot_segmentation_images
    image = image_transform(image)
  File "bin/run_patchcore.py", line 149, in image_transform
    dataloaders["testing"].dataset.transform_std
AttributeError: 'MVTecDataset' object has no attribute 'transform_std'

'transform_std', 'transform_mean' and similar attributes are undefined and shows an AttributeError. Please check the code associated to the tag --save_segmentation_images.

@Confusezius
Copy link
Collaborator

Oh thanks for noticing - when moving to the official repository, it seems that two dataset attributes got lost!

To address this, it should hopefully be enough to assign the attributes:

self.transform_mean = IMAGENET_MEAN
self.transform_std = IMAGENET_STD

in src/patchcore/datasets/mvtec > MVTecDataset > __init__().

Let me know if that worked or if other errors are thrown!

We will hopefully be able to push a fix soon :).

@svmaskery
Copy link
Author

That did not exactly fix the issue but I got it running, no problem. The --save_segmentation_images is working fine as now but please do the necessary changes. Anyways, the mean and standard deviation is taken from the imagenet dataset, how will the results compare if a custom dataset is used. Does it make a difference?

@PauloFavero
Copy link

PauloFavero commented Aug 10, 2023

Give a look at #80 (comment)

@wyweather
Copy link

Give a look at #80 (comment)

Hello, how should I do to get a prediction on the image, like this?
Uploading 微信图片_20240131225259.png…

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

4 participants