ShihaoZhaoZSH / Uni-ControlNet

[NeurIPS 2023] Uni-ControlNet: All-in-One Control to Text-to-Image Diffusion Models
MIT License
609 stars 42 forks source link

help: resolution: 512 --> resolution: 128, train error! #15

Open chenjingcheng opened 1 year ago

chenjingcheng commented 1 year ago

The same data, my training in controlnet code is ok.

raceback (most recent call last): File "/root/autodl-tmp/uni-controlnet/src/train/train.py", line 69, in main() File "/root/autodl-tmp/uni-controlnet/src/train/train.py", line 65, in main trainer.fit(model,dataloader,) File "/root/miniconda3/envs/controlnet/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py", line 529, in fit call._call_and_handle_interrupt( File "/root/miniconda3/envs/controlnet/lib/python3.10/site-packages/pytorch_lightning/trainer/call.py", line 42, in _call_and_handle_interrupt return trainer_fn(*args, kwargs) File "/root/miniconda3/envs/controlnet/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py", line 568, in _fit_impl self._run(model, ckpt_path=ckpt_path) File "/root/miniconda3/envs/controlnet/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py", line 973, in _run results = self._run_stage() File "/root/miniconda3/envs/controlnet/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py", line 1016, in _run_stage self.fit_loop.run() File "/root/miniconda3/envs/controlnet/lib/python3.10/site-packages/pytorch_lightning/loops/fit_loop.py", line 201, in run self.advance() File "/root/miniconda3/envs/controlnet/lib/python3.10/site-packages/pytorch_lightning/loops/fit_loop.py", line 354, in advance self.epoch_loop.run(self._data_fetcher) File "/root/miniconda3/envs/controlnet/lib/python3.10/site-packages/pytorch_lightning/loops/training_epoch_loop.py", line 133, in run self.advance(data_fetcher) File "/root/miniconda3/envs/controlnet/lib/python3.10/site-packages/pytorch_lightning/loops/training_epoch_loop.py", line 218, in advance batch_output = self.automatic_optimization.run(trainer.optimizers[0], kwargs) File "/root/miniconda3/envs/controlnet/lib/python3.10/site-packages/pytorch_lightning/loops/optimization/automatic.py", line 185, in run self._optimizer_step(kwargs.get("batch_idx", 0), closure) File "/root/miniconda3/envs/controlnet/lib/python3.10/site-packages/pytorch_lightning/loops/optimization/automatic.py", line 260, in _optimizer_step call._call_lightning_module_hook( File "/root/miniconda3/envs/controlnet/lib/python3.10/site-packages/pytorch_lightning/trainer/call.py", line 144, in _call_lightning_module_hook output = fn(args, kwargs) File "/root/miniconda3/envs/controlnet/lib/python3.10/site-packages/pytorch_lightning/core/module.py", line 1256, in optimizer_step optimizer.step(closure=optimizer_closure) File "/root/miniconda3/envs/controlnet/lib/python3.10/site-packages/pytorch_lightning/core/optimizer.py", line 155, in step step_output = self._strategy.optimizer_step(self._optimizer, closure, kwargs) File "/root/miniconda3/envs/controlnet/lib/python3.10/site-packages/pytorch_lightning/strategies/strategy.py", line 225, in optimizer_step return self.precision_plugin.optimizer_step(optimizer, model=model, closure=closure, kwargs) File "/root/miniconda3/envs/controlnet/lib/python3.10/site-packages/pytorch_lightning/plugins/precision/precision_plugin.py", line 114, in optimizer_step return optimizer.step(closure=closure, kwargs) File "/root/miniconda3/envs/controlnet/lib/python3.10/site-packages/torch/optim/optimizer.py", line 280, in wrapper out = func(args, kwargs) File "/root/miniconda3/envs/controlnet/lib/python3.10/site-packages/torch/optim/optimizer.py", line 33, in _use_grad ret = func(self, *args, kwargs) File "/root/miniconda3/envs/controlnet/lib/python3.10/site-packages/torch/optim/adamw.py", line 148, in step loss = closure() File "/root/miniconda3/envs/controlnet/lib/python3.10/site-packages/pytorch_lightning/plugins/precision/precision_plugin.py", line 101, in _wrap_closure closure_result = closure() File "/root/miniconda3/envs/controlnet/lib/python3.10/site-packages/pytorch_lightning/loops/optimization/automatic.py", line 140, in call self._result = self.closure(*args, kwargs) File "/root/miniconda3/envs/controlnet/lib/python3.10/site-packages/pytorch_lightning/loops/optimization/automatic.py", line 126, in closure step_output = self._step_fn() File "/root/miniconda3/envs/controlnet/lib/python3.10/site-packages/pytorch_lightning/loops/optimization/automatic.py", line 307, in _training_step training_step_output = call._call_strategy_hook(trainer, "training_step", kwargs.values()) File "/root/miniconda3/envs/controlnet/lib/python3.10/site-packages/pytorch_lightning/trainer/call.py", line 291, in _call_strategy_hook output = fn(args, kwargs) File "/root/miniconda3/envs/controlnet/lib/python3.10/site-packages/pytorch_lightning/strategies/strategy.py", line 367, in training_step return self.model.training_step(*args, kwargs) File "/root/autodl-tmp/uni-controlnet/./ldm/models/diffusion/ddpm.py", line 443, in training_step loss, loss_dict = self.shared_step(batch) File "/root/autodl-tmp/uni-controlnet/./ldm/models/diffusion/ddpm.py", line 837, in shared_step loss = self(x, c) File "/root/miniconda3/envs/controlnet/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(*args, kwargs) File "/root/autodl-tmp/uni-controlnet/./ldm/models/diffusion/ddpm.py", line 849, in forward return self.p_losses(x, c, t, *args, *kwargs) File "/root/autodl-tmp/uni-controlnet/./ldm/models/diffusion/ddpm.py", line 889, in p_losses model_output = self.apply_model(x_noisy, t, cond) File "/root/autodl-tmp/uni-controlnet/./models/uni_controlnet.py", line 59, in apply_model local_control = self.local_adapter(x=x_noisy, timesteps=t, context=cond_txt, local_conditions=local_control) File "/root/miniconda3/envs/controlnet/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(args, kwargs) File "/root/autodl-tmp/uni-controlnet/./models/local_adapter.py", line 401, in forward local_features = self.feature_extractor(local_conditions) File "/root/miniconda3/envs/controlnet/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(*args, kwargs) File "/root/autodl-tmp/uni-controlnet/./models/local_adapter.py", line 157, in forward local_features = self.pre_extractor(local_conditions, None) File "/root/miniconda3/envs/controlnet/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(*args, *kwargs) File "/root/autodl-tmp/uni-controlnet/./models/local_adapter.py", line 27, in forward x = layer(x) File "/root/miniconda3/envs/controlnet/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(args, kwargs) File "/root/miniconda3/envs/controlnet/lib/python3.10/site-packages/torch/nn/modules/conv.py", line 463, in forward return self._conv_forward(input, self.weight, self.bias) File "/root/miniconda3/envs/controlnet/lib/python3.10/site-packages/torch/nn/modules/conv.py", line 459, in _conv_forward return F.conv2d(input, weight, bias, self.stride, RuntimeError: Given groups=1, weight of size [32, 21, 3, 3], expected input[64, 6, 128, 128] to have 21 channels, but got 6 channels instead

yairshp commented 7 months ago

+1