text_generation / app.py
nichaphat's picture
Update app.py
65ad4aa
Raw
History Blame Contribute Delete
517 Bytes
import streamlit as st
from transformers import pipeline
text_generator = pipeline("text-generation",model="gpt2")
def main():
st.title("Text-generation")
with st.form("text_field"):
text = st.text_area('enter your text:')
# clicked==True only when the button is clicked
clicked = st.form_submit_button("Generate")
if clicked:
results =text_generator(text,max_length=100,num_return_sequences=5)
st.json(results)
if __name__ == "__main__":
main()