File size: 780 Bytes
fe81d1b
cf2f1c2
ad0d66d
f3d5768
8167ccd
f3d5768
6b647d1
7be2597
f3d5768
 
 
ad0d66d
f3d5768
ed71b30
6b647d1
ed71b30
6b647d1
ed71b30
6b647d1
 
 
 
 
 
 
ed71b30
f3d5768
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import streamlit as st 
from transformers import pipeline, set_seed
from datetime import datetime

def init():
    generator = setupAI()
    setupUI(generator)
    return generator

def setupAI():
    generator = pipeline('text-generation', model='gpt2')
    set_seed(datetime.now().second)
    return generator

def setupUI(generator):
    st.title('Phrase generator')
    phraseField = st.text_input('Enter a beginning phrase')
    if (st.button('Submit')):
        resultingphrase = phraseField.title()
        result = generator(phraseField.title(), max_length=30, num_return_sequences=5)
        generatedContent=''
        for item in result:
            generatedContent = generatedContent + item["generated_text"]

        st.success(generatedContent)

generator = init()