返回 Pixelle-Video
1_🎬_Home.py
根目录 / web / pages / 1_🎬_Home.py
1 # Copyright (C) 2025 AIDC-AI
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 # http://www.apache.org/licenses/LICENSE-2.0
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS,
9 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 # See the License for the specific language governing permissions and
11 # limitations under the License.
12
13 """
14 Home Page - Main video generation interface
15 """
16
17 import sys
18 from pathlib import Path
19
20 # Add project root to sys.path
21 _script_dir = Path(__file__).resolve().parent
22 _project_root = _script_dir.parent.parent
23 if str(_project_root) not in sys.path:
24 sys.path.insert(0, str(_project_root))
25
26 import streamlit as st
27
28 # Import state management
29 from web.state.session import init_session_state, init_i18n, get_pixelle_video
30
31 # Import components
32 from web.components.header import render_header
33 from web.components.settings import render_advanced_settings
34 from web.components.faq import render_faq_sidebar
35
36 # Page config
37 st.set_page_config(
38 page_title="Home - Pixelle-Video",
39 page_icon="🎬",
40 layout="wide",
41 initial_sidebar_state="collapsed",
42 )
43
44
45 def main():
46 """Main UI entry point"""
47 # Initialize session state and i18n
48 init_session_state()
49 init_i18n()
50
51 # Render header (title + language selector)
52 render_header()
53
54 # Render FAQ in sidebar
55 render_faq_sidebar()
56
57 # Initialize Pixelle-Video
58 pixelle_video = get_pixelle_video()
59
60 # Render system configuration (LLM + ComfyUI)
61 render_advanced_settings()
62
63 # ========================================================================
64 # Pipeline Selection & Delegation
65 # ========================================================================
66 from web.pipelines import get_all_pipeline_uis
67
68 # Get all registered pipelines
69 pipelines = get_all_pipeline_uis()
70
71 # Use Tabs for pipeline selection
72 # Note: st.tabs returns a list of containers, one for each tab
73 tab_labels = [f"{p.icon} {p.display_name}" for p in pipelines]
74 tabs = st.tabs(tab_labels)
75
76 # Render each pipeline in its corresponding tab
77 for i, pipeline in enumerate(pipelines):
78 with tabs[i]:
79 # Show description if available
80 if pipeline.description:
81 st.caption(pipeline.description)
82
83 # Delegate rendering
84 pipeline.render(pixelle_video)
85
86
87 if __name__ == "__main__":
88 main()
89
90
90 lines PYTHON