asigalov61 commited on
Commit
e9c4cef
·
verified ·
1 Parent(s): 6d6617d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -5
app.py CHANGED
@@ -97,6 +97,7 @@ def ID_MIDI(input_midi):
97
  print('Processing...Please wait...')
98
 
99
  output_str = 'None'
 
100
  output_midi_src_dataset= 'Unknown'
101
  output_midi_path_str = 'None'
102
 
@@ -106,9 +107,13 @@ def ID_MIDI(input_midi):
106
 
107
  prompt = "Please create a summary table for a MIDI file based on the following keywords strings, best possible description and best possible summary fields. Please respond with the table only. Do not say anything else. Thank you."
108
 
109
- output_midi_src_dataset = MIDID_database[new_midi_md5hash][0]['midi_dataset']
110
 
111
- output_midi_path_str = MIDID_database[new_midi_md5hash][0]['midi_path']
 
 
 
 
112
 
113
  data = 'Source MIDI dataset: ' + output_midi_src_dataset + '\n' + output_midi_path_str
114
 
@@ -136,7 +141,8 @@ def ID_MIDI(input_midi):
136
 
137
  print('Done!')
138
  print('=' * 70)
139
- print('Source MIDI dataset', output_midi_src_dataset)
 
140
  print('Original MIDI path string', output_midi_path_str)
141
  print('=' * 70)
142
  print(output_str)
@@ -155,7 +161,7 @@ def ID_MIDI(input_midi):
155
 
156
  #========================================================
157
 
158
- return output_midi_md5, output_midi_src_dataset, output_midi_path_str, output_table_data
159
 
160
  #==========================================================================================================
161
 
@@ -192,13 +198,15 @@ if __name__ == "__main__":
192
  gr.Markdown("## MIDI identification results")
193
 
194
  output_midi_md5 = gr.Textbox(label="Monster MIDI dataset md5 hash")
195
- output_midi_src_dataset = gr.Textbox(label="Source MIDI dataset pretty name")
 
196
  output_midi_path_str = gr.Textbox(label="Original MIDI raw path string")
197
  output_MIDID_results_table = gr.Dataframe(label="MIDID database results table", wrap=True, col_count=(3, 'dynamic'))
198
 
199
  run_event = submit.click(ID_MIDI, [input_midi,
200
  ],
201
  [output_midi_md5,
 
202
  output_midi_src_dataset,
203
  output_midi_path_str,
204
  output_MIDID_results_table
 
97
  print('Processing...Please wait...')
98
 
99
  output_str = 'None'
100
+ output_midi_records_count = 0
101
  output_midi_src_dataset= 'Unknown'
102
  output_midi_path_str = 'None'
103
 
 
107
 
108
  prompt = "Please create a summary table for a MIDI file based on the following keywords strings, best possible description and best possible summary fields. Please respond with the table only. Do not say anything else. Thank you."
109
 
110
+ output_midi_records_count = len(MIDID_database[new_midi_md5hash])
111
 
112
+ output_entry = random.choice(MIDID_database[new_midi_md5hash])
113
+
114
+ output_midi_src_dataset = output_entry['midi_dataset']
115
+
116
+ output_midi_path_str = output_entry['midi_path']
117
 
118
  data = 'Source MIDI dataset: ' + output_midi_src_dataset + '\n' + output_midi_path_str
119
 
 
141
 
142
  print('Done!')
143
  print('=' * 70)
144
+ print('Original MIDI unique records count', output_midi_records_count)
145
+ print('Original MIDI dataset', output_midi_src_dataset)
146
  print('Original MIDI path string', output_midi_path_str)
147
  print('=' * 70)
148
  print(output_str)
 
161
 
162
  #========================================================
163
 
164
+ return output_midi_md5, output_midi_records_count, output_midi_src_dataset, output_midi_path_str, output_table_data
165
 
166
  #==========================================================================================================
167
 
 
198
  gr.Markdown("## MIDI identification results")
199
 
200
  output_midi_md5 = gr.Textbox(label="Monster MIDI dataset md5 hash")
201
+ output_midi_records_count = gr.Textbox(label="Original MIDI unique records count")
202
+ output_midi_src_dataset = gr.Textbox(label="Original MIDI dataset pretty name")
203
  output_midi_path_str = gr.Textbox(label="Original MIDI raw path string")
204
  output_MIDID_results_table = gr.Dataframe(label="MIDID database results table", wrap=True, col_count=(3, 'dynamic'))
205
 
206
  run_event = submit.click(ID_MIDI, [input_midi,
207
  ],
208
  [output_midi_md5,
209
+ output_midi_records_count,
210
  output_midi_src_dataset,
211
  output_midi_path_str,
212
  output_MIDID_results_table