asigalov61 commited on
Commit
7648069
·
verified ·
1 Parent(s): 210ae7b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -10
app.py CHANGED
@@ -103,19 +103,23 @@ def ID_MIDI(input_midi):
103
  output_midi_src_dataset= 'Unknown'
104
  output_midi_path_str = 'None'
105
 
106
- if new_midi_md5hash in MIDID_database:
107
 
108
- client = InferenceClient(api_key=HF_TOKEN)
109
-
110
- 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."
111
 
112
- output_midi_records_count = len(MIDID_database[new_midi_md5hash])
113
 
114
- output_entry = random.choice(MIDID_database[new_midi_md5hash])
115
 
116
- output_midi_src_dataset = output_entry['midi_dataset']
117
 
118
- output_midi_path_str = output_entry['midi_path']
 
 
 
 
119
 
120
  data = 'Source MIDI dataset: ' + output_midi_src_dataset + '\n' + output_midi_path_str
121
 
@@ -176,9 +180,9 @@ if __name__ == "__main__":
176
  print('=' * 70)
177
 
178
  print('Loading MIDID database...')
179
- midid_dataset = load_dataset("asigalov61/MIDID")
180
 
181
- midid_md5_hashes = midid_dataset['train']['midi_hash']
182
 
183
  print('Done!')
184
  print('=' * 70)
 
103
  output_midi_src_dataset= 'Unknown'
104
  output_midi_path_str = 'None'
105
 
106
+ if new_midi_md5hash in midid_md5_hashes:
107
 
108
+ midid_entry_idx = midid_md5_hashes.index(new_midi_md5hash)
109
+
110
+ MIDID_record = midid_dataset[midid_entry_idx]
111
 
112
+ output_midi_records_count = len(MIDID_record)
113
 
114
+ output_entry = random.choice(MIDID_record)
115
 
116
+ output_midi_src_dataset = output_entry[0]
117
 
118
+ output_midi_path_str = output_entry[1]
119
+
120
+ client = InferenceClient(api_key=HF_TOKEN)
121
+
122
+ 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."
123
 
124
  data = 'Source MIDI dataset: ' + output_midi_src_dataset + '\n' + output_midi_path_str
125
 
 
180
  print('=' * 70)
181
 
182
  print('Loading MIDID database...')
183
+ midid_dataset = load_dataset("asigalov61/MIDID")['train']
184
 
185
+ midid_md5_hashes = midid_dataset['midi_hash']
186
 
187
  print('Done!')
188
  print('=' * 70)