seawolf2357 commited on
Commit
cebb418
Β·
verified Β·
1 Parent(s): f7a452e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -15
app.py CHANGED
@@ -1,32 +1,49 @@
1
  import streamlit as st
 
2
 
3
  # μ‚¬μ΄λ“œλ°” 타이틀 μ„€μ •
4
  st.sidebar.title("ViDraft")
5
 
6
  # 메뉴 ν•­λͺ©κ³Ό ν•˜μœ„ ν•­λͺ© μ •μ˜
7
  menus = {
8
- "Free Stock": ["Template Video", "Template Image", "Search Video", "Search Image"],
9
  "Image": ["Generation", "Face ID", "Inpainting", "Remove Background", "Studio"],
10
  "Video": ["Generation", "Talking Face", "Remove Background", "Studio"],
11
- "Sound": ["Video SFX", "Video Music", "TTS(Voice)", "Voice Clone", "Image SFX", "Image Music"],
12
  "Scripts": ["Script"]
13
  }
14
 
15
- # μ„ νƒλœ 메뉴 ν•­λͺ©μ„ μ €μž₯ν•  λ³€μˆ˜
16
- selected_menu = None
17
- selected_sub_menu = None
18
 
19
- # 메뉴 생성
20
- selected_menu = st.sidebar.selectbox("Menu", list(menus.keys()))
21
- selected_sub_menu = st.sidebar.selectbox("Sub Menu", menus[selected_menu])
 
 
 
 
 
22
 
23
- # 'Template Video'κ°€ μ„ νƒλ˜μ—ˆμ„ λ•Œ 'example.mp4' λΉ„λ””μ˜€λ₯Ό ν‘œμ‹œ
24
  if selected_menu == "Free Stock" and selected_sub_menu == "Template Video":
25
- # λΉ„λ””μ˜€ 파일의 경둜 μ„€μ •
26
- video_path = "example.mp4" # 슀페이슀의 루트 디렉토리에 μœ„μΉ˜ν•œ 경우
27
 
28
- # λΉ„λ””μ˜€ 제λͺ©μ„ 좜λ ₯
29
- st.subheader("Example Video")
 
30
 
31
- # λΉ„λ””μ˜€ νŒŒμΌμ„ μŠ€νŠΈλ¦Όλ¦Ώμ„ 톡해 ν‘œμ‹œ
32
- st.video(video_path)
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
+ import os
3
 
4
  # μ‚¬μ΄λ“œλ°” 타이틀 μ„€μ •
5
  st.sidebar.title("ViDraft")
6
 
7
  # 메뉴 ν•­λͺ©κ³Ό ν•˜μœ„ ν•­λͺ© μ •μ˜
8
  menus = {
9
+ "Free Stock": ["Template Video", "Template Image", "Search Video", "Search Image"],
10
  "Image": ["Generation", "Face ID", "Inpainting", "Remove Background", "Studio"],
11
  "Video": ["Generation", "Talking Face", "Remove Background", "Studio"],
12
+ "Sound": ["Video SFX", "Video Music", "TTS(Voice)", "Voice Clone", "Image SFX", "Image Music"],
13
  "Scripts": ["Script"]
14
  }
15
 
16
+ # μ„ νƒλœ λΉ„λ””μ˜€λ₯Ό μ €μž₯ν•  λ³€μˆ˜
17
+ selected_video = None
 
18
 
19
+ # 메뉴 생성 및 접이식 메뉴 κ΅¬ν˜„
20
+ for menu in menus.keys():
21
+ with st.sidebar.expander(menu):
22
+ for sub_menu in menus[menu]:
23
+ if st.button(sub_menu, key=sub_menu):
24
+ selected_menu = menu
25
+ selected_sub_menu = sub_menu
26
+ break
27
 
28
+ # 'Template Video'κ°€ μ„ νƒλ˜μ—ˆμ„ λ•Œ λΉ„λ””μ˜€ 가러리λ₯Ό ν‘œμ‹œ
29
  if selected_menu == "Free Stock" and selected_sub_menu == "Template Video":
30
+ st.subheader("Template Videos")
 
31
 
32
+ # 10개의 λΉ„λ””μ˜€ 썸넀일과 파일 경둜 μ •μ˜
33
+ video_paths = [f"example{i}.mp4" for i in range(1, 11)]
34
+ thumbnail_paths = [f"thumbnail{i}.jpg" for i in range(1, 11)]
35
 
36
+ # 썸넀일을 ν‘œμ‹œν•˜κ³  선택 처리
37
+ cols = st.columns(5)
38
+ for index, col in enumerate(cols):
39
+ with col:
40
+ if index < len(thumbnail_paths):
41
+ # 썸넀일 이미지 ν‘œμ‹œ
42
+ st.image(thumbnail_paths[index], width=100)
43
+ # 썸넀일 클릭 처리 (μ—¬κΈ°μ„œλŠ” λ‹¨μˆœνžˆ λ²„νŠΌμœΌλ‘œ κ΅¬ν˜„)
44
+ if st.button(f"Play Video {index+1}", key=f"video{index+1}"):
45
+ selected_video = video_paths[index]
46
+
47
+ # μ„ νƒλœ λΉ„λ””μ˜€ μž¬μƒ
48
+ if selected_video:
49
+ st.video(selected_video)