File size: 1,016 Bytes
f4cd130
9f9eb4f
f4cd130
 
 
9f9eb4f
e9e8d18
f4cd130
9f9eb4f
e9e8d18
f4cd130
 
 
 
 
 
9f9eb4f
f4cd130
 
 
9f9eb4f
f4cd130
 
 
 
 
 
 
9f9eb4f
5c4232e
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
29
30
import gradio as gr
from transformers import pipeline


def generator_gpt2(text):
  gen = pipeline('text-generation', model='gpt2')
  return gen(text, max_length=30, num_return_sequences=1)[0]['generated_text']
def generator_openai_gpt(text):
  gen = pipeline('text-generation', model='openai-gpt')
  return gen(text, max_length=30, num_return_sequences=1)[0]['generated_text']

examples=[["Hello, I'm a language model,"],
          ["How are you?\n"]]

demo1 = gr.Interface(fn=generator_gpt2,
             inputs=gr.inputs.Textbox(label="input"),
             outputs=gr.outputs.Textbox(label="gpt2"),
             )
demo2 = gr.Interface(fn=generator_openai_gpt,
             inputs=gr.inputs.Textbox(),
             outputs=gr.outputs.Textbox(label="openai-gpt"),
             )

demo = gr.Parallel(demo1, demo2,
                   examples=examples,
                   allow_flagging="auto",
                   css='styles.css',
                  )

# demo.launch(server_name="0.0.0.0",show_error=True,debug=True)