seawolf2357 commited on
Commit
d92242c
ยท
verified ยท
1 Parent(s): 75472b3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -34
app.py CHANGED
@@ -1,51 +1,49 @@
1
  import streamlit as st
2
 
3
  # ํŽ˜์ด์ง€ ์„ค์ •
4
- st.set_page_config(layout="wide")
5
 
6
- # ์‚ฌ์ด๋“œ๋ฐ” ํƒ€์ดํ‹€ ์„ค์ •
7
- st.sidebar.title("ViDraft")
 
 
8
 
9
- # 'Home' ๋ฒ„ํŠผ ์ถ”๊ฐ€
10
- if st.sidebar.button('Home'):
11
- # 'Home' ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด ์ดˆ๊ธฐ ํ™”๋ฉด์œผ๋กœ ์„ค์ •
12
- selected_menu = "Home"
13
- selected_sub_menu = None
14
- else:
15
- # ๋ฉ”๋‰ด ํ•ญ๋ชฉ๊ณผ ํ•˜์œ„ ํ•ญ๋ชฉ ์ •์˜
16
- menus = {
17
- "Free Stock": ["Template Video", "Template Image", "Search Video", "Search Image"],
18
- "Image": ["Generation", "Face ID", "Inpainting", "Remove Background", "Studio"],
19
- "Video": ["Generation", "Talking Face", "Remove Background", "Studio"],
20
- "Sound": ["Video SFX", "Video Music", "TTS(Voice)", "Voice Clone", "Image SFX", "Image Music"],
21
- "Scripts": ["Script"]
22
- }
23
-
24
- # ์„ ํƒ๋œ ๋ฉ”๋‰ด ๋ฐ ํ•˜๋ถ€ ๋ฉ”๋‰ด ์ดˆ๊ธฐํ™”
25
- selected_menu = None
26
- selected_sub_menu = None
27
-
28
- # ๊ฐ ๋ฉ”๋‰ด๋ณ„ ํ•˜๋ถ€ ๋ฉ”๋‰ด๋ฅผ ํŽผ์นจ
29
- for menu_name, sub_menus in menus.items():
30
  with st.sidebar.expander(menu_name):
31
  # ํ•˜๋ถ€ ๋ฉ”๋‰ด๋ฅผ ์„ ํƒํ•  ์ˆ˜ ์žˆ๋Š” selectbox ์ƒ์„ฑ
32
- selected = st.selectbox(f"Select {menu_name} option", [""] + sub_menus, key=menu_name)
33
  if selected:
34
- selected_menu = menu_name
35
- selected_sub_menu = selected
36
 
37
  # ์„ ํƒ๋œ ๋ฉ”๋‰ด์™€ ํ•˜๋ถ€ ๋ฉ”๋‰ด์— ๋”ฐ๋ฅธ ๋‚ด์šฉ ํ‘œ์‹œ
38
- if selected_menu == "Home" or selected_menu is None:
39
  st.title("Welcome to ViDraft")
40
  st.write("This is the Home page. Select an option from the sidebar to get started.")
41
- elif selected_menu and selected_sub_menu:
42
- st.subheader(f"{selected_menu} > {selected_sub_menu}")
43
  # ์—ฌ๊ธฐ์— ์„ ํƒ๋œ ๋ฉ”๋‰ด์— ๋”ฐ๋ฅธ ์ฝ˜ํ…์ธ  ํ‘œ์‹œ ๋กœ์ง ์ถ”๊ฐ€
44
 
45
- # ์˜ˆ์‹œ: 'Template Video'๊ฐ€ ์„ ํƒ๋˜์—ˆ์„ ๋•Œ ๋น„๋””์˜ค ๊ฐค๋Ÿฌ๋ฆฌ๋ฅผ ํ‘œ์‹œ
46
- if selected_menu == "Free Stock" and selected_sub_menu == "Template Video":
47
- st.subheader("Template Videos")
48
- # ๋น„๋””์˜ค ํŒŒ์ผ ๊ฒฝ๋กœ ์„ค์ • ๋ฐ ๋น„๋””์˜ค ํ‘œ์‹œ ๋กœ์ง ์ถ”๊ฐ€
49
 
50
  # ๋น„๋””์˜ค ํŒŒ์ผ ๊ฒฝ๋กœ ์„ค์ •
51
  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"]
 
1
  import streamlit as st
2
 
3
  # ํŽ˜์ด์ง€ ์„ค์ •
4
+ st.set_page_config(page_title="ViDraft", layout="wide")
5
 
6
+ # ์„ธ์…˜ ์ƒํƒœ ์ดˆ๊ธฐํ™”
7
+ if 'selected_menu' not in st.session_state or 'selected_sub_menu' not in st.session_state:
8
+ st.session_state['selected_menu'] = 'Home'
9
+ st.session_state['selected_sub_menu'] = None
10
 
11
+ # 'Home' ๋ฒ„ํŠผ ํด๋ฆญ ์‹œ ์„ธ์…˜ ์ƒํƒœ๋ฅผ 'Home'์œผ๋กœ ์„ค์ •ํ•˜๋Š” ํ•จ์ˆ˜
12
+ def set_home():
13
+ st.session_state['selected_menu'] = 'Home'
14
+ st.session_state['selected_sub_menu'] = None
15
+
16
+ # ์‚ฌ์ด๋“œ๋ฐ” ํƒ€์ดํ‹€ ์„ค์ • ๋ฐ 'Home' ๋ฒ„ํŠผ ์ถ”๊ฐ€
17
+ st.sidebar.title("ViDraft")
18
+ st.sidebar.button('Home', on_click=set_home)
19
+
20
+ # ๋ฉ”๋‰ด ํ•ญ๋ชฉ๊ณผ ํ•˜์œ„ ํ•ญ๋ชฉ ์ •์˜
21
+ menus = {
22
+ "Free Stock": ["Template Video", "Template Image", "Search Video", "Search Image"],
23
+ "Image": ["Generation", "Face ID", "Inpainting", "Remove Background", "Studio"],
24
+ "Video": ["Generation", "Talking Face", "Remove Background", "Studio"],
25
+ "Sound": ["Video SFX", "Video Music", "TTS(Voice)", "Voice Clone", "Image SFX", "Image Music"],
26
+ "Scripts": ["Script"]
27
+ }
28
+
29
+ # ๊ฐ ๋ฉ”๋‰ด๋ณ„ ํ•˜๋ถ€ ๋ฉ”๋‰ด๋ฅผ ํŽผ์นจ
30
+ for menu_name, sub_menus in menus.items():
31
+ if menu_name != 'Home': # 'Home'์€ ํ•˜์œ„ ๋ฉ”๋‰ด๊ฐ€ ์—†์œผ๋ฏ€๋กœ ์ œ์™ธ
32
  with st.sidebar.expander(menu_name):
33
  # ํ•˜๋ถ€ ๋ฉ”๋‰ด๋ฅผ ์„ ํƒํ•  ์ˆ˜ ์žˆ๋Š” selectbox ์ƒ์„ฑ
34
+ selected = st.selectbox(f"Select {menu_name} option", [""] + sub_menus, key=menu_name, on_change=set_home)
35
  if selected:
36
+ st.session_state['selected_menu'] = menu_name
37
+ st.session_state['selected_sub_menu'] = selected
38
 
39
  # ์„ ํƒ๋œ ๋ฉ”๋‰ด์™€ ํ•˜๋ถ€ ๋ฉ”๋‰ด์— ๋”ฐ๋ฅธ ๋‚ด์šฉ ํ‘œ์‹œ
40
+ if st.session_state['selected_menu'] == 'Home':
41
  st.title("Welcome to ViDraft")
42
  st.write("This is the Home page. Select an option from the sidebar to get started.")
43
+ else:
44
+ st.subheader(f"{st.session_state['selected_menu']} > {st.session_state['selected_sub_menu']}")
45
  # ์—ฌ๊ธฐ์— ์„ ํƒ๋œ ๋ฉ”๋‰ด์— ๋”ฐ๋ฅธ ์ฝ˜ํ…์ธ  ํ‘œ์‹œ ๋กœ์ง ์ถ”๊ฐ€
46
 
 
 
 
 
47
 
48
  # ๋น„๋””์˜ค ํŒŒ์ผ ๊ฒฝ๋กœ ์„ค์ •
49
  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"]