Spaces:
Runtime error
Runtime error
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") | |
with st.form(key='my_form'): | |
text_input = st.text_area(label="Input Sequence") | |
labels = st.text_input('Possible topics (separated by `,`)', max_chars=1000) | |
submit_button = st.form_submit_button(label='Submit') | |
labels = list(set([x.strip() for x in labels.strip().split(',') if len(x.strip()) > 0])) | |
multi_class = st.checkbox('Allow multiple correct topics', value=True) | |
if st.button("Predict"): | |
if len(labels) == 0: | |
st.write('Enter some text and at least one possible topic to see predictions.') | |
top_topics, scores = classifier_zero(classifier,sequence=text_input,labels=labels,multi_class=multi_class) | |
plot_result(top_topics[::-1][-10:], scores[::-1][-10:]) | |