Ldhlwh / DFMGAN

[AAAI 2023] Official implementation of "Few-Shot Defect Image Generation via Defect-Aware Feature Manipulation".
https://arxiv.org/abs/2303.02389
Other
83 stars 11 forks source link

a bug when read gray image #22

Closed TimZhang001 closed 9 months ago

TimZhang001 commented 9 months ago

in file dataset_tool.py line 73

img = np.array(PIL.Image.open(fname))

need to be convert to

Load image and convert to RGB if needed.

img = np.array(PIL.Image.open(fname).convert('RGB'))

Ldhlwh commented 9 months ago

Thanks for your suggestion. Currently this repo only supports RGB images. If you want to use it on grayscale images, I don't recommend converting them into RGB format since the samples rendered by the generator may not be exactly in grayscale. You are encouraged to slightly modify the codes and train a DFMGAN which renders one-channel images.

boxbox2 commented 2 months ago

Thanks for your suggestion. Currently this repo only supports RGB images. If you want to use it on grayscale images, I don't recommend converting them into RGB format since the samples rendered by the generator may not be exactly in grayscale. You are encouraged to slightly modify the codes and train a DFMGAN which renders one-channel images.

在MVTEC数据集中,如果我想dest grid_glue_mask它会报如下错误,在我改成img = np.array(PIL.Image.open(fname).convert('RGB'))成功解决了这个问题。

  File "dataset_tool.py", line 453, in convert_dataset
    img = np.concatenate((img, np.expand_dims(mask, axis = -1)), axis = 2)
  File "<__array_function__ internals>", line 6, in concatenate
numpy.AxisError: axis 2 is out of bounds for array of dimension 2

请问您说的You are encouraged to slightly modify the codes and train a DFMGAN which renders one-channel images.指的是什么呢?您是有遇到numpy.AxisError: axis 2 is out of bounds for array of dimension 2这个问题吗?

Ldhlwh commented 2 months ago

请问您说的You are encouraged to slightly modify the codes and train a DFMGAN which renders one-channel images.指的是什么呢?

@boxbox2 指的是在灰度图片上训单channel的模型效果可能更好(未经验证),因为可以减少参数并且没有RGB不一致的问题,不过用RGB也能训

CVKim commented 4 days ago

@Ldhlwh , @TimZhang001

https://github.com/Ldhlwh/DFMGAN/issues/22#issuecomment-1859045320

image

I modified the code in dataset_tool.py as follows, but it seems that there is an issue with proper generation during the training of the good and defect pkls.

Could you advise on which part needs further modification?

''' img = np.array(PIL.Image.open(fname).convert('RGB')) '''