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

AttributeError: 'MVTecDataset' object has no attribute 'transform_std' #80

Open
William9Baker opened this issue Jun 19, 2023 · 6 comments

Comments

@William9Baker
Copy link

What's wrong with this error?

@zsffuture
Copy link

I also encountered the same problem, did you solve it?

@zsffuture
Copy link

I solved this problem, because backbone is based on imagenet dataset training, so the mean and variance is imagenet, you can add it in src\patchcore\datasets\mvtec.py file can be seen at the top, and then modify it to add it.
image

@PauloFavero
Copy link

I fixed this issue in the simplenet repo with the following pull request: DonaldRR/SimpleNet#20
To fix the issue here in patchcore just follow the modifications in simplenet dateset folder.

@romanvelichkin
Copy link

Long story short:

in patchcore/datasets/mvtec.py in class MVTecDataset in def __init__ add this rows:

self.transform_std = IMAGENET_STD
self.transform_mean = IMAGENET_MEAN

rovodanica added a commit to rovodanica/patchcore-medical that referenced this issue Jan 24, 2024
@IESSTTJP
Copy link

I am using a different dataset, but adding those two sentences still reports the same error, can you please tell me in which rows they are added?

@DanielWell
Copy link

DanielWell commented Sep 4, 2024

I am using a different dataset, but adding those two sentences still reports the same error, can you please tell me in which rows they are added?

i also try this, but also report the same error, as you are. Maybe when run_patchcore.py->image_trainsform function to run , but mvtec.py->mvtec not init. Now, in run_patchcore.py->image_transform, this function,
def image_transform(image):
IMAGENET_MEAN = [0.485, 0.456, 0.406]
IMAGENET_STD = [0.229, 0.224, 0.225]
# in_std = np.array(
# dataloaders["testing"].dataset.transform_std
# ).reshape(-1, 1, 1)
# in_mean = np.array(
# #dataloaders["testing"].dataset.transform_mean
# ).reshape(-1, 1, 1)
in_std = np.array(IMAGENET_STD).reshape(-1, 1, 1)
in_mean = np.array(IMAGENET_MEAN).reshape(-1, 1, 1)
image = dataloaders["testing"].dataset.transform_img(image)
return np.clip(
(image.numpy() * in_std + in_mean) * 255, 0, 255
).astype(np.uint8)

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

6 participants