Peter commited on
Commit
edb05fc
1 Parent(s): 4dc1508
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -116,6 +116,7 @@ def load_single_example_text(
116
  text = clean(raw_text, lower=False)
117
  return text
118
 
 
119
  def load_uploaded_file(file_obj):
120
  """
121
  load_uploaded_file - process an uploaded file
@@ -130,7 +131,7 @@ def load_uploaded_file(file_obj):
130
  file_path = Path(file_obj[0].name)
131
 
132
  try:
133
- with open(file_path, "r", encoding='utf-8', errors='ignore') as f:
134
  raw_text = f.read()
135
  text = clean(raw_text, lower=False)
136
  return text
@@ -138,6 +139,7 @@ def load_uploaded_file(file_obj):
138
  logging.info(f"Trying to load file with path {file_path}, error: {e}")
139
  return "Error: Could not read file. Ensure that it is a valid text file with encoding UTF-8."
140
 
 
141
  if __name__ == "__main__":
142
 
143
  model, tokenizer = load_model_and_tokenizer("pszemraj/led-large-book-summary")
@@ -206,9 +208,7 @@ if __name__ == "__main__":
206
  file_count=1,
207
  type="file",
208
  )
209
- load_file_button = gr.Button(
210
- "Load Uploaded File"
211
- )
212
 
213
  with gr.Column():
214
  gr.Markdown("## Generate Summary")
 
116
  text = clean(raw_text, lower=False)
117
  return text
118
 
119
+
120
  def load_uploaded_file(file_obj):
121
  """
122
  load_uploaded_file - process an uploaded file
 
131
  file_path = Path(file_obj[0].name)
132
 
133
  try:
134
+ with open(file_path, "r", encoding="utf-8", errors="ignore") as f:
135
  raw_text = f.read()
136
  text = clean(raw_text, lower=False)
137
  return text
 
139
  logging.info(f"Trying to load file with path {file_path}, error: {e}")
140
  return "Error: Could not read file. Ensure that it is a valid text file with encoding UTF-8."
141
 
142
+
143
  if __name__ == "__main__":
144
 
145
  model, tokenizer = load_model_and_tokenizer("pszemraj/led-large-book-summary")
 
208
  file_count=1,
209
  type="file",
210
  )
211
+ load_file_button = gr.Button("Load Uploaded File")
 
 
212
 
213
  with gr.Column():
214
  gr.Markdown("## Generate Summary")