-
-
Save lazarinastoy/e0b247d73648acdcdaef57ad70bfb121 to your computer and use it in GitHub Desktop.
Article generation in website
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Import streamlit library | |
import streamlit as st | |
st.title("Medium Article Generator") #set title of website | |
starting_sentence = st.text_input(label='Enter Starting Sentence') #set input and label | |
#Function to run model and generate new text | |
@st.cache | |
def generate(): | |
import gpt_2_simple as gpt2 | |
global sess1 | |
sess = gpt2.start_tf_sess() | |
gpt2.load_gpt2(sess) | |
global single_text | |
single_text = gpt2.generate(sess, prefix=starting_sentence, top_k=40, length=100, | |
return_as_list=True)[0] | |
return single_text | |
model_load_state = st.text("Loading Gpt2 model ... ") | |
generate() #Run function after input | |
model_load_state.text('Loading Gpt2 ... Done! Have Fun:)') | |
st.write(single_text) #write output generated by model |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment