Hello author, I am honored to read your paper. After completing leather data set training, I tried to detect, but encountered some problems:
Here is my args file:
args19.json
{
"img_size": [256,256],
"Batch_Size": 1,
"EPOCHS": 1000,
"T": 1000,
"base_channels": 128,
"beta_schedule": "linear",
"channel_mults": "",
"loss-type": "l2",
"loss_weight": "none",
"train_start": true,
"lr": 1e-4,
"random_slice": true,
"sample_distance": 600,
"weight_decay": 0.0,
"save_imgs":true,
"save_vids":true,
"dropout":0,
"attention_resolutions":"16,8",
"num_heads":2,
"num_head_channels":-1,
"noise_fn":"simplex",
"dataset":"leather",
"channels": 1
}
After the training:
- Error is reported in evaluation.testing() immediately after train:
File "diffusion_training.py", line 153, in train
evaluation.testing(testing_dataset_loader, diffusion, ema=ema, args=args, model=model)
File "/home/dell/local/HK/AnoDDPM-master/evaluation.py", line 124, in testing
x = x.to(device)
NameError: name 'device' is not defined
- When I tried detection, I entered the following command:
python3 detection.py args19.json
Here, args19.json is the configuration file I trained with
But the following error is reported:
This is the shape of the layer for the row where the error occurred
Conv2d(1, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)
Traceback (most recent call last):
File "detection.py", line 959, in
anomalous_metric_calculation()
File "detection.py", line 226, in anomalous_metric_calculation
t_distance=200, denoise_fn=args["noise_fn"]
File "/home/dell/local/HK/AnoDDPM-master/GaussianDiffusion.py", line 354, in forward_backward
out = self.sample_p(model, x, t_batch, denoise_fn)
File "/home/dell/local/HK/AnoDDPM-master/GaussianDiffusion.py", line 299, in sample_p
out = self.p_mean_variance(model, x_t, t)
File "/home/dell/local/HK/AnoDDPM-master/GaussianDiffusion.py", line 279, in p_mean_variance
estimate_noise = model(x_t, t)
File "/home/dell/anaconda3/envs/pytorch181/lib/python3.6/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/dell/local/HK/AnoDDPM-master/UNet.py", line 400, in forward
h = module(h, time_embed)
File "/home/dell/anaconda3/envs/pytorch181/lib/python3.6/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/dell/local/HK/AnoDDPM-master/UNet.py", line 35, in forward
x = layer(x)
File "/home/dell/anaconda3/envs/pytorch181/lib/python3.6/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/dell/anaconda3/envs/pytorch181/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 399, in forward
return self._conv_forward(input, self.weight, self.bias)
File "/home/dell/anaconda3/envs/pytorch181/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 396, in _conv_forward
self.padding, self.dilation, self.groups)
RuntimeError: Given groups=1, weight of size [128, 1, 3, 3], expected input[1, 3, 256, 256] to have 1 channels, but got 3 channels instead
I wonder if there is something wrong with my detection call (I did not change your code) :
Maybe my question is relatively simple, but it has really caused me a lot of trouble. I would like to express my deep thanks again for troubling you.