streamlit4c / app.py
seawolf2357's picture
Update app.py
75472b3 verified
raw
history blame
2.47 kB
import streamlit as st
# νŽ˜μ΄μ§€ μ„€μ •
st.set_page_config(layout="wide")
# μ‚¬μ΄λ“œλ°” 타이틀 μ„€μ •
st.sidebar.title("ViDraft")
# 'Home' λ²„νŠΌ μΆ”κ°€
if st.sidebar.button('Home'):
# 'Home' λ²„νŠΌμ„ λˆ„λ₯΄λ©΄ 초기 ν™”λ©΄μœΌλ‘œ μ„€μ •
selected_menu = "Home"
selected_sub_menu = None
else:
# 메뉴 ν•­λͺ©κ³Ό ν•˜μœ„ ν•­λͺ© μ •μ˜
menus = {
"Free Stock": ["Template Video", "Template Image", "Search Video", "Search Image"],
"Image": ["Generation", "Face ID", "Inpainting", "Remove Background", "Studio"],
"Video": ["Generation", "Talking Face", "Remove Background", "Studio"],
"Sound": ["Video SFX", "Video Music", "TTS(Voice)", "Voice Clone", "Image SFX", "Image Music"],
"Scripts": ["Script"]
}
# μ„ νƒλœ 메뉴 및 ν•˜λΆ€ 메뉴 μ΄ˆκΈ°ν™”
selected_menu = None
selected_sub_menu = None
# 각 메뉴별 ν•˜λΆ€ 메뉴λ₯Ό 펼침
for menu_name, sub_menus in menus.items():
with st.sidebar.expander(menu_name):
# ν•˜λΆ€ 메뉴λ₯Ό 선택할 수 μžˆλŠ” selectbox 생성
selected = st.selectbox(f"Select {menu_name} option", [""] + sub_menus, key=menu_name)
if selected:
selected_menu = menu_name
selected_sub_menu = selected
# μ„ νƒλœ 메뉴와 ν•˜λΆ€ 메뉴에 λ”°λ₯Έ λ‚΄μš© ν‘œμ‹œ
if selected_menu == "Home" or selected_menu is None:
st.title("Welcome to ViDraft")
st.write("This is the Home page. Select an option from the sidebar to get started.")
elif selected_menu and selected_sub_menu:
st.subheader(f"{selected_menu} > {selected_sub_menu}")
# 여기에 μ„ νƒλœ 메뉴에 λ”°λ₯Έ μ½˜ν…μΈ  ν‘œμ‹œ 둜직 μΆ”κ°€
# μ˜ˆμ‹œ: 'Template Video'κ°€ μ„ νƒλ˜μ—ˆμ„ λ•Œ λΉ„λ””μ˜€ 가러리λ₯Ό ν‘œμ‹œ
if selected_menu == "Free Stock" and selected_sub_menu == "Template Video":
st.subheader("Template Videos")
# λΉ„λ””μ˜€ 파일 경둜 μ„€μ • 및 λΉ„λ””μ˜€ ν‘œμ‹œ 둜직 μΆ”κ°€
# λΉ„λ””μ˜€ 파일 경둜 μ„€μ •
video_files = ["ex1.mp4", "ex2.mp4", "ex3.mp4", "ex4.mp4", "ex5.mp4", "ex6.mp4", "ex7.mp4","ex8.mp4", "ex9.mp4", "ex10.mp4", "ex11.mp4", "ex12.mp4", "ex13.mp4", "ex14.mp4","ex15.mp4", "ex16.mp4", "ex17.mp4", "ex18.mp4"]
# 가러리 ν˜•νƒœλ‘œ λΉ„λ””μ˜€ ν‘œμ‹œ
cols = st.columns(2) # 2개의 μ—΄λ‘œ λ„“κ²Œ 배치
for index, video_file in enumerate(video_files):
with cols[index % 2]:
st.video(video_file)