Spaces:
Runtime error
Runtime error
Delete utils.py
Browse files
utils.py
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
import torch
|
2 |
-
from huggingface_hub import hf_hub_download
|
3 |
-
from safetensors.torch import load_file
|
4 |
-
|
5 |
-
def load_unet_model(base, repo, ckpt, device="cuda"):
|
6 |
-
"""
|
7 |
-
Load the UNet model from Hugging Face Hub.
|
8 |
-
|
9 |
-
Args:
|
10 |
-
base (str): Base model name.
|
11 |
-
repo (str): Repository name.
|
12 |
-
ckpt (str): Checkpoint filename.
|
13 |
-
device (str): Device to load the model on.
|
14 |
-
|
15 |
-
Returns:
|
16 |
-
UNet2DConditionModel: Loaded UNet model.
|
17 |
-
"""
|
18 |
-
from diffusers import UNet2DConditionModel
|
19 |
-
unet = UNet2DConditionModel.from_config(base, subfolder="unet").to(device, torch.float16)
|
20 |
-
unet.load_state_dict(load_file(hf_hub_download(repo, ckpt), device=device))
|
21 |
-
return unet
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|