mkoot007 commited on
Commit
e26d0de
·
1 Parent(s): af1e477

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -1,9 +1,10 @@
1
  import streamlit as st
2
  from transformers import pipeline, set_seed
3
-
4
- text_generator = pipeline("text-generation", model="gpt2")
5
 
6
  st.title("Story Generator")
 
 
7
  title = st.text_input("Title of the Story:")
8
  character = st.text_input("Character (Hero) Name:")
9
  era = st.selectbox("Era of the Story:", ["Medieval", "Modern", "Future"])
@@ -13,9 +14,8 @@ ending = st.selectbox("Ending:", ["Happy", "Sad"])
13
  if st.button("Generate Story"):
14
  if title and character:
15
  prompt = f"In the {era} era, there was a character named {character}. This is the {genre} story of {character}, a {genre} story with a {ending} ending."
16
-
17
- set_seed(42)
18
- story = text_generator(prompt, max_length=1000, do_sample=True)[0]["generated_text"]
19
  full_story = f"# {title}\n\n{story}"
20
 
21
  st.markdown(full_story)
 
1
  import streamlit as st
2
  from transformers import pipeline, set_seed
3
+ text_generator = pipeline("text-generation", model="google/flan-t5-base")
 
4
 
5
  st.title("Story Generator")
6
+
7
+ # User inputs
8
  title = st.text_input("Title of the Story:")
9
  character = st.text_input("Character (Hero) Name:")
10
  era = st.selectbox("Era of the Story:", ["Medieval", "Modern", "Future"])
 
14
  if st.button("Generate Story"):
15
  if title and character:
16
  prompt = f"In the {era} era, there was a character named {character}. This is the {genre} story of {character}, a {genre} story with a {ending} ending."
17
+ set_seed(42)
18
+ story = text_generator(prompt, max_length=300, do_sample=True)[0]["generated_text"]
 
19
  full_story = f"# {title}\n\n{story}"
20
 
21
  st.markdown(full_story)