|
import gradio as gr |
|
|
|
|
|
|
|
def make_custom_css(): |
|
"""カスタムCSSを作成してレスポンシブ対応およびエラースタイルを定義""" |
|
|
|
return combined_css |
|
|
|
css = make_custom_css() |
|
|
|
gr_ui = gr.Blocks(css=css).queue() |
|
with gr_ui: |
|
|
|
gr.HTML("<h1>FramePack - 画像から動画生成</h1>") |
|
|
|
|
|
with gr.Row(): |
|
with gr.Column(): |
|
|
|
input_image = gr.Image( |
|
source='upload', |
|
type="numpy", |
|
label="画像をアップロード", |
|
height=320 |
|
) |
|
|
|
|
|
prompt = gr.Textbox( |
|
label="プロンプト", |
|
placeholder="The camera smoothly orbits around the center of the scene, keeping the center point fixed and always in view" |
|
) |
|
|
|
|
|
quick_prompts = [ |
|
["The camera smoothly orbits around the center of the scene, keeping the center point fixed and always in view"], |
|
] |
|
example_prompts = gr.Dataset( |
|
samples=quick_prompts, |
|
label='クイックプロンプト', |
|
samples_per_page=10, |
|
components=[prompt] |
|
) |
|
example_prompts.click(lambda x: x[0], inputs=[example_prompts], outputs=prompt) |
|
|
|
|
|
with gr.Row(): |
|
start_button = gr.Button("生成開始", variant="primary") |
|
stop_button = gr.Button("生成停止", interactive=False) |
|
|
|
|
|
seed = gr.Number( |
|
label="シード値", |
|
value=31337, |
|
precision=0 |
|
) |
|
video_length = gr.Slider( |
|
label="動画の長さ (最大5秒)", |
|
minimum=1, |
|
maximum=5, |
|
value=3, |
|
step=0.1 |
|
) |
|
steps = gr.Slider( |
|
label="推論ステップ数", |
|
minimum=1, |
|
maximum=100, |
|
value=25, |
|
step=1 |
|
) |
|
teacache = gr.Checkbox( |
|
label="TeaCacheを使用", |
|
value=True, |
|
info="高速化しますが、手指の生成品質が若干低下する可能性があります。" |
|
) |
|
|
|
with gr.Column(): |
|
|
|
preview = gr.Image( |
|
label="プレビュー", |
|
visible=False, |
|
height=200 |
|
) |
|
|
|
result_video = gr.Video( |
|
label="生成された動画", |
|
autoplay=True, |
|
loop=True, |
|
height=512 |
|
) |
|
|
|
|
|
progress_desc = gr.Markdown("") |
|
progress_bar = gr.HTML("") |
|
|
|
|
|
error_html = gr.HTML("", visible=True) |
|
|
|
|
|
inputs = [input_image, prompt, seed, video_length, steps, teacache] |
|
start_button.click(fn=process, inputs=inputs, |
|
outputs=[result_video, preview, progress_desc, progress_bar, start_button, stop_button]) |
|
stop_button.click(fn=end_process) |
|
|
|
|
|
gr_ui.launch() |
|
|