Spaces:
Running
Running
fix dtype bug on CPU (#1)
Browse files- fix dtype bug on CPU (bff0f0a3074e9a74a99037e7c1c815296606b738)
Co-authored-by: Joyce Lin <jycln@users.noreply.huggingface.co>
app.py
CHANGED
|
@@ -15,11 +15,13 @@ if st.button("🎬 Generate Video"):
|
|
| 15 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 16 |
dtype = torch.float16 if device == "cuda" else torch.float32
|
| 17 |
|
|
|
|
|
|
|
| 18 |
pipe = DiffusionPipeline.from_pretrained(
|
| 19 |
"damo-vilab/text-to-video-ms-1.7b",
|
| 20 |
-
torch_dtype=
|
| 21 |
-
variant="fp16" if
|
| 22 |
-
).to(
|
| 23 |
|
| 24 |
video_frames = pipe(prompt).frames # Returns list of PIL Images (frames)
|
| 25 |
|
|
|
|
| 15 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 16 |
dtype = torch.float16 if device == "cuda" else torch.float32
|
| 17 |
|
| 18 |
+
use_fp16 = torch.cuda.is_available()
|
| 19 |
+
|
| 20 |
pipe = DiffusionPipeline.from_pretrained(
|
| 21 |
"damo-vilab/text-to-video-ms-1.7b",
|
| 22 |
+
torch_dtype=torch.float16 if use_fp16 else torch.float32,
|
| 23 |
+
variant="fp16" if use_fp16 else None,
|
| 24 |
+
).to("cuda" if use_fp16 else "cpu")
|
| 25 |
|
| 26 |
video_frames = pipe(prompt).frames # Returns list of PIL Images (frames)
|
| 27 |
|