我想要一天分享一點「LLM從底層堆疊的技術」,並且每篇文章長度控制在三分鐘以內,讓大家不會壓力太大,但是又能夠每天成長一點。
animation_prompts = {0: "a photo of a fantastic spaceship",
24: "a photo of a fantastic lunar landing module"}
可以在 Negative Prompt 中加入您不想看到的內容,例如:
negative_prompt = "trucks, clouds, Earth"
我們現在創建動畫物件:
animator = Animator(api_context = context,
animation_prompts = animation_prompts,
negative_prompt = negative_prompt,
args = args)
我們保存生成的每一幀:
for idx, frame in enumerate(animator.render()):
frame.save(f"frame_{idx:05d}.png")
Animator 物件現在會產生動畫幀,然後製作影片:
from stability_sdk.utils import create_video_from_frames
from tqdm import tqdm
animator = Animator(api_context = api.Context(STABILITY_HOST, STABILITY_KEY),
animation_prompts = animation_prompts,
negative_prompt = negative_prompt,
args = args,
out_dir = "video_01")
for _ in tqdm(animator.render(), total = args.max_frames):
pass
create_video_from_frames(animator.out_dir, "video.mp4", fps = 24)
欲播放影片,則鍵入以下程式:
from IPython.display import display, Video
display(Video("/content/video.mp4", embed = True))
影片結果截圖為:















