Spaces:
Configuration error
Configuration error
Download utils.py from erwann/Face-editor: direct link, hf CLI and curl.
- Browser
- Download file 475 Bytes
-
https://huggingface.co/spaces/erwann/Face-editor/resolve/main/utils.py
- Command line
-
hf download hf://spaces/erwann/Face-editor/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/erwann/Face-editor/resolve/main/utils.py
475 Bytes
| import time | |
| import matplotlib.pyplot as plt | |
| import numpy as np | |
| import torch | |
| import torch.nn.functional as F | |
| from skimage.color import lab2rgb, rgb2lab | |
| from torch import nn | |
| def freeze_module(module): | |
| for param in module.parameters(): | |
| param.requires_grad = False | |
| def get_device(): | |
| device = "cuda" if torch.cuda.is_available() else "cpu" | |
| if torch.backends.mps.is_available() and torch.backends.mps.is_built(): | |
| device = "mps" | |
| return (device) | |