File size: 1,092 Bytes
dc12ba7
 
 
 
fe37535
dc12ba7
 
 
 
 
 
 
fe37535
 
 
 
 
 
 
 
 
 
 
 
 
1699ffc
fe37535
 
 
 
 
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
import gradio as gr

title = "Reformer"

description = "Gradio Demo for Reformer'. To use it, simply add your text, or click one of the examples to load them. Read more at the links below."

article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2001.04451' target='_blank'>Reformer: The Efficient Transformer</a></p>"

examples = [
    ['A few months later']
]

reformerc = gr.Interface.load("huggingface/google/reformer-crime-and-punishment")

reformere = gr.Interface.load("huggingface/google/reformer-enwik8")

def inference(text,model):
    if model == "reformer-crime-and-punishment":
        outtext = reformerc(text)
    else:
        outtext = reformere(text)
    return outtext   

gr.Interface(
    inference, 
    [gr.inputs.Textbox(label="Input"),gr.inputs.Dropdown(choices=["reformer-crime-and-punishment","reformer-enwik8"], type="value", default="reformer-enwik8", label="model")], 
    gr.outputs.Textbox(label="Output"),
    examples=examples,
    article=article,
    title=title,
    description=description).launch(enable_queue=True, cache_examples=True)