fffiloni commited on
Commit
74d58ef
1 Parent(s): 3d7ab9b

Update imagic.py

Browse files
Files changed (1) hide show
  1. imagic.py +3 -2
imagic.py CHANGED
@@ -314,8 +314,9 @@ class ImagicStableDiffusionPipeline(DiffusionPipeline):
314
  loss = F.mse_loss(noise_pred, noise, reduction="none").mean([1, 2, 3]).mean()
315
  accelerator.backward(loss)
316
 
317
- optimizer.step()
318
- optimizer.zero_grad()
 
319
 
320
  # Checks if the accelerator has performed an optimization step behind the scenes
321
  if accelerator.sync_gradients:
 
314
  loss = F.mse_loss(noise_pred, noise, reduction="none").mean([1, 2, 3]).mean()
315
  accelerator.backward(loss)
316
 
317
+ with torch.no_grad():
318
+ optimizer.step()
319
+ optimizer.zero_grad()
320
 
321
  # Checks if the accelerator has performed an optimization step behind the scenes
322
  if accelerator.sync_gradients: