Spaces:
Runtime error
Runtime error
Corrects first_line input and adds boxplot
Browse files
app.py
CHANGED
@@ -1,12 +1,18 @@
|
|
1 |
import streamlit as st
|
2 |
from story_gen import StoryGenerator
|
3 |
import plotly.figure_factory as ff
|
4 |
-
import plotly.express as px
|
|
|
|
|
5 |
|
6 |
st.set_page_config(page_title='Storytelling ' +
|
7 |
u'\U0001F5BC', page_icon=u'\U0001F5BC', layout="wide")
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
10 |
container_mode = st.sidebar.container()
|
11 |
container_param = st.sidebar.container()
|
12 |
container_button = st.sidebar.container()
|
@@ -32,7 +38,7 @@ if mode == 'Create Statistics':
|
|
32 |
elif reaction_weight_mode == "Random":
|
33 |
reaction_weight = -1
|
34 |
if container_button.button('Analyse'):
|
35 |
-
gen.get_stats(story_till_now=
|
36 |
num_generation=num_generation, length=length, reaction_weight=reaction_weight, num_tests=num_tests)
|
37 |
if len(gen.stories) > 0:
|
38 |
for si, story in enumerate(gen.stories):
|
@@ -41,6 +47,8 @@ if mode == 'Create Statistics':
|
|
41 |
data=gen.stats_df[gen.stats_df.sentence_no==3]
|
42 |
fig = px.violin(data_frame=data, x="reaction_weight", y="num_reactions", hover_data=data.columns)
|
43 |
st.plotly_chart(fig, use_container_width=True)
|
|
|
|
|
44 |
else:
|
45 |
st.markdown('### You selected statistics. Now set your parameters and click the `Analyse` button.')
|
46 |
elif mode == 'Play Storytelling':
|
@@ -59,6 +67,6 @@ elif mode == 'Play Storytelling':
|
|
59 |
story_till_now, num_generation, length)
|
60 |
st.markdown(f'### Story')
|
61 |
st.text(story_till_now)
|
62 |
-
st.markdown(f'The last sentence has
|
63 |
else:
|
64 |
st.markdown('### Write the first sentence and then hit the `Run` button')
|
|
|
1 |
import streamlit as st
|
2 |
from story_gen import StoryGenerator
|
3 |
import plotly.figure_factory as ff
|
4 |
+
import plotly.express as px
|
5 |
+
|
6 |
+
gen = StoryGenerator()
|
7 |
|
8 |
st.set_page_config(page_title='Storytelling ' +
|
9 |
u'\U0001F5BC', page_icon=u'\U0001F5BC', layout="wide")
|
10 |
+
if 'count' not in st.session_state or st.session_state.count == 6:
|
11 |
+
st.session_state.count = 0
|
12 |
+
st.session_state.chat_history_ids = None
|
13 |
+
st.session_state.old_response = ''
|
14 |
+
else:
|
15 |
+
st.session_state.count += 1
|
16 |
container_mode = st.sidebar.container()
|
17 |
container_param = st.sidebar.container()
|
18 |
container_button = st.sidebar.container()
|
|
|
38 |
elif reaction_weight_mode == "Random":
|
39 |
reaction_weight = -1
|
40 |
if container_button.button('Analyse'):
|
41 |
+
gen.get_stats(story_till_now=story_till_now,
|
42 |
num_generation=num_generation, length=length, reaction_weight=reaction_weight, num_tests=num_tests)
|
43 |
if len(gen.stories) > 0:
|
44 |
for si, story in enumerate(gen.stories):
|
|
|
47 |
data=gen.stats_df[gen.stats_df.sentence_no==3]
|
48 |
fig = px.violin(data_frame=data, x="reaction_weight", y="num_reactions", hover_data=data.columns)
|
49 |
st.plotly_chart(fig, use_container_width=True)
|
50 |
+
fig2 = px.box(data_frame=data, x="reaction_weight", y="num_reactions", hover_data=data.columns)
|
51 |
+
st.plotly_chart(fig2, use_container_width=True)
|
52 |
else:
|
53 |
st.markdown('### You selected statistics. Now set your parameters and click the `Analyse` button.')
|
54 |
elif mode == 'Play Storytelling':
|
|
|
67 |
story_till_now, num_generation, length)
|
68 |
st.markdown(f'### Story')
|
69 |
st.text(story_till_now)
|
70 |
+
st.markdown(f'The last sentence has the "{emotion["label"]}" **Emotion** with a confidence score of {emotion["score"]}.')
|
71 |
else:
|
72 |
st.markdown('### Write the first sentence and then hit the `Run` button')
|