Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -120,6 +120,8 @@ def simple_generative_inference(image, mode, model, n_iterations=10, step_size=0
|
|
| 120 |
# Update image tensor
|
| 121 |
image_tensor = image_tensor + step_size * grad
|
| 122 |
image_tensor = torch.clamp(image_tensor, -eps, eps) # Keep within range
|
|
|
|
|
|
|
| 123 |
|
| 124 |
# Generate gradient visualization
|
| 125 |
grad_image = grad.abs().mean(dim=1).squeeze().cpu().numpy()
|
|
|
|
| 120 |
# Update image tensor
|
| 121 |
image_tensor = image_tensor + step_size * grad
|
| 122 |
image_tensor = torch.clamp(image_tensor, -eps, eps) # Keep within range
|
| 123 |
+
image_tensor = image_tensor.clone().detach().requires_grad_(True) # Ensure it's a new leaf tensor
|
| 124 |
+
image_tensor.retain_grad()
|
| 125 |
|
| 126 |
# Generate gradient visualization
|
| 127 |
grad_image = grad.abs().mean(dim=1).squeeze().cpu().numpy()
|