jayebaku commited on
Commit
6b08849
·
verified ·
1 Parent(s): cd14702

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -39,6 +39,7 @@ def single_classification(text, event_model, threshold):
39
  return res["event"], res["score"]
40
 
41
  def load_and_classify_csv(file, text_field, event_model, threshold):
 
42
  filepath = file.name
43
  if ".csv" in filepath:
44
  df = pd.read_csv(filepath)
@@ -66,7 +67,7 @@ def load_and_classify_csv(file, text_field, event_model, threshold):
66
  return flood_related, fire_related, not_related, model_confidence, len(df[text_field].to_list()), df, gr.update(interactive=True), gr.update(interactive=True)
67
 
68
  def load_and_classify_csv_dataframe(file, text_field, event_model, threshold):
69
-
70
  filepath = file.name
71
  if ".csv" in filepath:
72
  df = pd.read_csv(filepath)
@@ -98,6 +99,7 @@ def load_and_classify_csv_dataframe(file, text_field, event_model, threshold):
98
 
99
 
100
  def calculate_accuracy(flood_selections, fire_selections, none_selections, num_posts, text_field, data_df):
 
101
  posts = data_df[text_field].to_list()
102
  selections = flood_selections + fire_selections + none_selections
103
  eval = []
@@ -284,7 +286,12 @@ with gr.Blocks(fill_width=True) as demo:
284
  with gr.Group():
285
  with gr.Row():
286
  with gr.Column(scale=7):
287
- qa_df = gr.DataFrame()
 
 
 
 
 
288
  with gr.Column(scale=3):
289
  qa_tweet_embed = gr.HTML("""<div id="tweet-container2"></div>""")
290
 
 
39
  return res["event"], res["score"]
40
 
41
  def load_and_classify_csv(file, text_field, event_model, threshold):
42
+ text_field = text_field.strip()
43
  filepath = file.name
44
  if ".csv" in filepath:
45
  df = pd.read_csv(filepath)
 
67
  return flood_related, fire_related, not_related, model_confidence, len(df[text_field].to_list()), df, gr.update(interactive=True), gr.update(interactive=True)
68
 
69
  def load_and_classify_csv_dataframe(file, text_field, event_model, threshold):
70
+ text_field = text_field.strip()
71
  filepath = file.name
72
  if ".csv" in filepath:
73
  df = pd.read_csv(filepath)
 
99
 
100
 
101
  def calculate_accuracy(flood_selections, fire_selections, none_selections, num_posts, text_field, data_df):
102
+ text_field = text_field.strip()
103
  posts = data_df[text_field].to_list()
104
  selections = flood_selections + fire_selections + none_selections
105
  eval = []
 
286
  with gr.Group():
287
  with gr.Row():
288
  with gr.Column(scale=7):
289
+ qa_df = gr.DataFrame(wrap=True,
290
+ show_fullscreen_button=True,
291
+ show_copy_button=True,
292
+ show_search="filter",
293
+ max_height=1000,
294
+ column_widths=["10%","70%","20%"])
295
  with gr.Column(scale=3):
296
  qa_tweet_embed = gr.HTML("""<div id="tweet-container2"></div>""")
297