Spaces:
Runtime error
Runtime error
Delete frame_gen.py
Browse files- frame_gen.py +0 -50
frame_gen.py
DELETED
|
@@ -1,50 +0,0 @@
|
|
| 1 |
-
import torch
|
| 2 |
-
from diffusers import AnimateDiffPipeline, DDIMScheduler, MotionAdapter
|
| 3 |
-
from diffusers.utils import export_to_gif
|
| 4 |
-
from moviepy.editor import VideoFileClip, concatenate_videoclips
|
| 5 |
-
|
| 6 |
-
adapter = MotionAdapter.from_pretrained("guoyww/animatediff-motion-adapter-v1-5-2", torch_dtype=torch.float16)
|
| 7 |
-
|
| 8 |
-
pipeline = AnimateDiffPipeline.from_pretrained("emilianJR/epiCRealism", motion_adapter=adapter, torch_dtype=torch.float16)
|
| 9 |
-
scheduler = DDIMScheduler.from_pretrained(
|
| 10 |
-
"emilianJR/epiCRealism",
|
| 11 |
-
subfolder="scheduler",
|
| 12 |
-
clip_sample=False,
|
| 13 |
-
timestep_spacing="linspace",
|
| 14 |
-
beta_schedule="linear",
|
| 15 |
-
steps_offset=1,
|
| 16 |
-
)
|
| 17 |
-
pipeline.scheduler = scheduler
|
| 18 |
-
pipeline.enable_vae_slicing()
|
| 19 |
-
#pipeline.enable_model_cpu_offload()
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
def gen_movie(frames_desc):
|
| 23 |
-
frames_desc = [frames_desc[0]]
|
| 24 |
-
x = 1
|
| 25 |
-
for frame_description in frames_desc:
|
| 26 |
-
output = pipeline(
|
| 27 |
-
prompt="frame_description",
|
| 28 |
-
negative_prompt="high resolution",
|
| 29 |
-
num_frames=16,
|
| 30 |
-
guidance_scale=7.5,
|
| 31 |
-
num_inference_steps=50,
|
| 32 |
-
generator=torch.Generator("cpu").manual_seed(0),
|
| 33 |
-
)
|
| 34 |
-
frames = output.frames[0]
|
| 35 |
-
export_to_gif(frames, f'animation{x}.gif')
|
| 36 |
-
x += 1
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
# List to store VideoFileClip objects for each input GIF
|
| 40 |
-
video_clips = []
|
| 41 |
-
|
| 42 |
-
# Load each input GIF file and append it to the list
|
| 43 |
-
for x in range(1,2):
|
| 44 |
-
video_clips.append(VideoFileClip(f'animation{x}.gif'))
|
| 45 |
-
|
| 46 |
-
# Concatenate the video clips to create a single video
|
| 47 |
-
final_clip = concatenate_videoclips(video_clips)
|
| 48 |
-
|
| 49 |
-
# Export the final video to a new MP4 file
|
| 50 |
-
final_clip.write_videofile("combined_video.mp4", codec="libx264", fps=24)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|