File size: 571 Bytes
2fedd68
7599980
2fedd68
202b83f
 
2fedd68
 
 
202b83f
c7cc4b1
 
 
 
202b83f
f1c9cd6
 
 
 
 
 
01876a6
2fedd68
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import gradio as gr
from transformers import pipeline

pipeline = pipeline(task="text-generation", model="gpt2")

def greet(name):
    return "Hello " + name + "!!"

def gen_text(text):
    if len(text) > 0:
        return pipeline(text)[0]
    else:
        return "Enter text"
    
iface = gr.Interface(fn=gen_text, 
                     inputs="text", 
                     outputs="text",
                     title="Text Generation using GPT-2",
                     description="Example of text generation using OpenAI GPT-2",
                    )
iface.launch()