Spaces:
Sleeping
Sleeping
Davide Fiocco
commited on
Commit
·
7c7d7c6
1
Parent(s):
501b061
Improve messaging about model loading
Browse files
app.py
CHANGED
@@ -1,13 +1,22 @@
|
|
1 |
-
import streamlit as st
|
2 |
import pandas as pd
|
|
|
3 |
from transformers import pipeline
|
4 |
|
5 |
-
st.set_page_config(
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
-
|
|
|
8 |
|
9 |
st.title("Zero-shot classification from tabular data")
|
10 |
-
st.text(
|
|
|
|
|
11 |
|
12 |
data = st.file_uploader("Upload Excel file (it should contain a `text` column):")
|
13 |
labels = st.text_input("Enter comma-separated labels:")
|
@@ -24,14 +33,13 @@ if st.button("Calculate labels"):
|
|
24 |
|
25 |
for i in range(len(table)):
|
26 |
preds.append(classifier(table.loc[i, "text"], labels)["labels"][0])
|
27 |
-
prog_bar.progress((i + 1)/len(table))
|
28 |
|
29 |
table["label"] = preds
|
30 |
|
31 |
st.table(table[["text", "label"]])
|
32 |
|
33 |
except:
|
34 |
-
st.error(
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
1 |
import pandas as pd
|
2 |
+
import streamlit as st
|
3 |
from transformers import pipeline
|
4 |
|
5 |
+
st.set_page_config(
|
6 |
+
page_title="Zero-shot classification from tabular data",
|
7 |
+
page_icon=None,
|
8 |
+
layout="wide",
|
9 |
+
initial_sidebar_state="auto",
|
10 |
+
menu_items=None,
|
11 |
+
)
|
12 |
|
13 |
+
with st.spinner("Setting stuff up..."):
|
14 |
+
classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
|
15 |
|
16 |
st.title("Zero-shot classification from tabular data")
|
17 |
+
st.text(
|
18 |
+
"Upload an Excel table and perform zero-shot classification on a set of custom labels"
|
19 |
+
)
|
20 |
|
21 |
data = st.file_uploader("Upload Excel file (it should contain a `text` column):")
|
22 |
labels = st.text_input("Enter comma-separated labels:")
|
|
|
33 |
|
34 |
for i in range(len(table)):
|
35 |
preds.append(classifier(table.loc[i, "text"], labels)["labels"][0])
|
36 |
+
prog_bar.progress((i + 1) / len(table))
|
37 |
|
38 |
table["label"] = preds
|
39 |
|
40 |
st.table(table[["text", "label"]])
|
41 |
|
42 |
except:
|
43 |
+
st.error(
|
44 |
+
"File load didn't work. Make sure you upload a file containing a `text` column and a set of comma-separated labels is provided"
|
45 |
+
)
|
|