Spaces:
Runtime error
Runtime error
File size: 742 Bytes
e7429d7 1cacc37 82a84ea e7429d7 e3a7576 e7429d7 1cacc37 598a151 1cacc37 598a151 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import streamlit as st
from transformers import pipeline
st.title("Text Classifier 1")
st.write("Input text and labels -- comma separate labels. Submit. The machine will classify the text according to one of the labels. It will also present a score for classifying that text for that label.")
classifier = pipeline(task="zero-shot-classification")
form = st.form(key='zeroclassifier_form')
input_text = form.text_input(label='Input Text')
labels = form.text_input(label='Labels -- comma separate labels')
submit_button = form.form_submit_button(label='Submit')
if submit_button:
labs = labels.title().split(',')
text = input_text.title()
res = classifier(text, labs)
st.success(res['labels'][0])
st.info(res['scores'][0])
|