Giter Site home page Giter Site logo

some quesion about detection about anoddpm HOT 5 CLOSED

hk011 avatar hk011 commented on May 31, 2024
some quesion about detection

from anoddpm.

Comments (5)

jamdodot avatar jamdodot commented on May 31, 2024

Like you, I also made an error in the test after the training, but the channel of my args is 3. The problem I encountered during the test is that args["img_size"] is of float type, resulting in the following error.

Since image dtype is floating point, you must specify '
'the data_range parameter. Please read the documentation '
'carefully (including the note). It is recommended that '
'you always specify the data_range anyway.

https://github.com/scikit-image/scikit-image/blob/6569fbfeb2891a7498418e2d5b8af9e851ca2102/skimage/metrics/_structural_similarity.py#LL194C30-L194C30

The outermost layer of the faulting method stack is the following line of code

image.permute(0, 2, 3, 1).reshape(*args["img_size"], image.shape[1]),

return ssim(real.detach().cpu().numpy(), recon.detach().cpu().numpy(), channel_axis=2)

My training args are as follows

{
  "img_size": [
    256,
    256
  ],
  "Batch_Size": 1,
  "EPOCHS": 3000,
  "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": 800,
  "weight_decay": 0.0,
  "save_imgs": true,
  "save_vids": false,
  "dropout": 0,
  "attention_resolutions": "16,8",
  "num_heads": 2,
  "num_head_channels": -1,
  "noise_fn": "simplex",
  "channels": 3,
  "dataset": "leather"
}

from anoddpm.

Julian-Wyatt avatar Julian-Wyatt commented on May 31, 2024

Like you, I also made an error in the test after the training, but the channel of my args is 3. The problem I encountered during the test is that args["img_size"] is of float type, resulting in the following error.

Since image dtype is floating point, you must specify '
'the data_range parameter. Please read the documentation '
'carefully (including the note). It is recommended that '
'you always specify the data_range anyway.

https://github.com/scikit-image/scikit-image/blob/6569fbfeb2891a7498418e2d5b8af9e851ca2102/skimage/metrics/_structural_similarity.py#LL194C30-L194C30

The outermost layer of the faulting method stack is the following line of code

image.permute(0, 2, 3, 1).reshape(*args["img_size"], image.shape[1]),

return ssim(real.detach().cpu().numpy(), recon.detach().cpu().numpy(), channel_axis=2)

My training args are as follows

{
  "img_size": [
    256,
    256
  ],
  "Batch_Size": 1,
  "EPOCHS": 3000,
  "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": 800,
  "weight_decay": 0.0,
  "save_imgs": true,
  "save_vids": false,
  "dropout": 0,
  "attention_resolutions": "16,8",
  "num_heads": 2,
  "num_head_channels": -1,
  "noise_fn": "simplex",
  "channels": 3,
  "dataset": "leather"
}

The most likely answer here is that the code just needs a check if 3 channels are given with an edge case (there could be a nicer way but I'm not super familiar off the top of my head with the SSIM method from sklearn) - When writing my original codebase I naïvely hard coded the channels in some areas leading to issues above.

from anoddpm.

Julian-Wyatt avatar Julian-Wyatt commented on May 31, 2024

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:

  1. 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

  1. 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) : 屏幕截图 2023-06-03 134954

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.

The direct test methods had a couple of bugs towards the end of my development, so I apologise. Clearly, a device error here should be quick and easy to fix and rerun?

Regarding the second issue.
It is hard to say what the specific issue is here with the model being so large. However, it is evidently a channel issue; so I would ensure that the resulting channels are as expected throughout the Simplex calculations, and when passing the image into the model.
Any further issues, please feel free to reach out.

from anoddpm.

ZZZGGGG avatar ZZZGGGG commented on May 31, 2024

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:

  1. 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

  1. 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) : 屏幕截图 2023-06-03 134954
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.

The direct test methods had a couple of bugs towards the end of my development, so I apologise. Clearly, a device error here should be quick and easy to fix and rerun?

Regarding the second issue. It is hard to say what the specific issue is here with the model being so large. However, it is evidently a channel issue; so I would ensure that the resulting channels are as expected throughout the Simplex calculations, and when passing the image into the model. Any further issues, please feel free to reach out.

Hello, Professor, your work is very wonderful, but I have some questions when I reproduce your paper, that is, why can the batchsize only be 1? When I change it to a different multiple, the model will report an error during the diffusion process

from anoddpm.

Julian-Wyatt avatar Julian-Wyatt commented on May 31, 2024

Hello, Professor, your work is very wonderful, but I have some questions when I reproduce your paper, that is, why can the batchsize only be 1? When I change it to a different multiple, the model will report an error during the diffusion process

Moved to new issue

from anoddpm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.