asigalov61
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -25,7 +25,7 @@ in_space = os.getenv("SYSTEM") == "spaces"
|
|
25 |
# =================================================================================================
|
26 |
|
27 |
@spaces.GPU
|
28 |
-
def ClassifyMIDI(input_midi):
|
29 |
|
30 |
print('=' * 70)
|
31 |
print('Req start time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT)))
|
@@ -125,7 +125,7 @@ def ClassifyMIDI(input_midi):
|
|
125 |
|
126 |
input_data = []
|
127 |
|
128 |
-
for i in range(0, len(score)-chunk_size, chunk_size //
|
129 |
schunk = score[i:i+chunk_size]
|
130 |
|
131 |
if len(schunk) == chunk_size:
|
@@ -146,7 +146,7 @@ def ClassifyMIDI(input_midi):
|
|
146 |
classification_summary_string = '=' * 70
|
147 |
classification_summary_string += '\n'
|
148 |
|
149 |
-
samples_overlap = 340 - chunk_size //
|
150 |
|
151 |
print('Composition has', notes_counter, 'notes')
|
152 |
print('=' * 70)
|
@@ -377,6 +377,7 @@ if __name__ == "__main__":
|
|
377 |
gr.Markdown("## Upload any MIDI to classify")
|
378 |
|
379 |
input_midi = gr.File(label="Input MIDI", file_types=[".midi", ".mid", ".kar"])
|
|
|
380 |
|
381 |
run_btn = gr.Button("classify", variant="primary")
|
382 |
|
@@ -384,7 +385,7 @@ if __name__ == "__main__":
|
|
384 |
|
385 |
output_midi_cls_summary = gr.Textbox(label="MIDI classification results")
|
386 |
|
387 |
-
run_event = run_btn.click(ClassifyMIDI, [input_midi],
|
388 |
[output_midi_cls_summary])
|
389 |
|
390 |
app.queue().launch()
|
|
|
25 |
# =================================================================================================
|
26 |
|
27 |
@spaces.GPU
|
28 |
+
def ClassifyMIDI(input_midi, input_sampling_resolution):
|
29 |
|
30 |
print('=' * 70)
|
31 |
print('Req start time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT)))
|
|
|
125 |
|
126 |
input_data = []
|
127 |
|
128 |
+
for i in range(0, len(score)-chunk_size, chunk_size // input_sampling_resolution):
|
129 |
schunk = score[i:i+chunk_size]
|
130 |
|
131 |
if len(schunk) == chunk_size:
|
|
|
146 |
classification_summary_string = '=' * 70
|
147 |
classification_summary_string += '\n'
|
148 |
|
149 |
+
samples_overlap = 340 - chunk_size // input_sampling_resolution // 3
|
150 |
|
151 |
print('Composition has', notes_counter, 'notes')
|
152 |
print('=' * 70)
|
|
|
377 |
gr.Markdown("## Upload any MIDI to classify")
|
378 |
|
379 |
input_midi = gr.File(label="Input MIDI", file_types=[".midi", ".mid", ".kar"])
|
380 |
+
input_sampling_resolution = gr.Slider(1, 5, value=2, step=1, label="Classification sampling resolution")
|
381 |
|
382 |
run_btn = gr.Button("classify", variant="primary")
|
383 |
|
|
|
385 |
|
386 |
output_midi_cls_summary = gr.Textbox(label="MIDI classification results")
|
387 |
|
388 |
+
run_event = run_btn.click(ClassifyMIDI, [input_midi, input_sampling_resolution],
|
389 |
[output_midi_cls_summary])
|
390 |
|
391 |
app.queue().launch()
|