# --- Imports libs --- import gradio as gr import pandas as pd import configparser # --- Imports modules --- from modules.model_embbeding import Embedding # --- Imports interfaces --- from interfaces.interface_WordExplorer import interface as wordExplorer_interface from interfaces.interface_BiasWordExplorer import interface as biasWordExplorer_interface # --- Tool config --- cfg = configparser.ConfigParser() cfg.read('tool.cfg') LANGUAGE = cfg['INTERFACE']['language'] EMBEDDINGS_PATH = cfg['WORD_EXPLORER']['embeddings_path'] NN_METHOD = cfg['WORD_EXPLORER']['nn_method'] MAX_NEIGHBORS = int(cfg['WORD_EXPLORER']['max_neighbors']) AVAILABLE_LOGS = cfg['LOGS'].getboolean('available_logs') # --- Init classes --- embedding = Embedding( path=EMBEDDINGS_PATH, limit=100_000, randomizedPCA=False, max_neighbors=MAX_NEIGHBORS, nn_method=NN_METHOD ) # --- Init Vars --- labels = pd.read_json(f"language/{LANGUAGE}.json")["app"] # --- Main App --- INTERFACE_LIST = [ biasWordExplorer_interface( embedding=embedding, available_logs=AVAILABLE_LOGS, lang=LANGUAGE), wordExplorer_interface( embedding=embedding, available_logs=AVAILABLE_LOGS, max_neighbors=MAX_NEIGHBORS, lang=LANGUAGE), ] TAB_NAMES = [ labels["biasWordExplorer"], labels["wordExplorer"], ] # Skip data tab when using other than spanish language if LANGUAGE != 'es': INTERFACE_LIST = INTERFACE_LIST[:2] + INTERFACE_LIST[3:] TAB_NAMES = TAB_NAMES[:2] + TAB_NAMES[3:] iface = gr.TabbedInterface( interface_list=INTERFACE_LIST, tab_names=TAB_NAMES ) iface.queue(concurrency_count=8) iface.launch(debug=False)