Spaces:
Runtime error
Runtime error
Alex Ergasti
commited on
Commit
·
ab0a826
1
Parent(s):
16607f4
Add spaces support
Browse files
app.py
CHANGED
|
@@ -4,7 +4,7 @@ torch.backends.cuda.matmul.allow_tf32 = True
|
|
| 4 |
torch.backends.cudnn.allow_tf32 = True
|
| 5 |
|
| 6 |
import os
|
| 7 |
-
|
| 8 |
from diffusers.models import AutoencoderKL
|
| 9 |
from models import FLAV_models
|
| 10 |
|
|
@@ -35,6 +35,7 @@ def setup_models():
|
|
| 35 |
|
| 36 |
device = "cuda"
|
| 37 |
vae = AutoencoderKL.from_pretrained(f"stabilityai/sd-vae-ft-ema")
|
|
|
|
| 38 |
|
| 39 |
model = FLAV_models["FLAV-B/1"](
|
| 40 |
latent_size= 256//8,
|
|
@@ -46,7 +47,7 @@ def setup_models():
|
|
| 46 |
|
| 47 |
ckpt_path = hf_hub_download(repo_id="MaverickAlex/R-FLAV", filename="aist-ema.pth")
|
| 48 |
|
| 49 |
-
state_dict = torch.load(ckpt_path)
|
| 50 |
|
| 51 |
ema = EMAModel(model.parameters())
|
| 52 |
ema.load_state_dict(state_dict)
|
|
@@ -63,7 +64,7 @@ def setup_models():
|
|
| 63 |
vocoder.to(device)
|
| 64 |
|
| 65 |
|
| 66 |
-
|
| 67 |
def generate_video(num_frames=10, steps=2, seed=42):
|
| 68 |
global vae, model, vocoder
|
| 69 |
# Setup device
|
|
|
|
| 4 |
torch.backends.cudnn.allow_tf32 = True
|
| 5 |
|
| 6 |
import os
|
| 7 |
+
import spaces
|
| 8 |
from diffusers.models import AutoencoderKL
|
| 9 |
from models import FLAV_models
|
| 10 |
|
|
|
|
| 35 |
|
| 36 |
device = "cuda"
|
| 37 |
vae = AutoencoderKL.from_pretrained(f"stabilityai/sd-vae-ft-ema")
|
| 38 |
+
vae.eval()
|
| 39 |
|
| 40 |
model = FLAV_models["FLAV-B/1"](
|
| 41 |
latent_size= 256//8,
|
|
|
|
| 47 |
|
| 48 |
ckpt_path = hf_hub_download(repo_id="MaverickAlex/R-FLAV", filename="aist-ema.pth")
|
| 49 |
|
| 50 |
+
state_dict = torch.load(ckpt_path, map_location="cpu")
|
| 51 |
|
| 52 |
ema = EMAModel(model.parameters())
|
| 53 |
ema.load_state_dict(state_dict)
|
|
|
|
| 64 |
vocoder.to(device)
|
| 65 |
|
| 66 |
|
| 67 |
+
@spaces.GPU
|
| 68 |
def generate_video(num_frames=10, steps=2, seed=42):
|
| 69 |
global vae, model, vocoder
|
| 70 |
# Setup device
|