File size: 2,343 Bytes
71a48d6
feaec37
810185a
71a48d6
810185a
 
 
 
 
 
2812943
 
 
 
 
810185a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76d62a1
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import gradio as gr
from gradio.mix import Series 
from transformers import pipeline

description = "Select from a language model tab. Input text and submit."
examples = [
    ["Zoe Kwan is a 20-year old singer and songwriter who has taken Hong Kong’s music scene by storm."],
    ["Zoe only recently began writing songs."],
]

model1 = pipeline('text-generation', model='EleutherAI/gpt-neo-1.3B')
model2 = pipeline('text-generation', model='bigscience/bloom-560m')
model3 = pipeline('text-generation', model='EleutherAI/gpt-neo-125M')
model4 = pipeline('text-generation', model='Wootang01/distilgpt2-finetuned-hkdse-english-paper4')
model5 = pipeline('text-generation', model='Wootang01/gpt-neo-125M-finetuned-hkdse-english-paper4')

def generate1(text):
    result = model1(text, max_length=100, num_return_sequences=1)
    return result[0]["generated_text"]
def generate2(text):
    result = model2(text, max_length=100, num_return_sequences=1)
    return result[0]["generated_text"]
def generate3(text):
    result = model3(text, max_length=100, num_return_sequences=1)
    return result[0]["generated_text"]
def generate4(text):
    result = model4(text, max_length=100, num_return_sequences=1)
    return result[0]["generated_text"]
def generate5(text):
    result = model5(text, max_length=100, num_return_sequences=1)
    return result[0]["generated_text"]

generator1 = gr.Interface(fn=model1, inputs=gr.inputs.Textbox(lines=5, label="Input Text"), outputs=gr.outputs.Textbox(label="Generated Text"), 
                    examples=examples)
generator2 = gr.Interface(fn=model2, inputs=gr.inputs.Textbox(lines=5, label="Input Text"), outputs=gr.outputs.Textbox(label="Generated Text"), 
                    examples=examples)
generator3 = gr.Interface(fn=model3, inputs=gr.inputs.Textbox(lines=5, label="Input Text"), outputs=gr.outputs.Textbox(label="Generated Text"), 
                    examples=examples)
generator4 = gr.Interface(fn=model4, inputs=gr.inputs.Textbox(lines=5, label="Input Text"), outputs=gr.outputs.Textbox(label="Generated Text"), 
                    examples=examples)
generator5 = gr.Interface(fn=model5, inputs=gr.inputs.Textbox(lines=5, label="Input Text"), outputs=gr.outputs.Textbox(label="Generated Text"), 
                    examples=examples)

gr.Parallel(generator1,generator2,generator3).launch()