mrcuddle commited on
Commit
30a8deb
·
verified ·
1 Parent(s): d03a679

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -5,7 +5,6 @@ from diffusers.utils import export_to_gif, load_image
5
  import tempfile
6
  import spaces
7
 
8
- # Function to initialize the pipeline with CUDA support
9
  @spaces.GPU
10
  def initialize_pipeline():
11
  # Check if CUDA is available and set the device
@@ -16,7 +15,10 @@ def initialize_pipeline():
16
  pipeline.to(device)
17
  return pipeline, device
18
 
19
- def generate_gif(pipeline, device, prompt, image, negative_prompt, num_inference_steps, guidance_scale, seed):
 
 
 
20
  # Set the generator seed
21
  generator = torch.Generator(device=device).manual_seed(seed)
22
 
@@ -49,8 +51,6 @@ def generate_gif(pipeline, device, prompt, image, negative_prompt, num_inference
49
 
50
  # Create the Gradio interface with tabs
51
  with gr.Blocks() as demo:
52
- pipeline, device = initialize_pipeline()
53
-
54
  with gr.TabItem("Generate from Text or Image"):
55
  with gr.Row():
56
  with gr.Column():
@@ -67,7 +67,7 @@ with gr.Blocks() as demo:
67
 
68
  generate_button.click(
69
  fn=generate_gif,
70
- inputs=[pipeline, device, prompt, image, negative_prompt, num_inference_steps, guidance_scale, seed],
71
  outputs=output_video
72
  )
73
 
 
5
  import tempfile
6
  import spaces
7
 
 
8
  @spaces.GPU
9
  def initialize_pipeline():
10
  # Check if CUDA is available and set the device
 
15
  pipeline.to(device)
16
  return pipeline, device
17
 
18
+ def generate_gif(prompt, image, negative_prompt, num_inference_steps, guidance_scale, seed):
19
+ # Initialize the pipeline and device within the function
20
+ pipeline, device = initialize_pipeline()
21
+
22
  # Set the generator seed
23
  generator = torch.Generator(device=device).manual_seed(seed)
24
 
 
51
 
52
  # Create the Gradio interface with tabs
53
  with gr.Blocks() as demo:
 
 
54
  with gr.TabItem("Generate from Text or Image"):
55
  with gr.Row():
56
  with gr.Column():
 
67
 
68
  generate_button.click(
69
  fn=generate_gif,
70
+ inputs=[prompt, image, negative_prompt, num_inference_steps, guidance_scale, seed],
71
  outputs=output_video
72
  )
73