orion / app.py
andreslu's picture
Update app.py
7110a4a
raw
history blame
937 Bytes
import gradio as gr
from inductor import BartInductor
inductor = BartInductor()
def bart(prompt, num):
results = inductor.generate(prompt, k=num, topk=num, 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
demo = gr.Interface(fn=bart,
inputs=[gr.inputs.Textbox(default='<mask> is the capital of <mask>.'),gr.Slider(0, 10)],
outputs=gr.Label(),
title="Orion",
examples=[['<mask> is the capital of <mask>.',5],
['<mask> is founder and CEO of <mask>.',5],
["<mask>'s mother was a <mask>-based actress, <mask>.",5]],
description="Enter a text prompt to generate text using BART.")
if __name__ == "__main__":
demo.launch()