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