asigalov61 commited on
Commit
ba9437d
·
verified ·
1 Parent(s): 8cad869

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -24
app.py CHANGED
@@ -117,35 +117,40 @@ def ID_MIDI(input_midi):
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'
125
- data += 'Keywords strings:' + '\n'
126
- data += output_midi_path_str
127
-
128
- messages = [
129
- {
130
- "role": "user",
131
- "content": prompt + "\n\n" + data
132
- }
133
- ]
134
-
135
- completion = client.chat.completions.create(
136
- #model="Qwen/Qwen2.5-72B-Instruct",
137
- model="mistralai/Mistral-Nemo-Instruct-2407",
138
- messages=messages,
139
- max_tokens=500
140
- )
141
 
142
- output_str = completion.choices[0].message['content']
 
 
143
 
144
- output_table_data = format_table_data(output_str)
 
 
 
 
 
145
 
146
- else:
 
 
 
 
 
 
 
147
 
148
- output_table_data = [['No matching MIDI ID records found', 'Unknown MIDI', 'Sorry :(']]
149
 
150
  print('Done!')
151
  print('=' * 70)
 
117
 
118
  output_midi_path_str = output_entry[1]
119
 
120
+ else:
121
 
122
+ raw_score = TMIDIX.midi2single_track_ms_score(fdata)
123
+ escore_notes = TMIDIX.advanced_score_processor(raw_score, return_enhanced_score_notes=True)[0]
124
+ escore_notes = TMIDIX.augment_enhanced_score_notes(escore_notes, sort_drums_last=True)
125
+
126
+ output_midi_src_dataset = 'unknown'
127
+ output_midi_path_str = TMIDIX.escore_notes_to_text_description(escore_notes)
128
+
129
+ client = InferenceClient(api_key=HF_TOKEN)
130
+
131
+ 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."
 
 
 
 
 
 
 
 
 
132
 
133
+ data = 'Source MIDI dataset: ' + output_midi_src_dataset + '\n'
134
+ data += 'Keywords strings:' + '\n'
135
+ data += output_midi_path_str
136
 
137
+ messages = [
138
+ {
139
+ "role": "user",
140
+ "content": prompt + "\n\n" + data
141
+ }
142
+ ]
143
 
144
+ completion = client.chat.completions.create(
145
+ #model="Qwen/Qwen2.5-72B-Instruct",
146
+ model="mistralai/Mistral-Nemo-Instruct-2407",
147
+ messages=messages,
148
+ max_tokens=500
149
+ )
150
+
151
+ output_str = completion.choices[0].message['content']
152
 
153
+ output_table_data = format_table_data(output_str)
154
 
155
  print('Done!')
156
  print('=' * 70)