Prudvireddy commited on
Commit
1bafcb4
·
verified ·
1 Parent(s): 71fe545

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +84 -83
app.py CHANGED
@@ -1,83 +1,84 @@
1
- import streamlit as st
2
- import os
3
- from crewai import Crew, Process
4
- from agents import get_agents_and_tasks
5
- from tools import send_mail
6
-
7
- def generate_video(topic, openai_api_key, stabilityai_api_key, user_mail):
8
- os.environ['OPENAI_API_KEY'] = openai_api_key
9
- grow_api_key = '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'
10
- if stabilityai_api_key is not None:
11
- os.environ['STABILITY_AI_API_KEY'] = stabilityai_api_key
12
- model = 'Stability AI'
13
- else:
14
- model = 'Dalle-2'
15
- agents, tasks = get_agents_and_tasks(grow_api_key)
16
-
17
- crew = Crew(
18
- agents=agents,
19
- tasks=tasks,
20
- process=Process.sequential,
21
- memory=True,
22
- verbose=2
23
- )
24
- result = crew.kickoff(inputs={'topic': topic, 'model' : model})
25
- send_mail(user_mail, result)
26
- return result
27
-
28
- st.markdown("""
29
- <style>
30
- .heading {
31
- font-size: 24px;
32
- font-weight: bold;
33
- text-align: center;
34
- }
35
- .subheading {
36
- font-size: 18px;
37
- font-weight: bold;
38
- text-align: center;
39
- margin-top: 10px;
40
- }
41
- </style>
42
- """, unsafe_allow_html=True)
43
-
44
- st.markdown("""
45
- <div class="heading">
46
- YouTube Shorts Creator
47
- </div>
48
- <div class="subheading">
49
- Generate stunning short videos with simple text input
50
- </div>
51
- """, unsafe_allow_html=True)
52
-
53
- st.text(" ")
54
-
55
- topic = st.text_input('Enter title here')
56
- openai_api_key = st.text_input('Enter your OpenAI API key here')
57
- size = st.selectbox('Size',
58
- ('512 X 512', '1024 X 1024', '9:16'))
59
- stabilityai_api_key = None
60
- if size=='9:16':
61
- stabilityai_api_key = st.text_input('Enter your stability ai API key here')
62
- mail = st.text_input('Enter you email address')
63
-
64
- if st.button('Generate'):
65
- st.text(f"Video will be sent to {mail}")
66
- result = generate_video(topic, openai_api_key, stabilityai_api_key, mail)
67
- # with open(result, 'rb') as video_file:
68
- # video_data = video_file.read()
69
- # st.video(video_data)
70
-
71
- # Sidebar for Example Videos
72
- st.sidebar.markdown("### Example Videos")
73
- example_paths = os.listdir('results')
74
- examples = [os.path.join('results', i) for i in example_paths]
75
-
76
- # Display videos in a row
77
- st.sidebar.markdown('<div class="example-video-container">', unsafe_allow_html=True)
78
- for video_url in examples:
79
- title = video_url.split('\\')[1].split('.')[0]
80
- st.sidebar.text(f"input: {title}")
81
- st.sidebar.video(video_url, format="video/mp4", start_time=0)
82
- st.sidebar.markdown("</div>", unsafe_allow_html=True)
83
-
 
 
1
+ import streamlit as st
2
+ import os
3
+ from crewai import Crew, Process
4
+ from agents import get_agents_and_tasks
5
+ from tools import send_mail
6
+
7
+ def generate_video(topic, openai_api_key, stabilityai_api_key, user_mail):
8
+ os.environ['OPENAI_API_KEY'] = openai_api_key
9
+ grow_api_key = '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'
10
+ if stabilityai_api_key is not None:
11
+ os.environ['STABILITY_AI_API_KEY'] = stabilityai_api_key
12
+ model = 'Stability AI'
13
+ else:
14
+ model = 'Dalle-2'
15
+ agents, tasks = get_agents_and_tasks(grow_api_key)
16
+
17
+ crew = Crew(
18
+ agents=agents,
19
+ tasks=tasks,
20
+ process=Process.sequential,
21
+ memory=True,
22
+ verbose=2
23
+ )
24
+ result = crew.kickoff(inputs={'topic': topic, 'model' : model})
25
+ send_mail(user_mail, result)
26
+ return result
27
+
28
+ st.markdown("""
29
+ <style>
30
+ .heading {
31
+ font-size: 24px;
32
+ font-weight: bold;
33
+ text-align: center;
34
+ }
35
+ .subheading {
36
+ font-size: 18px;
37
+ font-weight: bold;
38
+ text-align: center;
39
+ margin-top: 10px;
40
+ }
41
+ </style>
42
+ """, unsafe_allow_html=True)
43
+
44
+ st.markdown("""
45
+ <div class="heading">
46
+ YouTube Shorts Creator
47
+ </div>
48
+ <div class="subheading">
49
+ Generate stunning short videos with simple text input
50
+ </div>
51
+ """, unsafe_allow_html=True)
52
+
53
+ st.text(" ")
54
+
55
+ topic = st.text_input('Enter title here')
56
+ openai_api_key = st.text_input('Enter your OpenAI API key here')
57
+ size = st.selectbox('Size',
58
+ ('512 X 512', '1024 X 1024', '9:16'))
59
+ stabilityai_api_key = None
60
+ if size=='9:16':
61
+ stabilityai_api_key = st.text_input('Enter your stability ai API key here')
62
+ mail = st.text_input('Enter you email address')
63
+
64
+ if st.button('Generate'):
65
+ st.text(f"Video will be sent to {mail}")
66
+ result = generate_video(topic, openai_api_key, stabilityai_api_key, mail)
67
+ # with open(result, 'rb') as video_file:
68
+ # video_data = video_file.read()
69
+ # st.video(video_data)
70
+
71
+ # Sidebar for Example Videos
72
+ st.sidebar.markdown("### Example Videos")
73
+ example_paths = os.listdir('results')
74
+ examples = [os.path.join('results', i) for i in example_paths]
75
+
76
+ # Display videos in a row
77
+ st.sidebar.markdown('<div class="example-video-container">', unsafe_allow_html=True)
78
+ for video_url in examples:
79
+ print(video_url)
80
+ title = video_url.split('\\')[1].split('.')[0]
81
+ st.sidebar.text(f"input: {title}")
82
+ st.sidebar.video(video_url, format="video/mp4", start_time=0)
83
+ st.sidebar.markdown("</div>", unsafe_allow_html=True)
84
+