File size: 444 Bytes
6ba4966
 
 
 
 
 
3226311
6ba4966
 
 
 
3226311
6ba4966
1
2
3
4
5
6
7
8
9
10
11
12
13
import gradio as gr
from transformers import pipeline

def get_model():
    return pipeline('text-generation', model='gpt-2') 

def complete_text(start_of_sentence):
    model = get_model()
    result = model(start_of_sentence, max_length=50, do_sample=True)[0]['generated_text']
    return result

iface = gr.Interface(fn=complete_text, inputs=gr.inputs.Textbox(lines=2, placeholder='Start of Sentence Here...'), outputs="text")
iface.launch()