from typing import Sequence import streamlit as st from hf_model import classifier_zero,load_model from utils import plot_result classifier=load_model() if __name__ == '__main__': st.header("Zero Shot Classification") sequence = st.text_area(label="Input Sequence") labels = st.text_input('Possible topics (separated by `,`)', max_chars=1000) labels = list(set([x.strip() for x in labels.strip().split(',') if len(x.strip()) > 0])) if len(labels) == 0 or len(sequence) == 0: st.write('Enter some text and at least one possible topic to see predictions.') multi_class = st.checkbox('Allow multiple correct topics', value=True) with st.spinner('Classifying...'): top_topics, scores = classifier_zero(classifier,sequence=sequence,labels=labels,multi_class=multi_class) plot_result(top_topics[::-1][-10:], scores[::-1][-10:])