orion / app.py
andreslu's picture
Update app.py
ab42fe0
raw
history blame
1.27 kB
import gradio as gr
from inductor import BartInductor
inductor = BartInductor()
def bart(text):
results = inductor.generate(text, return_scores=True)
results = [(result[0], float(result[1]) * 100) for result in results]
results_dict = {result[0]: float(result[1]) for result in results}
return results_dict
bivar = gr.Interface(fn=bart,
inputs=gr.inputs.Textbox(default='<mask> is the capital of <mask>.'),
outputs=gr.Label(),
title="BART Inductor εŒε˜ι‡",
examples=[['<mask> is the capital of <mask>.'],['<mask> is founder and CEO of <mask>.']],
description="Enter a text prompt to generate text using BART.")
trivar = gr.Interface(fn=bart,
inputs=gr.inputs.Textbox(default='<mask> is the parent of <mask>, who is the sibling of <mask>.'),
outputs=gr.Label(),
title="BART Inductor δΈ‰ε˜ι‡",
examples=[['<mask> is the parent of <mask>, who is the sibling of <mask>.']],
description="this might not work so well")
demo = gr.TabbedInterface([bivar, trivar], ["εŒε˜ι‡", "δΈ‰ε˜ι‡"])
if __name__ == "__main__":
demo.launch()