Spaces:
Runtime error
Runtime error
cocktailpeanut
commited on
Commit
•
8ef362c
1
Parent(s):
ebbffeb
update
Browse files- app.py +8 -6
- requirements.txt +2 -2
app.py
CHANGED
@@ -3,6 +3,7 @@ import torch
|
|
3 |
import os
|
4 |
import spaces
|
5 |
import uuid
|
|
|
6 |
|
7 |
from diffusers import AnimateDiffPipeline, MotionAdapter, EulerDiscreteScheduler
|
8 |
from diffusers.utils import export_to_video
|
@@ -26,11 +27,12 @@ step_loaded = None
|
|
26 |
base_loaded = "Realistic"
|
27 |
motion_loaded = None
|
28 |
|
29 |
-
|
30 |
-
if not torch.cuda.is_available():
|
31 |
-
raise NotImplementedError("No GPU detected!")
|
32 |
-
|
33 |
-
device = "cuda"
|
|
|
34 |
dtype = torch.float16
|
35 |
pipe = AnimateDiffPipeline.from_pretrained(bases[base_loaded], torch_dtype=dtype).to(device)
|
36 |
pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config, timestep_spacing="trailing", beta_schedule="linear")
|
@@ -172,4 +174,4 @@ with gr.Blocks(css="style.css") as demo:
|
|
172 |
|
173 |
gr.Markdown(MORE)
|
174 |
|
175 |
-
demo.queue().launch()
|
|
|
3 |
import os
|
4 |
import spaces
|
5 |
import uuid
|
6 |
+
import devicetorch
|
7 |
|
8 |
from diffusers import AnimateDiffPipeline, MotionAdapter, EulerDiscreteScheduler
|
9 |
from diffusers.utils import export_to_video
|
|
|
27 |
base_loaded = "Realistic"
|
28 |
motion_loaded = None
|
29 |
|
30 |
+
## Ensure model and scheduler are initialized in GPU-enabled function
|
31 |
+
#if not torch.cuda.is_available():
|
32 |
+
# raise NotImplementedError("No GPU detected!")
|
33 |
+
#
|
34 |
+
#device = "cuda"
|
35 |
+
device = devicetorch.get(torch)
|
36 |
dtype = torch.float16
|
37 |
pipe = AnimateDiffPipeline.from_pretrained(bases[base_loaded], torch_dtype=dtype).to(device)
|
38 |
pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config, timestep_spacing="trailing", beta_schedule="linear")
|
|
|
174 |
|
175 |
gr.Markdown(MORE)
|
176 |
|
177 |
+
demo.queue().launch()
|
requirements.txt
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
accelerate
|
2 |
diffusers
|
3 |
gradio
|
4 |
-
torch
|
5 |
transformers
|
6 |
opencv-python
|
7 |
-
peft
|
|
|
1 |
accelerate
|
2 |
diffusers
|
3 |
gradio
|
4 |
+
#torch
|
5 |
transformers
|
6 |
opencv-python
|
7 |
+
peft
|