Spaces:
Paused
Paused
Update app.py
Browse files2 unmodified lines3456784 unmodified lines1314151617181920212223242526272829303132332 unmodified linesimport numpy as npimport torchfrom diffusers import DiffusionPipeline, DPMSolverMultistepSchedulerpipe = DiffusionPipeline.from_pretrained("cerspense/zeroscope_v2_576w", torch_dtype=torch.float16)pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)4 unmodified linesvideo_frames = np.array(video_frames)video_frames = (video_frames * 255).astype(np.uint8)# Get the dimensions of the framesheight, width, channels = video_frames.shape[2:]# Define the video writer objectfourcc = cv2.VideoWriter_fourcc(*'mp4v') # Codec for .mp4 filesfps = 24 # Frames per secondvideo_writer = cv2.VideoWriter('output_video.mp4', fourcc, fps, (width, height))# Write each frame to the videofor i in range(video_frames.shape[0]):frame = video_frames[i]video_writer.write(frame)# Release the video writer objectvideo_writer.release()print("Video has been created successfully.")return 'output_video.mp4'2 unmodified lines34567894 unmodified lines1415161718192021222324252627282 unmodified linesimport numpy as npimport torchfrom diffusers import DiffusionPipeline, DPMSolverMultistepSchedulerfrom moviepy.editor import ImageSequenceClippipe = DiffusionPipeline.from_pretrained("cerspense/zeroscope_v2_576w", torch_dtype=torch.float16)pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)4 unmodified linesvideo_frames = np.array(video_frames)video_frames = (video_frames * 255).astype(np.uint8)# Convert frames from (N, H, W, C) to list of (H, W, C)frames_list = [frame for frame in video_frames]# Create a video clip from the framesfps = 24 # Frames per secondclip = ImageSequenceClip(frames_list, fps=fps)# Write the video fileclip.write_videofile("output_video.mp4", codec="libx264")print("Video has been created successfully.")return 'output_video.mp4'
app.py+7-12