File size: 3,622 Bytes
50f328c
 
5354773
50f328c
ffb7037
5354773
 
 
ffb7037
2a8ac85
5354773
 
 
 
 
 
 
 
 
 
2a8ac85
5354773
 
 
2a8ac85
 
5354773
 
2a8ac85
5354773
 
2a8ac85
5354773
 
 
 
 
 
 
 
 
2a8ac85
 
5354773
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2a8ac85
5354773
 
 
 
2a8ac85
5354773
2a8ac85
5354773
2a8ac85
5354773
 
2a8ac85
5354773
2a8ac85
1064203
5354773
 
 
 
 
 
217c6bd
5354773
 
 
 
 
217c6bd
5354773
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import gradio as gr

# FramePack - 画像から動画生成 アプリケーション

def make_custom_css():
    """カスタムCSSを作成してレスポンシブ対応およびエラースタイルを定義"""
    # (省略: 既存のCSS定義をそのまま利用)
    return combined_css  # 前述の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()