Spaces:
Runtime error
Runtime error
File size: 893 Bytes
17a8518 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
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:])
|