Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -45,10 +45,26 @@ id2label = {
|
|
45 |
14: 'Women'}
|
46 |
|
47 |
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
par_list = get_paragraphs(uploaded_file)
|
50 |
|
51 |
-
|
52 |
preds = vg_model(par_list)
|
53 |
|
54 |
# Get label names
|
|
|
45 |
14: 'Women'}
|
46 |
|
47 |
|
48 |
+
### Process document to paragraphs
|
49 |
+
# Source: https://blog.jcharistech.com/2021/01/21/how-to-save-uploaded-files-to-directory-in-streamlit-apps/
|
50 |
+
|
51 |
+
# Store uploaded file temporarily in directory to get file path (necessary for processing)
|
52 |
+
def save_uploadedfile(upl_file):
|
53 |
+
with open(os.path.join("tempDir",upl_file.name),"wb") as f:
|
54 |
+
f.write(upl_file.getbuffer())
|
55 |
+
return st.success("Saved File:{} to tempDir".format(upl_file.name))
|
56 |
+
|
57 |
+
if uploaded_file is not None:
|
58 |
+
# Save the file
|
59 |
+
file_details = {"FileName": uploaded_file.name, "FileType": uploaded_file.type}
|
60 |
+
save_uploadedfile(uploaded_file)
|
61 |
+
|
62 |
+
#Get the file path
|
63 |
+
|
64 |
+
|
65 |
par_list = get_paragraphs(uploaded_file)
|
66 |
|
67 |
+
### Make predictions
|
68 |
preds = vg_model(par_list)
|
69 |
|
70 |
# Get label names
|