Yoon-gu Hwang commited on
Commit
3bed1b1
β€’
1 Parent(s): ad8b121

make simple ux

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -5,7 +5,7 @@ with gr.Blocks() as demo:
5
  dataset_df = {}
6
  state = gr.State(value=0)
7
  with gr.Row():
8
- gr.Markdown("# Distributed Evaluation Parallel 😎")
9
  with gr.Row():
10
  file = gr.File(label="Upload a file")
11
  prev = gr.Button(value="Previous")
@@ -40,7 +40,6 @@ with gr.Blocks() as demo:
40
 
41
  def next_func(score):
42
  df_dict = dataset_df['df_dict']
43
- df_dict[state.value]['score'] = score
44
  state.value = min(state.value + 1, len(dataset_df['df']) - 1)
45
  score = df_dict[state.value]['score']
46
  gr.Info(f"총 {len(dataset_df['df'])}개 쀑에 {state.value + 1}번째 λ°μ΄ν„°μž…λ‹ˆλ‹€.")
@@ -56,9 +55,18 @@ with gr.Blocks() as demo:
56
  todos = df[df.score.isna()]
57
  done = df[df.score.isna() == False]
58
  return q, g, p, todos, done, "data_backup.csv"
 
59
  file.upload(csv2df, file, [question, ground_truth, prediction, todos, done, download])
60
  prev.click(prev_func, [score], [question, ground_truth, prediction, todos, done, download, score])
61
  next.click(next_func, [score], [question, ground_truth, prediction, todos, done, download, score])
 
 
 
 
 
 
 
 
62
 
63
  demo.queue()
64
  demo.launch()
 
5
  dataset_df = {}
6
  state = gr.State(value=0)
7
  with gr.Row():
8
+ gr.Markdown("# Evaluation 😎")
9
  with gr.Row():
10
  file = gr.File(label="Upload a file")
11
  prev = gr.Button(value="Previous")
 
40
 
41
  def next_func(score):
42
  df_dict = dataset_df['df_dict']
 
43
  state.value = min(state.value + 1, len(dataset_df['df']) - 1)
44
  score = df_dict[state.value]['score']
45
  gr.Info(f"총 {len(dataset_df['df'])}개 쀑에 {state.value + 1}번째 λ°μ΄ν„°μž…λ‹ˆλ‹€.")
 
55
  todos = df[df.score.isna()]
56
  done = df[df.score.isna() == False]
57
  return q, g, p, todos, done, "data_backup.csv"
58
+
59
  file.upload(csv2df, file, [question, ground_truth, prediction, todos, done, download])
60
  prev.click(prev_func, [score], [question, ground_truth, prediction, todos, done, download, score])
61
  next.click(next_func, [score], [question, ground_truth, prediction, todos, done, download, score])
62
+ def select_func(request: gr.Request, evt: gr.SelectData):
63
+ df_dict = dataset_df['df_dict']
64
+ df_dict[state.value]['score'] = evt.value
65
+ state.value = min(state.value + 1, len(dataset_df['df']) - 1)
66
+ score = df_dict[state.value]['score']
67
+ gr.Info(f"총 {len(dataset_df['df'])}개 쀑에 {state.value + 1}번째 λ°μ΄ν„°μž…λ‹ˆλ‹€.")
68
+ return [*update(), score]
69
+ score.select(select_func, None, [question, ground_truth, prediction, todos, done, download, score])
70
 
71
  demo.queue()
72
  demo.launch()