AstrAI-video-repo/main.py

305 lines
7.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
AstrAI项目介绍视频 - 第一部分:开场白与项目定位
"""
from manim import *
class Part1_Intro(Scene):
"""第一部分:开场白与项目定位"""
def construct(self):
# === 场景1Logo动画 ===
self.play_logo_intro()
# === 场景2开场白 ===
self.play_opening_speech()
# === 场景3核心要点展示 ===
self.play_key_points()
# === 场景4项目名称与总结 ===
self.play_project_name()
def play_logo_intro(self):
"""Logo动画展示"""
# 创建AstrAI Logo样式
logo_text = Text(
"AstrAI",
font_size=72,
font="SimHei",
)
# 创建副标题
subtitle = Text(
"轻量级 Transformer 训练推理框架",
font_size=28,
font="SimHei",
color=GRAY
)
# 居中排列
logo_text.next_to(subtitle, UP, buff=0.3)
subtitle.next_to(logo_text, DOWN, buff=0.3)
# 初始状态
logo_text.set_opacity(0)
subtitle.set_opacity(0)
# 动画淡入Logo
self.play(
FadeIn(logo_text, shift=UP * 0.5, scale=1.2),
run_time=1.5
)
# 动画:淡入副标题
self.play(
FadeIn(subtitle, shift=UP * 0.3),
run_time=1.0
)
# 短暂停留
self.wait(0.8)
# 淡出
self.play(
FadeOut(logo_text),
FadeOut(subtitle),
run_time=0.8
)
self.wait(0.5)
def play_opening_speech(self):
"""开场白"""
# 第一段文字
line1 = Text(
"在当下的大语言模型时代,",
font_size=32,
font="SimHei"
)
line1.to_edge(UP, buff=1.0)
self.play(Write(line1), run_time=1.0)
self.wait(0.5)
# 第二段文字
line2 = Text(
"我们见证了GPT、LLaMA等庞然大物。",
font_size=32,
font="SimHei"
)
line2.next_to(line1, DOWN, buff=0.3)
self.play(Write(line2), run_time=1.0)
self.wait(0.5)
# 第三段文字
line3 = Text(
"然而,这些模型对硬件要求极高,",
font_size=32,
font="SimHei"
)
line3.next_to(line2, DOWN, buff=0.3)
self.play(Write(line3), run_time=1.0)
self.wait(0.5)
# 第四段文字(关键问题)
line4 = Text(
"对于普通开发者来说往往遥不可及。",
font_size=32,
font="SimHei",
color=BLUE
)
line4.next_to(line3, DOWN, buff=0.3)
self.play(Write(line4), run_time=1.0)
self.wait(0.8)
# 思考问题
question = Text(
"我们能否创建一个既有用又能运行在普通电脑上的模型?",
font_size=28,
font="SimHei",
color=YELLOW
)
question.to_edge(DOWN, buff=1.5)
self.play(Write(question), run_time=1.5)
self.wait(1.0)
# 清除场景
self.play(
FadeOut(line1),
FadeOut(line2),
FadeOut(line3),
FadeOut(line4),
FadeOut(question),
run_time=0.8
)
self.wait(0.5)
def play_key_points(self):
"""核心要点展示"""
# 标题
title = Text(
"AstrAI 的核心特点",
font_size=40,
font="SimHei",
color=WHITE
)
title.to_edge(UP, buff=0.8)
self.play(Write(title), run_time=1.0)
self.wait(0.5)
# 要点1轻量级
point1_title = Text(
"轻量级",
font_size=36,
font="SimHei",
color=GREEN
)
point1_title.to_edge(LEFT, buff=2.0).shift(UP * 0.5)
point1_content = Text(
"1B参数中英双语",
font_size=24,
font="SimHei",
color=GRAY
)
point1_content.next_to(point1_title, DOWN, buff=0.2)
point1_content.align_to(point1_title, LEFT)
self.play(
Write(point1_title),
Write(point1_content),
run_time=1.0
)
self.wait(0.8)
# 要点2完全自研
point2_title = Text(
"完全自研",
font_size=36,
font="SimHei",
color=BLUE
)
point2_title.next_to(point1_title, DOWN, buff=0.8)
point2_title.align_to(point1_title, LEFT)
point2_content = Text(
"核心代码全部开源",
font_size=24,
font="SimHei",
color=GRAY
)
point2_content.next_to(point2_title, DOWN, buff=0.2)
point2_content.align_to(point2_title, LEFT)
self.play(
Write(point2_title),
Write(point2_content),
run_time=1.0
)
self.wait(0.8)
# 要点3训练推理一体化
point3_title = Text(
"训练推理一体化",
font_size=36,
font="SimHei",
color=ORANGE
)
point3_title.next_to(point2_title, DOWN, buff=0.8)
point3_title.align_to(point1_title, LEFT)
point3_content = Text(
"从预训练到推理,一套全搞定",
font_size=24,
font="SimHei",
color=GRAY
)
point3_content.next_to(point3_title, DOWN, buff=0.2)
point3_content.align_to(point3_title, LEFT)
self.play(
Write(point3_title),
Write(point3_content),
run_time=1.0
)
self.wait(1.0)
# 清除场景(保留标题)
self.play(
FadeOut(point1_title),
FadeOut(point1_content),
FadeOut(point2_title),
FadeOut(point2_content),
FadeOut(point3_title),
FadeOut(point3_content),
run_time=0.5
)
self.wait(0.3)
def play_project_name(self):
"""项目名称与总结"""
# 项目名称 - 使用普通颜色避免兼容性问题
project_name = Text(
"AstrAI",
font_size=80,
font="SimHei",
color=BLUE
)
project_name.center()
# 动画:放大出现
self.play(
project_name.animate.scale(1.2),
run_time=1.5
)
self.wait(1.0)
# 补充说明
tagline = Text(
"1B参数 · 中英双语 · 完全自研 · 训练推理一体化",
font_size=24,
font="SimHei",
color=YELLOW
)
tagline.next_to(project_name, DOWN, buff=0.5)
self.play(Write(tagline), run_time=1.0)
self.wait(1.0)
# 淡出结束
self.play(
FadeOut(project_name),
FadeOut(tagline),
run_time=1.0
)
self.wait(0.5)
# 配置类
class AstrAIVideoConfig:
"""视频配置"""
video_quality = "high_quality" # high_quality, production_quality
preview = True # 是否预览
save_last_frame = True # 保存最后一帧
if __name__ == "__main__":
# 运行配置
config = AstrAIVideoConfig()
# 渲染视频
if config.preview:
# 预览模式
from manim import *
scene = Part1_Intro()
scene.render()
else:
# 渲染视频文件
# manim -pql main.py Part1_Intro
# manim -pqh main.py Part1_Intro
pass