You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm confused about the error: AttributeError: 'float' object has no attribute 'backward'
It occurs during the image-to-image translation. The details about the error information are:
I think the problem is caused by the line 149 in edit_pipline.py so I transfer it into a tensor, but it doesn't work. If possible, I wanna know what's wrong here. Thanks a lot!
The text was updated successfully, but these errors were encountered:
I added this line of code loss = torch.tensor(0.0, requires_grad=True) after line 142 in the edit_pipline.py file, and it will work. Maybe you can try it?
Hi, I'm confused about the error: AttributeError: 'float' object has no attribute 'backward'
It occurs during the image-to-image translation. The details about the error information are:
────────── Traceback (most recent call last) ────────────────────────────────╮
│ /pix2pix-zero/src/edit_synthetic.py:51 in │
│ │
│ 48 │ pipe = EditingPipeline.from_pretrained(args.model_path, torch_dtype=torch_dtype).to( │
│ 49 │ pipe.scheduler = DDIMScheduler.from_config(pipe.scheduler.config) │
│ 50 │ │
│ ❱ 51 │ rec_pil, edit_pil = pipe(args.prompt_str, │
│ 52 │ │ num_inference_steps=args.num_ddim_steps, │
│ 53 │ │ x_in=x, │
│ 54 │ │ edit_dir=construct_direction(args.task_name), │
│ │
│ /pix2pix-zero/src/utils/edit_pipeline.py:150 in call │
│ │
│ 147 │ │ │ │ │ │ ref = d_ref_t2attn[t.item()][name].detach().to(device) │
│ 148 │ │ │ │ │ │ cal = ((curr-ref)**2).sum((1,2)).mean(0) │
│ 149 │ │ │ │ │ │ loss += torch.tensor(cal, requires_grad=True) │
│ ❱ 150 │ │ │ │ loss.backward(retain_graph=False) │
│ 151 │ │ │ │ opt.step() │
│ 152 │ │ │ │ │
│ 153 │ │ │ │ # recompute the noise │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'float' object has no attribute 'backward'
I think the problem is caused by the line 149 in edit_pipline.py so I transfer it into a tensor, but it doesn't work. If possible, I wanna know what's wrong here. Thanks a lot!
The text was updated successfully, but these errors were encountered: