dream / app.py
lorenzoscottb's picture
Update app.py
26c8ca4
raw
history blame
2.29 kB
import gradio as gr
import os
import pandas as pd
path_to_L_model = str(os.environ['path_to_L_model'])
path_to_S_model = str(os.environ['path_to_S_model'])
read_token = str(os.environ['read_token'])
read_token_ii = str(os.environ['read_token_ii'])
languages = pd.read_csv("model_lang.csv", names=["Lang_acr"])
def check_lang(lang_acronym):
if lang_acronym in languages["Lang_acr"].to_list():
return "True"
else:
return "False"
title = "DSA: version II"
description_main = """
A set of pre-trained LLMs tuned to perform sentiment analysis. You can choose between a Large-Multilingual or Base-English-only model.
Use the current interface to check if a language is included in the multilingual model, using language acronyms (e.g. it for Italian).
Click on one of the upper buttons to select and start querying one of the two models.
"""
description_L = """
XLM-R tuned model, EN-tuned, pre-trained with 94 languages available (see original model [card](https://huggingface.co/xlm-roberta-large) to see which are available)
"""
description_S = """
A BERT-base-cased model pre-trained and tuned on English data.
"""
example_main = ["en", "it", "pl"]
examples = [
["I was followed by the blue monster but was not scared. I was calm and relaxed."],
["Ero seguito dal mostro blu, ma non ero spaventato. Ero calmo e rilassato."],
["Śledził mnie niebieski potwór, ale się nie bałem. Byłem spokojny i zrelaksowany."],
]
interface_words = gr.Interface(
fn=check_lang,
inputs="text",
outputs="text",
title=title,
description=description_main,
examples=example_main,
)
interface_model_L = gr.Interface.load(
name=path_to_L_model,
description=description_L,
examples=examples,
title="DSA Large Multilingual",
api_key=read_token,
)
interface_model_S = gr.Interface.load(
name=path_to_S_model,
description=description_S,
examples=examples[0],
title="DSA Small English Only",
api_key=read_token_ii,
)
gr.TabbedInterface(
[interface_words, interface_model_L, interface_model_S],
["Intro", "Large Multilingual", "Base En"]
).launch()