Qifan Zhang commited on
Commit
b49f004
1 Parent(s): 23ec45d

add dataframe in frontend

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -45,9 +45,9 @@ def process(task_name: str,
45
  # save
46
  path = 'output.csv'
47
  df.to_csv(path, index=False, encoding='utf-8-sig')
48
- return str(df), path
49
  except Exception as e:
50
- return {'Error': e}, None
51
 
52
 
53
  instructions = 'Please upload a file or paste the text below. '
@@ -81,6 +81,10 @@ text_output = gr.components.Textbox(
81
  type='text'
82
  )
83
 
 
 
 
 
84
  description = open('description.txt', 'r').read()
85
 
86
  file_output = gr.components.File(label='Output File',
@@ -90,7 +94,7 @@ file_output = gr.components.File(label='Output File',
90
  app = gr.Interface(
91
  fn=process,
92
  inputs=[task_name_dropdown, model_name_dropdown, text_input, 'file'],
93
- outputs=[text_output, file_output],
94
  description=description
95
  )
96
  app.launch()
 
45
  # save
46
  path = 'output.csv'
47
  df.to_csv(path, index=False, encoding='utf-8-sig')
48
+ return None, df.iloc[:10], path
49
  except Exception as e:
50
+ return {'Error': e}, None, None
51
 
52
 
53
  instructions = 'Please upload a file or paste the text below. '
 
81
  type='text'
82
  )
83
 
84
+ dataframe_output = gr.components.Dataframe(
85
+ label='DataFrame'
86
+ )
87
+
88
  description = open('description.txt', 'r').read()
89
 
90
  file_output = gr.components.File(label='Output File',
 
94
  app = gr.Interface(
95
  fn=process,
96
  inputs=[task_name_dropdown, model_name_dropdown, text_input, 'file'],
97
+ outputs=[text_output, dataframe_output, file_output],
98
  description=description
99
  )
100
  app.launch()