Skip to content

Instantly share code, notes, and snippets.

@lazarinastoy
Forked from tejeshb/article_generation.py
Created May 24, 2021 11:56
Show Gist options
  • Save lazarinastoy/e0b247d73648acdcdaef57ad70bfb121 to your computer and use it in GitHub Desktop.
Save lazarinastoy/e0b247d73648acdcdaef57ad70bfb121 to your computer and use it in GitHub Desktop.
Article generation in website
#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