sjtuplayer / anomalydiffusion

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

Trainer #77

Open Vietsol-AnhHaiLe opened 1 week ago

Vietsol-AnhHaiLe commented 1 week ago

(Anomalydiffusion) haianh@admin:~/anomalydiffusion$ python main.py --spatial_encoder_embedding --data_enhance --base configs/latent-diffusion/txt2img-1p4B-finetune-encoder+embedding.yaml -t --actual_resume models/ldm/text2img-large/model.ckpt -n test --gpus 0 --init_word anomaly --mvtec_path=/home/haianh/anomalydiffusion/mvtec Global seed set to 23 Running on GPUs 0 Loading model from models/ldm/text2img-large/model.ckpt Traceback (most recent call last): File "main.py", line 644, in model = load_model_from_config(config, opt.actual_resume) File "main.py", line 30, in load_model_from_config model = instantiate_from_config(config.model) File "/home/haianh/anomalydiffusion/ldm/util.py", line 86, in instantiate_from_config return get_obj_from_str(config["target"])(config.get("params", dict()), kwargs) File "/home/haianh/anomalydiffusion/ldm/util.py", line 94, in get_obj_from_str return getattr(importlib.import_module(module, package=None), cls) File "/home/haianh/miniconda3/envs/Anomalydiffusion/lib/python3.8/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 975, in _find_and_load_unlocked File "", line 671, in _load_unlocked File "", line 783, in exec_module File "", line 219, in _call_with_frames_removed File "/home/haianh/anomalydiffusion/ldm/models/diffusion/ddpm.py", line 26, in from ldm.models.autoencoder import VQModelInterface, IdentityFirstStage, AutoencoderKL File "/home/haianh/anomalydiffusion/ldm/models/autoencoder.py", line 5, in from taming.modules.vqvae.quantize import VectorQuantizer2 as VectorQuantizer ModuleNotFoundError: No module named 'taming.modules.vqvae'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "main.py", line 887, in if trainer.global_rank == 0: NameError: name 'trainer' is not defined

Colorful12 commented 1 week ago

Hi. I solved this problem by creating quantize.py in ./anomalydiffusion/taming/modules/vqvae/ and using the code from here. Hope this solution works for you as well.

Vietsol-AnhHaiLe commented 1 week ago

it work but i have this next fault (Anomalydiffusion) haianh@admin:~/anomalydiffusion$ CUDA_VISIBLE_DEVICES=$gpu_id python main.py --spatial_encoder_embedding --data_enhance --base configs/latent-diffusion/txt2img-1p4B-finetune-encoder+embedding.yaml -t --actual_resume models/ldm/text2img-large/model.ckpt -n test --gpus 0 --init_word anomaly --mvtec_path=/home/haianh/anomalydiffusion/mvtec Global seed set to 23 Running on GPUs 0 Loading model from models/ldm/text2img-large/model.ckpt LatentDiffusion: Running in eps-prediction mode Killed

Vietsol-AnhHaiLe commented 6 days ago

ModuleNotFoundError: No module named 'imgaug' Traceback (most recent call last): File "generate_with_mask.py", line 15, in from ldm.data.personalized import Positive_sample_with_generated_mask File "/home/haianh/anomalydiffusion/ldm/data/personalized.py", line 10, in from .mask_generate import generate_mask File "/home/haianh/anomalydiffusion/ldm/data/mask_generate.py", line 4, in import imgaug.augmenters as iaa ModuleNotFoundError: No module named 'imgaug'

Colorful12 commented 6 days ago

This should resolve the error. pip install imgaug

Vietsol-AnhHaiLe commented 6 days ago

i have pip install imgaug (Anomalydiffusion) haianh@admin:~/anomalydiffusion$ CUDA_VISIBLE_DEVICES=$gpu_id python run-mvtec.py --data_path=/home/haianh/anomalydiffusion/mvtec Global seed set to 23 Running on GPUs 0, Loading model from ./models/ldm/text2img-large/model.ckpt LatentDiffusion: Running in eps-prediction mode Killed Traceback (most recent call last): File "generate_mask.py", line 13, in from ldm.data.personalized import Personalized_mvtec_mask File "/home/haianh/anomalydiffusion/ldm/data/personalized.py", line 10, in from .mask_generate import generate_mask File "/home/haianh/anomalydiffusion/ldm/data/mask_generate.py", line 4, in import imgaug.augmenters as iaa ModuleNotFoundError: No module named 'imgaug' Traceback (most recent call last): File "generate_with_mask.py", line 15, in from ldm.data.personalized import Positive_sample_with_generated_mask File "/home/haianh/anomalydiffusion/ldm/data/personalized.py", line 10, in from .mask_generate import generate_mask File "/home/haianh/anomalydiffusion/ldm/data/mask_generate.py", line 4, in import imgaug.augmenters as iaa ModuleNotFoundError: No module named 'imgaug' Global seed set to 23 Running on GPUs 0, Loading model from ./models/ldm/text2img-large/model.ckpt LatentDiffusion: Running in eps-prediction mode Killed Traceback (most recent call last): File "generate_mask.py", line 13, in from ldm.data.personalized import Personalized_mvtec_mask File "/home/haianh/anomalydiffusion/ldm/data/personalized.py", line 10, in from .mask_generate import generate_mask File "/home/haianh/anomalydiffusion/ldm/data/mask_generate.py", line 4, in import imgaug.augmenters as iaa ModuleNotFoundError: No module named 'imgaug' Traceback (most recent call last): File "generate_with_mask.py", line 15, in from ldm.data.personalized import Positive_sample_with_generated_mask File "/home/haianh/anomalydiffusion/ldm/data/personalized.py", line 10, in from .mask_generate import generate_mask File "/home/haianh/anomalydiffusion/ldm/data/mask_generate.py", line 4, in import imgaug.augmenters as iaa ModuleNotFoundError: No module named 'imgaug' Global seed set to 23 Running on GPUs 0, Loading model from ./models/ldm/text2img-large/model.ckpt LatentDiffusion: Running in eps-prediction mode Killed Traceback (most recent call last): File "generate_mask.py", line 13, in from ldm.data.personalized import Personalized_mvtec_mask File "/home/haianh/anomalydiffusion/ldm/data/personalized.py", line 10, in from .mask_generate import generate_mask File "/home/haianh/anomalydiffusion/ldm/data/mask_generate.py", line 4, in import imgaug.augmenters as iaa ModuleNotFoundError: No module named 'imgaug' Traceback (most recent call last): File "generate_with_mask.py", line 15, in from ldm.data.personalized import Positive_sample_with_generated_mask File "/home/haianh/anomalydiffusion/ldm/data/personalized.py", line 10, in from .mask_generate import generate_mask File "/home/haianh/anomalydiffusion/ldm/data/mask_generate.py", line 4, in import imgaug.augmenters as iaa ModuleNotFoundError: No module named 'imgaug'