sjtuplayer / anomalydiffusion

[AAAI 2024] AnomalyDiffusion: Few-Shot Anomaly Image Generation with Diffusion Model
MIT License
114 stars 14 forks source link

Some questions #48

Closed DonghoonPark12 closed 1 month ago

DonghoonPark12 commented 2 months ago

Dear Author, I have some questions

  1. I find that, In (main.py, generate_with_mask.py), 'sample'=False, 'inpaint'=True, and In (train_mask.py, generate_mask.py) 'sample'=True, 'inpaint'=False. In LatentDiffusion.log_images method, how does it work differently when sample=True or inpaint=True?

  2. What do the log images -sample_gs.jpg and -sample_scaled_gs.jpg saved when running train_mask.py mean?

  3. A defect image is created using a mask on a random normal image. At this time, isn't there a case where the defect mask is not mapped properly to the normal image and the object deviates from it?(If the mask is over the background)

  4. In 'Personalized_mvtec_mask' class, I really don't know the meaning of these two line. l=len(mask_files)//3
    (why divide by 3 ???, ) (Why do we use only 1/3 of the total mask when creating a mask?)

*self._length = self.num_images repeats** (What does it mean to increase the total data size by 2000 times?)

That open source is helpful to me. Thanks ahead.

sjtuplayer commented 2 months ago

Hi, for the question 3 and 4:

  1. There is only a small possibility where the mask is outside the object (which only usually happens in screw). But even if sometimes the mask is outside the object, our model can still generate corresponding masks.
  2. As noted in the paper, we use 1/3 of the data to train our model. So we only use 1/3 of the masks. Note: The 'repeats' operation is just used to increase the dataset length since the training images are too few, which may not be enough even for only one batch data.
DonghoonPark12 commented 1 month ago

Thank you for your reply!