import numpy as np import pandas as pd import streamlit as st from streamlit_text_rating.st_text_rater import st_text_rater from transformers import AutoTokenizer,AutoModelForSequenceClassification from transformers import AutoModelForMaskedLM import onnxruntime as ort import os import time import plotly.express as px import plotly.graph_objects as go from PIL import Image global _plotly_config _plotly_config={'displayModeBar': False} from sentiment_clf_helper import (classify_sentiment, create_onnx_model_sentiment, classify_sentiment_onnx) from zeroshot_clf_helper import (zero_shot_classification, create_onnx_model_zs_nli, create_onnx_model_zs_mlm, zero_shot_classification_nli_onnx, zero_shot_classification_fillmask_onnx) import multiprocessing total_threads=multiprocessing.cpu_count()#for ort inference import yaml def read_yaml(file_path): with open(file_path, "r") as f: return yaml.safe_load(f) config = read_yaml('config.yaml') sent_chkpt=config['SENTIMENT_CLF']['sent_chkpt'] sent_mdl_dir=config['SENTIMENT_CLF']['sent_mdl_dir'] sent_onnx_mdl_dir=config['SENTIMENT_CLF']['sent_onnx_mdl_dir'] sent_onnx_mdl_name=config['SENTIMENT_CLF']['sent_onnx_mdl_name'] sent_onnx_quant_mdl_name=config['SENTIMENT_CLF']['sent_onnx_quant_mdl_name'] zs_chkpt=config['ZEROSHOT_CLF']['zs_chkpt'] zs_mdl_dir=config['ZEROSHOT_CLF']['zs_mdl_dir'] zs_onnx_mdl_dir=config['ZEROSHOT_CLF']['zs_onnx_mdl_dir'] zs_onnx_mdl_name=config['ZEROSHOT_CLF']['zs_onnx_mdl_name'] zs_onnx_quant_mdl_name=config['ZEROSHOT_CLF']['zs_onnx_quant_mdl_name'] zs_mlm_chkpt=config['ZEROSHOT_MLM']['zs_mlm_chkpt'] zs_mlm_mdl_dir=config['ZEROSHOT_MLM']['zs_mlm_mdl_dir'] zs_mlm_onnx_mdl_dir=config['ZEROSHOT_MLM']['zs_mlm_onnx_mdl_dir'] zs_mlm_onnx_mdl_name=config['ZEROSHOT_MLM']['zs_mlm_onnx_mdl_name'] st.set_page_config( # Alternate names: setup_page, page, layout layout="wide", # Can be "centered" or "wide". In the future also "dashboard", etc. initial_sidebar_state="auto", # Can be "auto", "expanded", "collapsed" page_title='None', # String or None. Strings get appended with "• Streamlit". ) padding_top = 0 st.markdown(f""" """, unsafe_allow_html=True, ) def set_page_title(title): st.sidebar.markdown(unsafe_allow_html=True, body=f"""