asigalov61
commited on
Commit
•
1aa6fb6
1
Parent(s):
e11b4a1
Update app.py
Browse files
app.py
CHANGED
@@ -184,35 +184,30 @@ if __name__ == "__main__":
|
|
184 |
parser.add_argument("--port", type=int, default=7860, help="gradio server port")
|
185 |
parser.add_argument("--max-gen", type=int, default=1024, help="max")
|
186 |
opt = parser.parse_args()
|
187 |
-
soundfont_path =
|
188 |
models_info = {"generic pretrain model": ["skytnt/midi-model", ""],
|
189 |
"j-pop finetune model": ["skytnt/midi-model-ft", "jpop/"],
|
190 |
"touhou finetune model": ["skytnt/midi-model-ft", "touhou/"]}
|
191 |
-
|
192 |
-
tokenizer = MIDITokenizer()
|
193 |
-
providers = ['CUDAExecutionProvider', 'CPUExecutionProvider']
|
194 |
-
for name, (repo_id, path) in models_info.items():
|
195 |
-
model_base_path = hf_hub_download(repo_id=repo_id, filename=f"{path}onnx/model_base.onnx")
|
196 |
-
model_token_path = hf_hub_download(repo_id=repo_id, filename=f"{path}onnx/model_token.onnx")
|
197 |
-
model_base = rt.InferenceSession(model_base_path, providers=providers)
|
198 |
-
model_token = rt.InferenceSession(model_token_path, providers=providers)
|
199 |
-
models[name] = [model_base, model_token]
|
200 |
|
201 |
load_javascript()
|
202 |
app = gr.Blocks()
|
203 |
with app:
|
204 |
-
gr.Markdown("<h1 style='text-align: center; margin-bottom: 1rem'>
|
205 |
-
gr.Markdown("![Visitors](https://api.visitorbadge.io/api/visitors?path=
|
206 |
-
"
|
207 |
-
"Demo for [
|
208 |
"[Open In Colab]"
|
209 |
-
"(https://colab.research.google.com/github/
|
210 |
" for faster running and longer generation"
|
211 |
)
|
|
|
212 |
js_msg = JSMsgReceiver()
|
|
|
213 |
input_model = gr.Dropdown(label="select model", choices=list(models.keys()),
|
214 |
type="value", value=list(models.keys())[0])
|
215 |
tab_select = gr.Variable(value=0)
|
|
|
216 |
with gr.Tabs():
|
217 |
with gr.TabItem("instrument prompt") as tab1:
|
218 |
input_instruments = gr.Dropdown(label="instruments (auto if empty)", choices=list(patch2number.keys()),
|
@@ -259,4 +254,4 @@ if __name__ == "__main__":
|
|
259 |
input_allow_cc],
|
260 |
[output_midi_seq, output_midi, output_audio, js_msg])
|
261 |
stop_btn.click(cancel_run, output_midi_seq, [output_midi, output_audio, js_msg], cancels=run_event, queue=False)
|
262 |
-
app.queue(
|
|
|
184 |
parser.add_argument("--port", type=int, default=7860, help="gradio server port")
|
185 |
parser.add_argument("--max-gen", type=int, default=1024, help="max")
|
186 |
opt = parser.parse_args()
|
187 |
+
soundfont_path = "SGM-v2.01-YamahaGrand-Guit-Bass-v2.7.sf2"
|
188 |
models_info = {"generic pretrain model": ["skytnt/midi-model", ""],
|
189 |
"j-pop finetune model": ["skytnt/midi-model-ft", "jpop/"],
|
190 |
"touhou finetune model": ["skytnt/midi-model-ft", "touhou/"]}
|
191 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
192 |
|
193 |
load_javascript()
|
194 |
app = gr.Blocks()
|
195 |
with app:
|
196 |
+
gr.Markdown("<h1 style='text-align: center; margin-bottom: 1rem'>MIDI Search</h1>")
|
197 |
+
gr.Markdown("![Visitors](https://api.visitorbadge.io/api/visitors?path=asigalov61.MIDI-Search&style=flat)\n\n"
|
198 |
+
"MIDI Search and Explore\n\n"
|
199 |
+
"Demo for [MIDI Search](https://github.com/asigalov61)\n\n"
|
200 |
"[Open In Colab]"
|
201 |
+
"(https://colab.research.google.com/github/asigalov61/MIDI-Search/blob/main/demo.ipynb)"
|
202 |
" for faster running and longer generation"
|
203 |
)
|
204 |
+
|
205 |
js_msg = JSMsgReceiver()
|
206 |
+
|
207 |
input_model = gr.Dropdown(label="select model", choices=list(models.keys()),
|
208 |
type="value", value=list(models.keys())[0])
|
209 |
tab_select = gr.Variable(value=0)
|
210 |
+
|
211 |
with gr.Tabs():
|
212 |
with gr.TabItem("instrument prompt") as tab1:
|
213 |
input_instruments = gr.Dropdown(label="instruments (auto if empty)", choices=list(patch2number.keys()),
|
|
|
254 |
input_allow_cc],
|
255 |
[output_midi_seq, output_midi, output_audio, js_msg])
|
256 |
stop_btn.click(cancel_run, output_midi_seq, [output_midi, output_audio, js_msg], cancels=run_event, queue=False)
|
257 |
+
app.queue(1).launch(server_port=opt.port, share=opt.share, inbrowser=True)
|