sjtuplayer / anomalydiffusion

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

Issue in generate_with_mask.py Function - Image Generation Error #70

Closed CVKim closed 1 month ago

CVKim commented 2 months ago

Traceback (most recent call last): File "/storage/research/workspaces/gwangyeol/anomalydiffusion/generate_with_mask.py", line 191, in images=model.log_images(batch,sample=False,inpaint=True,unconditional_only=True,adaptive_mask=opt.adaptive_mask) File "/storage/research/workspaces/gwangyeol/anomalydiffusion/ldm/models/diffusion/ddpm.py", line 1451, in log_images z, c,total_dict, x, xrec, xc = self.get_input(batch, self.first_stage_key, File "/storage/research/workspaces/gwangyeol/anomalydiffusion/ldm/models/diffusion/ddpm.py", line 794, in get_input c,position = self.get_learned_conditioning(xc,x=masked_img,name=name) File "/storage/research/workspaces/gwangyeol/anomalydiffusion/ldm/models/diffusion/ddpm.py", line 633, in get_learned_conditioning c,position = self.cond_stage_model.encode(c, cond_img=x,embedding_manager=self.embedding_manager,name=name) File "/storage/research/workspaces/gwangyeol/anomalydiffusion/ldm/modules/encoders/modules.py", line 130, in encode return self(text,kwargs) File "/usr/local/lib/python3.9/dist-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, *kwargs) File "/usr/local/lib/python3.9/dist-packages/torch/nn/modules/module.py", line 1527, in _call_impl return forward_call(args, kwargs) File "/storage/research/workspaces/gwangyeol/anomalydiffusion/ldm/modules/encoders/modules.py", line 122, in forward z,position = self.transformer(tokens, return_embeddings=True, kwargs) File "/usr/local/lib/python3.9/dist-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, *kwargs) File "/usr/local/lib/python3.9/dist-packages/torch/nn/modules/module.py", line 1527, in _call_impl return forward_call(args, kwargs) File "/storage/research/workspaces/gwangyeol/anomalydiffusion/ldm/modules/x_transformer.py", line 615, in forward x,position = embedding_manager(x, embedded_x,kwargs) File "/usr/local/lib/python3.9/dist-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, *kwargs) File "/usr/local/lib/python3.9/dist-packages/torch/nn/modules/module.py", line 1527, in _call_impl return forward_call(args, kwargs) File "/storage/research/workspaces/gwangyeol/anomalydiffusion/ldm/modules/embedding_manager2.py", line 123, in forward placeholder_embedding.append(self.string_to_param_dict[i]) File "/usr/local/lib/python3.9/dist-packages/torch/nn/modules/container.py", line 739, in getitem return getattr(self, attr) File "/usr/local/lib/python3.9/dist-packages/torch/nn/modules/module.py", line 1695, in getattr

**raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")

AttributeError: 'ParameterDict' object has no attribute 'cable+cut_outer_insulation'**


CUDA_VISIBLE_DEVICES=0,1 python run-mvtec.py --data_path=/storage/image_datasets/mvtec_anomaly_detection_real --adaptive_mask

the generate_with_mask.py script creates the image, image-mask, mask, and ori folders, but no images are generated.

Could you please help identify the reason for this issue based on the error described above? Thank you.

sjtuplayer commented 1 month ago

you can check whether your name-anomaly.txt contains cable+cut_outer_insulation