Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,23 +3,18 @@ import torch
|
|
| 3 |
from diffusers import I2VGenXLPipeline
|
| 4 |
from diffusers.utils import export_to_gif, load_image
|
| 5 |
import tempfile
|
| 6 |
-
import spaces
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
# Initialize the pipeline with CUDA support
|
| 11 |
pipeline = I2VGenXLPipeline.from_pretrained("ali-vilab/i2vgen-xl", torch_dtype=torch.float16, variant="fp16")
|
| 12 |
-
pipeline.to(device)
|
| 13 |
return pipeline
|
| 14 |
|
| 15 |
def generate_gif(prompt, image, negative_prompt, num_inference_steps, guidance_scale, seed):
|
| 16 |
-
# Check if CUDA is available and set the device
|
| 17 |
-
|
| 18 |
# Initialize the pipeline within the function
|
| 19 |
-
pipeline = initialize_pipeline(
|
| 20 |
|
| 21 |
# Set the generator seed
|
| 22 |
-
generator = torch.Generator(
|
| 23 |
|
| 24 |
# Check if an image is provided
|
| 25 |
if image is not None:
|
|
@@ -66,7 +61,7 @@ with gr.Blocks() as demo:
|
|
| 66 |
|
| 67 |
text_generate_button.click(
|
| 68 |
fn=generate_gif,
|
| 69 |
-
inputs=[text_prompt,
|
| 70 |
outputs=text_output_video
|
| 71 |
)
|
| 72 |
|
|
|
|
| 3 |
from diffusers import I2VGenXLPipeline
|
| 4 |
from diffusers.utils import export_to_gif, load_image
|
| 5 |
import tempfile
|
|
|
|
| 6 |
|
| 7 |
+
def initialize_pipeline():
|
| 8 |
+
# Initialize the pipeline without CUDA support
|
|
|
|
| 9 |
pipeline = I2VGenXLPipeline.from_pretrained("ali-vilab/i2vgen-xl", torch_dtype=torch.float16, variant="fp16")
|
|
|
|
| 10 |
return pipeline
|
| 11 |
|
| 12 |
def generate_gif(prompt, image, negative_prompt, num_inference_steps, guidance_scale, seed):
|
|
|
|
|
|
|
| 13 |
# Initialize the pipeline within the function
|
| 14 |
+
pipeline = initialize_pipeline()
|
| 15 |
|
| 16 |
# Set the generator seed
|
| 17 |
+
generator = torch.Generator().manual_seed(seed)
|
| 18 |
|
| 19 |
# Check if an image is provided
|
| 20 |
if image is not None:
|
|
|
|
| 61 |
|
| 62 |
text_generate_button.click(
|
| 63 |
fn=generate_gif,
|
| 64 |
+
inputs=[text_prompt, None, text_negative_prompt, text_num_inference_steps, text_guidance_scale, text_seed],
|
| 65 |
outputs=text_output_video
|
| 66 |
)
|
| 67 |
|