Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -16,6 +16,8 @@ from diffusers.utils import export_to_video
|
|
16 |
from diffusers.utils import load_image
|
17 |
from PIL import Image
|
18 |
|
|
|
|
|
19 |
from transformers import LlamaModel
|
20 |
|
21 |
import torch
|
@@ -55,13 +57,27 @@ def init_predictor():
|
|
55 |
torch_dtype=torch.bfloat16,
|
56 |
device="cpu",
|
57 |
).to("cpu").eval()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
pipe = SkyreelsVideoPipeline.from_pretrained(
|
59 |
base_model_id,
|
60 |
transformer=transformer,
|
61 |
text_encoder=text_encoder,
|
62 |
torch_dtype=torch.bfloat16,
|
63 |
).to("cpu")
|
64 |
-
|
|
|
|
|
|
|
65 |
|
66 |
negative_prompt = "Aerial view, aerial view, overexposed, low quality, deformation, a poor composition, bad hands, bad teeth, bad eyes, bad limbs, distortion"
|
67 |
|
|
|
16 |
from diffusers.utils import load_image
|
17 |
from PIL import Image
|
18 |
|
19 |
+
from torchao.quantization import float8_weight_only
|
20 |
+
from torchao.quantization import quantize_
|
21 |
from transformers import LlamaModel
|
22 |
|
23 |
import torch
|
|
|
57 |
torch_dtype=torch.bfloat16,
|
58 |
device="cpu",
|
59 |
).to("cpu").eval()
|
60 |
+
quantize_(text_encoder, float8_weight_only(), device="cpu")
|
61 |
+
text_encoder.to("cpu")
|
62 |
+
torch.cuda.empty_cache()
|
63 |
+
quantize_(transformer, float8_weight_only(), device="cpu")
|
64 |
+
transformer.to("cpu")
|
65 |
+
torch.cuda.empty_cache()
|
66 |
+
offload_config=OffloadConfig(
|
67 |
+
high_cpu_memory=True,
|
68 |
+
parameters_level=True,
|
69 |
+
compiler_transformer=False,
|
70 |
+
)
|
71 |
pipe = SkyreelsVideoPipeline.from_pretrained(
|
72 |
base_model_id,
|
73 |
transformer=transformer,
|
74 |
text_encoder=text_encoder,
|
75 |
torch_dtype=torch.bfloat16,
|
76 |
).to("cpu")
|
77 |
+
Offload.offload(
|
78 |
+
pipeline=pipe,
|
79 |
+
config=offload_config,
|
80 |
+
)
|
81 |
|
82 |
negative_prompt = "Aerial view, aerial view, overexposed, low quality, deformation, a poor composition, bad hands, bad teeth, bad eyes, bad limbs, distortion"
|
83 |
|