Spaces:
Sleeping
Sleeping
Peter
commited on
Commit
•
11da24b
1
Parent(s):
571c966
:sparkles: add sharing for local testing
Browse files
app.py
CHANGED
@@ -128,15 +128,15 @@ def load_uploaded_file(file_obj):
|
|
128 |
str, the uploaded file contents
|
129 |
"""
|
130 |
|
131 |
-
file_path = Path(file_obj[0].name)
|
132 |
|
133 |
try:
|
134 |
-
with open(
|
135 |
raw_text = f.read()
|
136 |
text = clean(raw_text, lower=False)
|
137 |
return text
|
138 |
except Exception as e:
|
139 |
-
logging.info(f"Trying to load file with path {
|
140 |
return "Error: Could not read file. Ensure that it is a valid text file with encoding UTF-8."
|
141 |
|
142 |
|
@@ -248,7 +248,7 @@ if __name__ == "__main__":
|
|
248 |
)
|
249 |
|
250 |
load_file_button.click(
|
251 |
-
fn=load_uploaded_file, inputs=
|
252 |
)
|
253 |
|
254 |
summarize_button.click(
|
|
|
128 |
str, the uploaded file contents
|
129 |
"""
|
130 |
|
131 |
+
# file_path = Path(file_obj[0].name)
|
132 |
|
133 |
try:
|
134 |
+
with open(file_obj, "r", encoding="utf-8", errors="ignore") as f:
|
135 |
raw_text = f.read()
|
136 |
text = clean(raw_text, lower=False)
|
137 |
return text
|
138 |
except Exception as e:
|
139 |
+
logging.info(f"Trying to load file with path {file_obj}, error: {e}")
|
140 |
return "Error: Could not read file. Ensure that it is a valid text file with encoding UTF-8."
|
141 |
|
142 |
|
|
|
248 |
)
|
249 |
|
250 |
load_file_button.click(
|
251 |
+
fn=load_uploaded_file, inputs=uploaded_file, outputs=[input_text]
|
252 |
)
|
253 |
|
254 |
summarize_button.click(
|