CoolFace
Apppublic

docs-demos/tiny-ctrl

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
app.py34 linesDownload Raw Back to root
1import gradio as gr2title = "CTRL"3 4description = "Gradio Demo for CTRL. To use it, simply add your text, or click one of the examples to load them. Read more at the links below."5 6article = "<p style='text-align: center'><a href='https://arxiv.org/abs/1909.05858' target='_blank'>CTRL: A Conditional Transformer Language Model for Controllable Generation</a></p>"7 8examples = [9    ['My name is Thomas and my main',"tiny-ctrl"]10]11 12 13io1 = gr.Interface.load("huggingface/sshleifer/tiny-ctrl")14 15io2 = gr.Interface.load("huggingface/prajjwal1/ctrl_discovery_flipped_2")16 17 18def inference(inputtext, model):19    if model == "tiny-ctrl":20        outlabel = io1(inputtext)21    else:22        outlabel = io2(inputtext)23    return outlabel24     25 26gr.Interface(27    inference, 28    [gr.inputs.Textbox(label="Context",lines=10),gr.inputs.Dropdown(choices=["tiny-ctrl","ctrl_discovery_flipped_2"], type="value", default="tiny-ctrl", label="model")], 29    [gr.outputs.Textbox(label="Output")],30    examples=examples,31    article=article,32    title=title,33    description=description).launch(enable_queue=True)34