File size: 389 Bytes
0b2d9d7
 
 
 
 
 
 
 
 
 
 
 
71d9134
0b2d9d7
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import gradio as gr
from transformers import pipeline

def infer(input_text):
    out = pipeline("text-generation", model="gpt2")
    output_text = out(input_text, max_length=30, num_return_sequences=1)
    return output_text[0]['generated_text']

demo = gr.Interface(
    fn=infer,
    inputs=["text"],
    outputs=["text"],
    description="text-generation using gpt2",
)

demo.launch()