Spaces:
Sleeping
Sleeping
Davide Fiocco
commited on
Commit
·
76b4c44
1
Parent(s):
7c7d7c6
Modify the table truncation logic
Browse files
app.py
CHANGED
|
@@ -10,7 +10,7 @@ st.set_page_config(
|
|
| 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")
|
|
@@ -21,12 +21,15 @@ st.text(
|
|
| 21 |
data = st.file_uploader("Upload Excel file (it should contain a `text` column):")
|
| 22 |
labels = st.text_input("Enter comma-separated labels:")
|
| 23 |
|
|
|
|
|
|
|
|
|
|
| 24 |
if st.button("Calculate labels"):
|
| 25 |
|
| 26 |
try:
|
| 27 |
labels_list = labels.split(",")
|
| 28 |
table = pd.read_excel(data)
|
| 29 |
-
table = table.loc[table["text"].apply(len) > 10].reset_index(drop=True).head(
|
| 30 |
|
| 31 |
prog_bar = st.progress(0)
|
| 32 |
preds = []
|
|
@@ -41,5 +44,5 @@ if st.button("Calculate labels"):
|
|
| 41 |
|
| 42 |
except:
|
| 43 |
st.error(
|
| 44 |
-
"
|
| 45 |
)
|
|
|
|
| 10 |
menu_items=None,
|
| 11 |
)
|
| 12 |
|
| 13 |
+
with st.spinner("Setting stuff up related to the inference engine..."):
|
| 14 |
classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
|
| 15 |
|
| 16 |
st.title("Zero-shot classification from tabular data")
|
|
|
|
| 21 |
data = st.file_uploader("Upload Excel file (it should contain a `text` column):")
|
| 22 |
labels = st.text_input("Enter comma-separated labels:")
|
| 23 |
|
| 24 |
+
# classify first N snippets only for faster inference
|
| 25 |
+
N = 100
|
| 26 |
+
|
| 27 |
if st.button("Calculate labels"):
|
| 28 |
|
| 29 |
try:
|
| 30 |
labels_list = labels.split(",")
|
| 31 |
table = pd.read_excel(data)
|
| 32 |
+
table = table.loc[table["text"].apply(len) > 10].reset_index(drop=True).head(N)
|
| 33 |
|
| 34 |
prog_bar = st.progress(0)
|
| 35 |
preds = []
|
|
|
|
| 44 |
|
| 45 |
except:
|
| 46 |
st.error(
|
| 47 |
+
"Something went wrong. Make sure you upload an Excel file containing a `text` column and a set of comma-separated labels is provided"
|
| 48 |
)
|