File size: 604 Bytes
7681358
480e0ae
7681358
d1abd49
 
 
 
 
480e0ae
 
d1abd49
480e0ae
 
d1abd49
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import gradio as gr
from transformers import pipeline

generator = pipeline('text-generation', model='EleutherAI/gpt-neo-1.3B')
examples = [
    ["Once upon a time, Dr. Woo was teaching computer programming in a school."],
    ["Once upon a time, Dr. Woo was walking in a park. He "]
]

def generate(text):
    result=generator(text, max_length=100, num_return_sequences=1)
    return result[0]['generated_text']

gr.Interface(fn=generate, inputs=gr.inputs.Textbox(lines=5, label='input text'), outputs=gr.outputs.Textbox(label='output text'), title='My First Text Generator', examples=examples).launch()