Martim-Ramos-Neural commited on
Commit
bcbc123
·
verified ·
1 Parent(s): 86f8d75

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -14
app.py CHANGED
@@ -37,12 +37,12 @@ feature_extractor = CLIPFeatureExtractor.from_pretrained("openai/clip-vit-base-p
37
 
38
  # Function
39
  @spaces.GPU(duration=30,queue=False)
40
- def generate_image(prompt, base="Realistic", motion="", step=8, resolution="Square", duration=5, progress=gr.Progress()):
41
  global step_loaded
42
  global base_loaded
43
  global motion_loaded
44
 
45
- print(prompt, base, step, resolution, duration)
46
 
47
  # Set resolution
48
  if resolution == "Square":
@@ -71,12 +71,11 @@ def generate_image(prompt, base="Realistic", motion="", step=8, resolution="Squa
71
  def progress_callback(i, t, z):
72
  progress((i+1, step))
73
 
74
- num_frames = duration * 10 # Assuming 10 FPS
75
- output = pipe(prompt=prompt, guidance_scale=1.2, num_inference_steps=step, width=width, height=height, num_frames=num_frames, callback=progress_callback, callback_steps=1)
76
 
77
  name = str(uuid.uuid4()).replace("-", "")
78
  path = f"/tmp/{name}.mp4"
79
- export_to_video(output.frames, path, fps=10) # Export all frames to video
80
  return path
81
 
82
 
@@ -138,14 +137,6 @@ with gr.Blocks(css="style.css") as demo:
138
  value="Square",
139
  interactive=True
140
  )
141
- select_duration = gr.Slider(
142
- label='Video Duration (seconds)',
143
- minimum=1,
144
- maximum=30,
145
- step=1,
146
- value=5,
147
- interactive=True
148
- )
149
  submit = gr.Button(
150
  scale=1,
151
  variant='primary'
@@ -164,7 +155,7 @@ with gr.Blocks(css="style.css") as demo:
164
  prompt.submit
165
  ],
166
  fn=generate_image,
167
- inputs=[prompt, select_base, select_motion, select_step, select_resolution, select_duration],
168
  outputs=[video],
169
  api_name="instant_video",
170
  queue=False
 
37
 
38
  # Function
39
  @spaces.GPU(duration=30,queue=False)
40
+ def generate_image(prompt, base="Realistic", motion="", step=8, resolution="Square", progress=gr.Progress()):
41
  global step_loaded
42
  global base_loaded
43
  global motion_loaded
44
 
45
+ print(prompt, base, step, resolution)
46
 
47
  # Set resolution
48
  if resolution == "Square":
 
71
  def progress_callback(i, t, z):
72
  progress((i+1, step))
73
 
74
+ output = pipe(prompt=prompt, guidance_scale=1.2, num_inference_steps=step, width=width, height=height, callback=progress_callback, callback_steps=1)
 
75
 
76
  name = str(uuid.uuid4()).replace("-", "")
77
  path = f"/tmp/{name}.mp4"
78
+ export_to_video(output.frames[0], path, fps=10)
79
  return path
80
 
81
 
 
137
  value="Square",
138
  interactive=True
139
  )
 
 
 
 
 
 
 
 
140
  submit = gr.Button(
141
  scale=1,
142
  variant='primary'
 
155
  prompt.submit
156
  ],
157
  fn=generate_image,
158
+ inputs=[prompt, select_base, select_motion, select_step, select_resolution],
159
  outputs=[video],
160
  api_name="instant_video",
161
  queue=False