MariaK's picture
fixed the cache_examples runtime error
c22353a
import gradio as gr
title = "MT5"
description = "Gradio Demo for MT5. 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/2010.11934' target='_blank'>mT5: A massively multilingual pre-trained text-to-text transformer</a></p>"
examples = [
["""The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building, and the tallest structure in Paris. Its base is square, measuring 125 metres (410 ft) on each side. During its construction, the Eiffel Tower surpassed the Washington Monument to become the tallest man-made structure in the world, a title it held for 41 years until the Chrysler Building in New York City was finished in 1930. It was the first structure to reach a height of 300 metres. Due to the addition of a broadcasting aerial at the top of the tower in 1957, it is now taller than the Chrysler Building by 5.2 metres (17 ft). Excluding transmitters, the Eiffel Tower is the second tallest free-standing structure in France after the Millau Viaduct.""","mt5-small-finetuned-arxiv-cs-finetuned-arxiv-cs-full"]
]
io1 = gr.Interface.load("huggingface/shamikbose89/mt5-small-finetuned-arxiv-cs-finetuned-arxiv-cs-full")
io2 = gr.Interface.load("huggingface/csebuetnlp/mT5_multilingual_XLSum")
def inference(text,model):
if model == "mt5-small-finetuned-arxiv-cs-finetuned-arxiv-cs-full":
outtext = io1(text)
else:
outtext = io2(text)
return outtext
gr.Interface(
inference,
[gr.inputs.Textbox(label="Input",lines=5),gr.inputs.Dropdown(choices=["mt5-small-finetuned-arxiv-cs-finetuned-arxiv-cs-full","mT5_multilingual_XLSum"], type="value", default="mt5-small-finetuned-arxiv-cs-finetuned-arxiv-cs-full", label="model")
],
gr.outputs.Textbox(label="Output"),
examples=examples,
article=article,
title=title,
description=description).launch(enable_queue=True)