Spaces:
Runtime error
Runtime error
kevinwang676
commited on
Update app_new.py
Browse files- app_new.py +9 -3
app_new.py
CHANGED
@@ -21,7 +21,7 @@ from diffsynth import save_video, ModelManager, SVDVideoPipeline
|
|
21 |
from diffsynth import SDVideoPipeline, ControlNetConfigUnit, VideoData, save_frames
|
22 |
from diffsynth.extensions.RIFE import RIFESmoother
|
23 |
|
24 |
-
|
25 |
|
26 |
# Constants
|
27 |
MAX_SEED = np.iinfo(np.int32).max
|
@@ -74,7 +74,13 @@ def update_frames(video_in):
|
|
74 |
up_video = VideoData(
|
75 |
video_file=video_in)
|
76 |
frame_len = len(up_video)
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
@spaces.GPU(duration=180)
|
80 |
def generate(
|
@@ -227,7 +233,7 @@ with gr.Blocks(css=CSS, js=JS, theme="soft") as demo:
|
|
227 |
cache_examples="lazy",
|
228 |
examples_per_page=4,
|
229 |
)
|
230 |
-
video_in.upload(update_frames, inputs=[video_in], outputs=[num_frames])
|
231 |
submit_event = submit_btn.click(fn=generate, inputs=[video_in, image_in, prompt, seed, num_inference_steps, num_frames, height, width, animatediff_batch_size, animatediff_stride, fps_id], outputs=[video, seed], api_name="video")
|
232 |
#stop_btn.click(fn=None, inputs=None, outputs=None, cancels=[submit_event])
|
233 |
|
|
|
21 |
from diffsynth import SDVideoPipeline, ControlNetConfigUnit, VideoData, save_frames
|
22 |
from diffsynth.extensions.RIFE import RIFESmoother
|
23 |
|
24 |
+
import cv2
|
25 |
|
26 |
# Constants
|
27 |
MAX_SEED = np.iinfo(np.int32).max
|
|
|
74 |
up_video = VideoData(
|
75 |
video_file=video_in)
|
76 |
frame_len = len(up_video)
|
77 |
+
video_path = video_in
|
78 |
+
cap = cv2.VideoCapture(video_path)
|
79 |
+
fps_in = cap.get(cv2.CAP_PROP_FPS)
|
80 |
+
width_in = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
|
81 |
+
height_in = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
82 |
+
cap.release()
|
83 |
+
return gr.update(maximum=frame_len), gr.update(value=fps_in), gr.update(value=width_in), gr.update(value=height_in)
|
84 |
|
85 |
@spaces.GPU(duration=180)
|
86 |
def generate(
|
|
|
233 |
cache_examples="lazy",
|
234 |
examples_per_page=4,
|
235 |
)
|
236 |
+
video_in.upload(update_frames, inputs=[video_in], outputs=[num_frames, fps_id, width, height])
|
237 |
submit_event = submit_btn.click(fn=generate, inputs=[video_in, image_in, prompt, seed, num_inference_steps, num_frames, height, width, animatediff_batch_size, animatediff_stride, fps_id], outputs=[video, seed], api_name="video")
|
238 |
#stop_btn.click(fn=None, inputs=None, outputs=None, cancels=[submit_event])
|
239 |
|