Spaces:
Runtime error
Runtime error
File size: 926 Bytes
4038adb d2096ca 544b432 af4af87 544b432 af4af87 4038adb 544b432 d2096ca 4038adb 544b432 d2096ca 4038adb 544b432 4038adb 544b432 4038adb 544b432 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import os
from transformers import pipeline
import streamlit as st
'''port = int(os.environ.get("PORT", 7860))
st.set_page_config(page_title="Text Classifier")
st.write(f"Running on port {port} (for Hugging Face)")
'''
# Use local cache directory to avoid permission issues
##os.environ['TRANSFORMERS_CACHE'] = '/app/cache'
# Create zero-shot classification pipeline
##classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
# Streamlit UI
st.title("Zero-Shot Text Classifier")
text = st.text_area("Enter text to classify")
labels = st.text_input("Enter candidate labels (comma-separated)", "finance, education, health")
'''
if st.button("Classify"):
if text and labels:
label_list = [l.strip() for l in labels.split(",")]
result = classifier(text, candidate_labels=label_list)
st.write(result)
else:
st.warning("Please enter both text and labels.")
''' |