Spaces:
Sleeping
Sleeping
Davide Fiocco
commited on
Commit
·
2b07bf2
1
Parent(s):
a452638
Debug download button
Browse files
app.py
CHANGED
@@ -46,30 +46,24 @@ labels = st.text_input("Enter comma-separated labels:")
|
|
46 |
|
47 |
if st.button("Calculate labels"):
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
table = table.loc[table["text"].apply(len) > 10].reset_index(drop=True)
|
53 |
|
54 |
-
|
55 |
-
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
|
61 |
-
|
62 |
|
63 |
-
|
64 |
|
65 |
-
|
66 |
-
|
67 |
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
except:
|
73 |
-
st.error(
|
74 |
-
"Something went wrong. Make sure you upload an Excel file containing a column named `text` and a set of comma-separated labels is provided"
|
75 |
-
)
|
|
|
46 |
|
47 |
if st.button("Calculate labels"):
|
48 |
|
49 |
+
labels_list = labels.split(",")
|
50 |
+
table = pd.read_excel(data)
|
51 |
+
table = table.loc[table["text"].apply(len) > 10].reset_index(drop=True)
|
|
|
52 |
|
53 |
+
prog_bar = st.progress(0)
|
54 |
+
preds = []
|
55 |
|
56 |
+
for i in range(len(table)):
|
57 |
+
preds.append(classifier(table.loc[i, "text"], labels)["labels"][0])
|
58 |
+
prog_bar.progress((i + 1) / len(table))
|
59 |
|
60 |
+
table["label"] = preds
|
61 |
|
62 |
+
st.table(table[["text", "label"]])
|
63 |
|
64 |
+
buf = BytesIO()
|
65 |
+
table[["text", "label"]].to_excel(buf)
|
66 |
|
67 |
+
st.download_button(
|
68 |
+
label="Download table", data=buf.getvalue(), file_name="output.xlsx"
|
69 |
+
)
|
|
|
|
|
|
|
|
|
|