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

update upload function

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -29,17 +29,20 @@ def prediction(news):
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:
40
- results.append(prediction(news))
 
41
 
42
- return results
 
43
 
44
 
45
  gradio_ui = gr.Interface(
 
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
+ file_content = file.read().decode('utf-8')
37
+ news_list = file_content.splitlines()
38
 
39
  results = []
40
  for news in news_list:
41
+ if news.strip():
42
+ results.append(prediction(news))
43
 
44
+ return pd.DataFrame(results, index=news_list)
45
+
46
 
47
 
48
  gradio_ui = gr.Interface(