edia_lmodels_es / app.py
nanom's picture
Added type hinting and config file
f1ad590
raw
history blame
1.28 kB
# --- Imports libs ---
import gradio as gr
import pandas as pd
import configparser
# --- Imports modules ---
from modules.module_languageModel import LanguageModel
# --- Imports interfaces ---
from interfaces.interface_biasPhrase import interface as interface_sesgoEnFrases
from interfaces.interface_crowsPairs import interface as interface_crowsPairs
# --- Tool config ---
cfg = configparser.ConfigParser()
cfg.read('tool.cfg')
LANGUAGE = cfg['INTERFACE']['language']
LANGUAGE_MODEL = cfg['LMODEL']['language_model']
AVAILABLE_LOGS = cfg['LOGS'].getboolean('available_logs')
# --- Init classes ---
bert_lm = LanguageModel(
model_name=LANGUAGE_MODEL
)
# --- Init Vars ---
labels = pd.read_json(f"language/{LANGUAGE}.json")["app"]
# --- Init App ---
INTERFACE_LIST = [
interface_sesgoEnFrases(
language_model=bert_lm,
available_logs=AVAILABLE_LOGS,
lang=LANGUAGE),
interface_crowsPairs(
language_model=bert_lm,
available_logs=AVAILABLE_LOGS,
lang=LANGUAGE),
]
TAB_NAMES = [
labels["phraseExplorer"],
labels["crowsPairsExplorer"]
]
iface = gr.TabbedInterface(
interface_list=INTERFACE_LIST,
tab_names=TAB_NAMES
)
iface.queue(concurrency_count=8)
iface.launch(debug=False)