Update imagic.py
Browse files
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 |
-
|
318 |
-
|
|
|
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:
|