Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import torch
|
| 2 |
from diffusers import HunyuanVideoPipeline, HunyuanVideoTransformer3DModel
|
| 3 |
from PIL import Image
|
|
@@ -5,7 +6,6 @@ import numpy as np
|
|
| 5 |
import gradio as gr
|
| 6 |
import os
|
| 7 |
import gc
|
| 8 |
-
import spaces
|
| 9 |
|
| 10 |
|
| 11 |
model_id = "hunyuanvideo-community/HunyuanVideo"
|
|
@@ -40,6 +40,8 @@ def generate(prompt, width=832, height=832, num_inference_steps=30, lora_id=None
|
|
| 40 |
return output
|
| 41 |
finally:
|
| 42 |
# Always clear memory, even if an error occurs
|
|
|
|
|
|
|
| 43 |
torch.cuda.empty_cache()
|
| 44 |
gc.collect()
|
| 45 |
|
|
|
|
| 1 |
+
import spaces
|
| 2 |
import torch
|
| 3 |
from diffusers import HunyuanVideoPipeline, HunyuanVideoTransformer3DModel
|
| 4 |
from PIL import Image
|
|
|
|
| 6 |
import gradio as gr
|
| 7 |
import os
|
| 8 |
import gc
|
|
|
|
| 9 |
|
| 10 |
|
| 11 |
model_id = "hunyuanvideo-community/HunyuanVideo"
|
|
|
|
| 40 |
return output
|
| 41 |
finally:
|
| 42 |
# Always clear memory, even if an error occurs
|
| 43 |
+
if lora_id and lora_id.strip() != "":
|
| 44 |
+
pipe.unload_lora_weights()
|
| 45 |
torch.cuda.empty_cache()
|
| 46 |
gc.collect()
|
| 47 |
|