Spaces:
Sleeping
Sleeping
Download diffusion_core/utils/model_utils.py from hugging-apps/inverse-and-edit: direct link, hf CLI and curl.
- Browser
- Download file 230 Bytes
-
https://huggingface.co/spaces/hugging-apps/inverse-and-edit/resolve/main/diffusion_core/utils/model_utils.py
- Command line
-
hf download hf://spaces/hugging-apps/inverse-and-edit/diffusion_core/utils/model_utils.py
-
curl -L -o model_utils.py https://huggingface.co/spaces/hugging-apps/inverse-and-edit/resolve/main/diffusion_core/utils/model_utils.py
230 Bytes
| import torch | |
| def use_deterministic(): | |
| torch.backends.cudnn.benchmark = False | |
| torch.backends.cudnn.deterministic = True | |
| def toggle_grad(model, mode=True): | |
| for p in model.parameters(): | |
| p.requires_grad = mode | |