timothybrooks / instruct-pix2pix

Other
6.41k stars 542 forks source link

AttributeError: 'AutoencoderKL' object has no attribute 'quantize' #130

Open LitaoLiu01 opened 6 months ago

LitaoLiu01 commented 6 months ago

I run the model correctly in the first four train epochs using my own dataset, which is 320×240, but it have the error when it runs to the first validation.

File "/home/bingxing2/home/scx6d13/litaoliu/p2p_script/instruct-pix2pix-main/./stable_diffusion/ldm/models/diffusion/ddpm_edit.py", line 1084, in p_mean_variance xrecon, , [, , indices] = self.first_stage_model.quantize(x_recon) File "/home/bingxing2/home/scx6d13/.conda/envs/ip2p_cu113/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1185, in getattr raise AttributeError("'{}' object has no attribute '{}'".format( AttributeError: 'AutoencoderKL' object has no attribute 'quantize'

What is going on? Can he only process an image of the same length and width?

The full error is: Traceback (most recent call last): File "/home/bingxing2/home/scx6d13/litaoliu/p2p_script/instruct-pix2pix-main/main.py", line 817, in trainer.fit(model, data) File "/home/bingxing2/home/scx6d13/.conda/envs/ip2p_cu113/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 553, in fit self._run(model) File "/home/bingxing2/home/scx6d13/.conda/envs/ip2p_cu113/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 918, in _run self._dispatch() File "/home/bingxing2/home/scx6d13/.conda/envs/ip2p_cu113/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 986, in _dispatch self.accelerator.start_training(self) File "/home/bingxing2/home/scx6d13/.conda/envs/ip2p_cu113/lib/python3.9/site-packages/pytorch_lightning/accelerators/accelerator.py", line 92, in start_training self.training_type_plugin.start_training(trainer) File "/home/bingxing2/home/scx6d13/.conda/envs/ip2p_cu113/lib/python3.9/site-packages/pytorch_lightning/plugins/training_type/training_type_plugin.py", line 161, in start_training self._results = trainer.run_stage() File "/home/bingxing2/home/scx6d13/.conda/envs/ip2p_cu113/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 996, in run_stage return self._run_train() File "/home/bingxing2/home/scx6d13/.conda/envs/ip2p_cu113/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 1045, in _run_train self.fit_loop.run() File "/home/bingxing2/home/scx6d13/.conda/envs/ip2p_cu113/lib/python3.9/site-packages/pytorch_lightning/loops/base.py", line 111, in run self.advance(*args, kwargs) File "/home/bingxing2/home/scx6d13/.conda/envs/ip2p_cu113/lib/python3.9/site-packages/pytorch_lightning/loops/fit_loop.py", line 200, in advance epoch_output = self.epoch_loop.run(train_dataloader) File "/home/bingxing2/home/scx6d13/.conda/envs/ip2p_cu113/lib/python3.9/site-packages/pytorch_lightning/loops/base.py", line 112, in run self.on_advance_end() File "/home/bingxing2/home/scx6d13/.conda/envs/ip2p_cu113/lib/python3.9/site-packages/pytorch_lightning/loops/epoch/training_epoch_loop.py", line 177, in on_advance_end self._run_validation() File "/home/bingxing2/home/scx6d13/.conda/envs/ip2p_cu113/lib/python3.9/site-packages/pytorch_lightning/loops/epoch/training_epoch_loop.py", line 256, in _run_validation self.val_loop.run() File "/home/bingxing2/home/scx6d13/.conda/envs/ip2p_cu113/lib/python3.9/site-packages/pytorch_lightning/loops/base.py", line 111, in run self.advance(*args, *kwargs) File "/home/bingxing2/home/scx6d13/.conda/envs/ip2p_cu113/lib/python3.9/site-packages/pytorch_lightning/loops/dataloader/evaluation_loop.py", line 110, in advance dl_outputs = self.epoch_loop.run( File "/home/bingxing2/home/scx6d13/.conda/envs/ip2p_cu113/lib/python3.9/site-packages/pytorch_lightning/loops/base.py", line 111, in run self.advance(args, kwargs) File "/home/bingxing2/home/scx6d13/.conda/envs/ip2p_cu113/lib/python3.9/site-packages/pytorch_lightning/loops/epoch/evaluation_epoch_loop.py", line 116, in advance self.on_evaluation_batch_end(output, batch, batch_idx, dataloader_idx) File "/home/bingxing2/home/scx6d13/.conda/envs/ip2p_cu113/lib/python3.9/site-packages/pytorch_lightning/loops/epoch/evaluation_epoch_loop.py", line 197, in on_evaluation_batch_end self.trainer.call_hook(hook_name, output, batch, batch_idx, dataloader_idx) File "/home/bingxing2/home/scx6d13/.conda/envs/ip2p_cu113/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 1217, in call_hook trainer_hook(args, kwargs) File "/home/bingxing2/home/scx6d13/.conda/envs/ip2p_cu113/lib/python3.9/site-packages/pytorch_lightning/trainer/callback_hook.py", line 199, in on_validation_batch_end callback.on_validation_batch_end(self, self.lightning_module, outputs, batch, batch_idx, dataloader_idx) File "/home/bingxing2/home/scx6d13/litaoliu/p2p_script/instruct-pix2pix-main/main.py", line 473, in on_validation_batch_end self.log_img(pl_module, batch, batch_idx, split="val") File "/home/bingxing2/home/scx6d13/litaoliu/p2p_script/instruct-pix2pix-main/main.py", line 436, in log_img images = pl_module.log_images(batch, split=split, self.log_images_kwargs) File "/home/bingxing2/home/scx6d13/.conda/envs/ip2p_cu113/lib/python3.9/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context return func(args, kwargs) File "/home/bingxing2/home/scx6d13/litaoliu/p2p_script/instruct-pix2pix-main/./stable_diffusion/ldm/models/diffusion/ddpm_edit.py", line 1332, in log_images samples, z_denoise_row = self.sample_log(cond=c,batch_size=N,ddim=use_ddim, File "/home/bingxing2/home/scx6d13/.conda/envs/ip2p_cu113/lib/python3.9/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context return func(*args, *kwargs) File "/home/bingxing2/home/scx6d13/litaoliu/p2p_script/instruct-pix2pix-main/./stable_diffusion/ldm/models/diffusion/ddpm_edit.py", line 1259, in sample_log samples, intermediates = self.sample(cond=cond, batch_size=batch_size, File "/home/bingxing2/home/scx6d13/.conda/envs/ip2p_cu113/lib/python3.9/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context return func(args, kwargs) File "/home/bingxing2/home/scx6d13/litaoliu/p2p_script/instruct-pix2pix-main/./stable_diffusion/ldm/models/diffusion/ddpm_edit.py", line 1243, in sample return self.p_sample_loop(cond, File "/home/bingxing2/home/scx6d13/.conda/envs/ip2p_cu113/lib/python3.9/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context return func(*args, *kwargs) File "/home/bingxing2/home/scx6d13/litaoliu/p2p_script/instruct-pix2pix-main/./stable_diffusion/ldm/models/diffusion/ddpm_edit.py", line 1215, in p_sample_loop img = self.p_sample(img, cond, ts, File "/home/bingxing2/home/scx6d13/.conda/envs/ip2p_cu113/lib/python3.9/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context return func(args, **kwargs) File "/home/bingxing2/home/scx6d13/litaoliu/p2p_script/instruct-pix2pix-main/./stable_diffusion/ldm/models/diffusion/ddpm_edit.py", line 1098, in p_sample outputs = self.p_mean_variance(x=x, c=c, t=t, clip_denoised=clip_denoised, File "/home/bingxing2/home/scx6d13/litaoliu/p2p_script/instruct-pix2pix-main/./stable_diffusion/ldm/models/diffusion/ddpm_edit.py", line 1084, in p_mean_variance xrecon, , [, , indices] = self.first_stage_model.quantize(x_recon) File "/home/bingxing2/home/scx6d13/.conda/envs/ip2p_cu113/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1185, in getattr raise AttributeError("'{}' object has no attribute '{}'".format( AttributeError: 'AutoencoderKL' object has no attribute 'quantize'

LitaoLiu01 commented 6 months ago

It also seems there is not the Method 'quantize' in 'AutoencoderKL' Class

LitaoLiu01 commented 6 months ago

So, should I add which 'quantize' Method to 'AutoencoderKL' Class