CutPaste icon indicating copy to clipboard operation
CutPaste copied to clipboard

Issue with the code CutPaste Anomaly detection

Open Chichiviriche opened this issue 2 years ago • 9 comments

Hello, first off all, thanks for that very interesting work. I've tried to reproduce these experiments. I'm under Ubuntu 20.04, python 3.8. I've installed all the requirements successfully. I've downloaded the bottle and wood dataset, Ok But none of the training is working :

python train.py --dataset_path /CutPaste/bottle/train --num_class 3 gives me the error : File "/home/laurent/.local/bin/.virtualenvs/pytorch/lib/python3.8/site-packages/torch/nn/modules/linear.py", line 85, in init self.weight = Parameter(torch.empty((out_features, in_features), **factory_kwargs)) TypeError: empty() received an invalid combination of arguments - got (tuple, dtype=NoneType, device=NoneType), but expected one of:

  • (tuple of ints size, *, tuple of names names, torch.memory_format memory_format, torch.dtype dtype, torch.layout layout, torch.device device, bool pin_memory, bool requires_grad)
  • (tuple of ints size, *, torch.memory_format memory_format, Tensor out, torch.dtype dtype, torch.layout layout, torch.device device, bool pin_memory, bool requires_grad)

python train.py --dataset_path /CutPaste/bottle/train --encoder efficientnet_b4 gives me the error : File "/home/laurent/.local/bin/.virtualenvs/pytorch/lib/python3.8/site-packages/torch/nn/functional.py", line 1848, in linear return torch._C._nn.linear(input, weight, bias) RuntimeError: mat1 and mat2 shapes cannot be multiplied (12x1792 and 512x512)

Can you help ? Is you code fully running ? Is there something I forgot in the configuration ? The bottle images are 900x900, the wood images are 1024x1024 Kind Regards,

Chichiviriche avatar Apr 04 '22 17:04 Chichiviriche

I have the same problem. At first, I thought the system was incompatible. Could we discuss ? [email protected] Screenshot from 2022-04-07 09-23-52

xaioffff avatar Apr 07 '22 01:04 xaioffff

I can't reproduce the error, I don't get the error during the training. If you can give me more info, I'll check @xaioffff @Chichiviriche

LilitYolyan avatar Apr 07 '22 11:04 LilitYolyan

@xaioffff @Chichiviriche Also check if the dataset structure is exact the same as here: https://github.com/LilitYolyan/CutPaste/issues/20#issuecomment-1087144630 Check if your bottle/train folder has this structure:

bottle └─── train | | └─── good

LilitYolyan avatar Apr 07 '22 11:04 LilitYolyan

I have the same problem. At first, I thought the system was incompatible. Could we discuss ? [email protected] Screenshot from 2022-04-07 09-23-52

Hello, I have encountered the same problem, may I ask if you have solved it

mouxinyue1 avatar Apr 18 '22 08:04 mouxinyue1

yes, my dataset structure is Ok otherwise I get another type of error. Could you guide us ? the code is quite complex, what king of info would help to find the cause of the error ? Kind regards,

Chichiviriche avatar Apr 20 '22 14:04 Chichiviriche

I made some progress: when i did git clone https://github.com/LilitYolyan/CutPaste.git, the train.py has not the def get_args(): part in the code. After adding those lines, I have now only a single error, which is; File "/home/laurent/.local/bin/.virtualenvs/pytorch/lib/python3.8/site-packages/torch/utils/data/sampler.py", line 102, in init raise ValueError("num_samples should be a positive integer " ValueError: num_samples should be a positive integer value, but got num_samples=0 Any idea ? Thanks

Chichiviriche avatar Apr 22 '22 15:04 Chichiviriche

also, you have to be sure that you specify the full path to your dataset. python train.py --dataset_path /bottle/train --num_class 3 --> leads to an error even if you are in the directory where bootle is python train.py --dataset_path /home/laurent/CutPaste/bottle/train --num_class 3 is starting correctly Regards,

Chichiviriche avatar Apr 25 '22 08:04 Chichiviriche

@LilitYolyan

    return torch._C._nn.linear(input, weight, bias)
RuntimeError: mat1 and mat2 shapes cannot be multiplied (12x2048 and 512x512)

I am getting this error with the ff command

python train.py --dataset_path ../data/train --encoder resnet50 --pretrained --num_gpus 1

My ../data/train is just composed of jpg images.

I would just want to do self-supervised pretraining without annotations/labels.

sarmientoj24 avatar May 02 '22 14:05 sarmientoj24

Seems like it has soemthing to do with this dims

    def __init__(self, encoder='resnet18', pretrained=True, dims=[512, 512, 512, 512, 512, 512, 512, 512, 128], num_class=3):

What would be the dims for resnet50?

sarmientoj24 avatar May 02 '22 14:05 sarmientoj24