zionia commited on
Commit
9a2fed2
1 Parent(s): 15a27ae

update the upload function

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -28,12 +28,12 @@ def prediction(news):
28
  return preds_dict
29
 
30
  def file_prediction(file):
31
- # Load the file (CSV or text)
32
  if file.name.endswith('.csv'):
33
- df = pd.read_csv(file.name)
34
  news_list = df.iloc[:, 0].tolist()
35
  else:
36
- news_list = [file.read().decode('utf-8')]
 
37
 
38
  results = []
39
  for news in news_list:
@@ -41,6 +41,7 @@ def file_prediction(file):
41
 
42
  return results
43
 
 
44
  gradio_ui = gr.Interface(
45
  fn=prediction,
46
  title="Setswana News Classification",
 
28
  return preds_dict
29
 
30
  def file_prediction(file):
 
31
  if file.name.endswith('.csv'):
32
+ df = pd.read_csv(file)
33
  news_list = df.iloc[:, 0].tolist()
34
  else:
35
+ file.seek(0)
36
+ news_list = file.read().decode('utf-8').splitlines()
37
 
38
  results = []
39
  for news in news_list:
 
41
 
42
  return results
43
 
44
+
45
  gradio_ui = gr.Interface(
46
  fn=prediction,
47
  title="Setswana News Classification",