Epsilon617 commited on
Commit
e85f544
1 Parent(s): ebd2b6f

update output format

Browse files
Files changed (2) hide show
  1. __pycache__/app.cpython-310.pyc +0 -0
  2. app.py +8 -8
__pycache__/app.cpython-310.pyc CHANGED
Binary files a/__pycache__/app.cpython-310.pyc and b/__pycache__/app.cpython-310.pyc differ
 
app.py CHANGED
@@ -48,13 +48,13 @@ audio_examples = [
48
  # ["input/example-2.wav"],
49
  ]
50
 
51
- df_init = pd.DataFrame(columns=['Task', 'Top 1', 'Top 2', 'Top 3'])
52
  transcription_df = gr.DataFrame(value=df_init, label="Output Dataframe", row_count=(
53
  0, "dynamic"), max_rows=30, wrap=True, overflow_row_behaviour='paginate')
54
  # outputs = [gr.components.Textbox()]
55
  outputs = transcription_df
56
 
57
- df_init_live = pd.DataFrame(columns=['Task', 'Top 1', 'Top 2', 'Top 3'])
58
  transcription_df_live = gr.DataFrame(value=df_init_live, label="Output Dataframe", row_count=(
59
  0, "dynamic"), max_rows=30, wrap=True, overflow_row_behaviour='paginate')
60
  outputs_live = transcription_df_live
@@ -143,7 +143,7 @@ def model_infernce(inputs):
143
  all_layer_hidden_states = all_layer_hidden_states.mean(dim=2)
144
 
145
  task_output_texts = ""
146
- df = pd.DataFrame(columns=['Task', 'Top 1', 'Top 2', 'Top 3'])
147
  df_objects = []
148
 
149
  for task in TASKS:
@@ -159,9 +159,9 @@ def model_infernce(inputs):
159
  # print(sorted_prob)
160
  # print(sorted_prob.shape)
161
 
162
- top_n_show = 3 if num_class >= 3 else num_class
163
- task_output_texts = task_output_texts + f"TASK {task} output:\n" + "\n".join([str(ID2CLASS[task][str(sorted_idx[idx].item())])+f', probability: {sorted_prob[idx].item():.2%}' for idx in range(top_n_show)]) + '\n'
164
- task_output_texts = task_output_texts + '----------------------\n'
165
 
166
  row_elements = [task]
167
  for idx in range(top_n_show):
@@ -174,10 +174,10 @@ def model_infernce(inputs):
174
  output_prob = f' {sorted_prob[idx].item():.2%}'
175
  row_elements.append(output_class_name+output_prob)
176
  # fill empty elment
177
- for _ in range(4 - len(row_elements)):
178
  row_elements.append(' ')
179
  df_objects.append(row_elements)
180
- df = pd.DataFrame(df_objects, columns=['Task', 'Top 1', 'Top 2', 'Top 3'])
181
  return df
182
 
183
  def convert_audio(inputs, microphone):
 
48
  # ["input/example-2.wav"],
49
  ]
50
 
51
+ df_init = pd.DataFrame(columns=['Task', 'Top 1', 'Top 2', 'Top 3', 'Top 4', 'Top 5'])
52
  transcription_df = gr.DataFrame(value=df_init, label="Output Dataframe", row_count=(
53
  0, "dynamic"), max_rows=30, wrap=True, overflow_row_behaviour='paginate')
54
  # outputs = [gr.components.Textbox()]
55
  outputs = transcription_df
56
 
57
+ df_init_live = pd.DataFrame(columns=['Task', 'Top 1', 'Top 2', 'Top 3', 'Top 4', 'Top 5'])
58
  transcription_df_live = gr.DataFrame(value=df_init_live, label="Output Dataframe", row_count=(
59
  0, "dynamic"), max_rows=30, wrap=True, overflow_row_behaviour='paginate')
60
  outputs_live = transcription_df_live
 
143
  all_layer_hidden_states = all_layer_hidden_states.mean(dim=2)
144
 
145
  task_output_texts = ""
146
+ df = pd.DataFrame(columns=['Task', 'Top 1', 'Top 2', 'Top 3', 'Top 4', 'Top 5'])
147
  df_objects = []
148
 
149
  for task in TASKS:
 
159
  # print(sorted_prob)
160
  # print(sorted_prob.shape)
161
 
162
+ top_n_show = 5 if num_class >= 5 else num_class
163
+ # task_output_texts = task_output_texts + f"TASK {task} output:\n" + "\n".join([str(ID2CLASS[task][str(sorted_idx[idx].item())])+f', probability: {sorted_prob[idx].item():.2%}' for idx in range(top_n_show)]) + '\n'
164
+ # task_output_texts = task_output_texts + '----------------------\n'
165
 
166
  row_elements = [task]
167
  for idx in range(top_n_show):
 
174
  output_prob = f' {sorted_prob[idx].item():.2%}'
175
  row_elements.append(output_class_name+output_prob)
176
  # fill empty elment
177
+ for _ in range(5+1 - len(row_elements)):
178
  row_elements.append(' ')
179
  df_objects.append(row_elements)
180
+ df = pd.DataFrame(df_objects, columns=['Task', 'Top 1', 'Top 2', 'Top 3', 'Top 4', 'Top 5'])
181
  return df
182
 
183
  def convert_audio(inputs, microphone):