harp-dev commited on
Commit
3ec01ff
·
verified ·
1 Parent(s): d5effc1

Bring the Space up to the pyharp example standard (taxonomy tags, __main__ guard, show_error, v0.4.0)

Browse files
Files changed (3) hide show
  1. README.md +1 -1
  2. app.py +46 -46
  3. requirements.txt +1 -0
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 📝
4
  colorFrom: yellow
5
  colorTo: green
6
  sdk: gradio
7
- sdk_version: 5.28.0
8
  python_version: '3.13'
9
  app_file: app.py
10
  pinned: false
 
4
  colorFrom: yellow
5
  colorTo: green
6
  sdk: gradio
7
+ sdk_version: 6.24.0
8
  python_version: '3.13'
9
  app_file: app.py
10
  pinned: false
app.py CHANGED
@@ -22,7 +22,7 @@ from pathlib import Path
22
 
23
  import gradio as gr
24
  import torch
25
- from pyharp import ModelCard, build_endpoint
26
 
27
  from muscriptor import TranscriptionModel
28
  from muscriptor.tokenizer.mt3 import MT3_FULL_PLUS_GROUP_NAMES, resolve_instrument_names
@@ -34,7 +34,7 @@ model_card = ModelCard(
34
  "from classical music to heavy metal."
35
  ),
36
  author="Simon Rouard, Michael Krause, Axel Roebel, Carl-Johann Simon-Gabriel, Alexandre Défossez (Kyutai x Mirelo)",
37
- tags=["transcription", "midi", "multi-instrument"],
38
  )
39
 
40
  _VALID_INSTRUMENTS = ", ".join(MT3_FULL_PLUS_GROUP_NAMES)
@@ -116,48 +116,48 @@ def process_fn(
116
  return output_midi_path, output_notes_path
117
 
118
 
119
- with gr.Blocks() as demo:
120
- input_components = [
121
- gr.Audio(type="filepath", label="Input Audio").harp_required(True),
122
- gr.Dropdown(
123
- choices=["small", "medium", "large"],
124
- value="medium",
125
- label="Model Size",
126
- info="small = fastest, least accurate. medium = balanced (default, per repo). large = most accurate, slower.",
127
- ),
128
- gr.Textbox(
129
- value="",
130
- label="Instruments",
131
- info=f"Separate names with commas. Leave blank to let the model detect instruments on its own. Valid names: {_VALID_INSTRUMENTS}.",
132
- ),
133
- gr.Checkbox(
134
- label="Use Sampling",
135
- info="Temperature sampling instead of greedy decoding (default: False, per repo).",
136
- ),
137
- gr.Slider(
138
- minimum=0.1,
139
- maximum=2.0,
140
- step=0.1,
141
- value=1.0,
142
- label="Temperature",
143
- info="Only used when Use Sampling is on. Higher values = note choices are more varied and unpredictable. Lower values = values are closer to model's most confident guesses. (default: 1.0, per repo).",
144
- ),
145
- ]
146
- output_components = [
147
- gr.File(type="filepath", file_types=[".mid", ".midi"], label="Output MIDI").set_info(
148
- "Transcribed MIDI notes."
149
- ),
150
- gr.File(type="filepath", file_types=[".txt"], label="Instrument Matching").set_info(
151
- "Which requested instrument names were matched or ignored."
152
- ),
153
- ]
154
-
155
- build_endpoint(
156
- model_card=model_card,
157
- input_components=input_components,
158
- output_components=output_components,
159
- process_fn=process_fn,
160
- )
161
-
162
  if __name__ == "__main__":
163
- demo.queue().launch(pwa=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
  import gradio as gr
24
  import torch
25
+ from pyharp import ModelCard, build_endpoint, Subcategory
26
 
27
  from muscriptor import TranscriptionModel
28
  from muscriptor.tokenizer.mt3 import MT3_FULL_PLUS_GROUP_NAMES, resolve_instrument_names
 
34
  "from classical music to heavy metal."
35
  ),
36
  author="Simon Rouard, Michael Krause, Axel Roebel, Carl-Johann Simon-Gabriel, Alexandre Défossez (Kyutai x Mirelo)",
37
+ tags=[Subcategory.MUSIC_ANALYSIS, 'transcription', 'midi', 'multi-instrument'],
38
  )
39
 
40
  _VALID_INSTRUMENTS = ", ".join(MT3_FULL_PLUS_GROUP_NAMES)
 
116
  return output_midi_path, output_notes_path
117
 
118
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  if __name__ == "__main__":
120
+ with gr.Blocks() as demo:
121
+ input_components = [
122
+ gr.Audio(type="filepath", label="Input Audio").harp_required(True),
123
+ gr.Dropdown(
124
+ choices=["small", "medium", "large"],
125
+ value="medium",
126
+ label="Model Size",
127
+ info="small = fastest, least accurate. medium = balanced (default, per repo). large = most accurate, slower.",
128
+ ),
129
+ gr.Textbox(
130
+ value="",
131
+ label="Instruments",
132
+ info=f"Separate names with commas. Leave blank to let the model detect instruments on its own. Valid names: {_VALID_INSTRUMENTS}.",
133
+ ),
134
+ gr.Checkbox(
135
+ label="Use Sampling",
136
+ info="Temperature sampling instead of greedy decoding (default: False, per repo).",
137
+ ),
138
+ gr.Slider(
139
+ minimum=0.1,
140
+ maximum=2.0,
141
+ step=0.1,
142
+ value=1.0,
143
+ label="Temperature",
144
+ info="Only used when Use Sampling is on. Higher values = note choices are more varied and unpredictable. Lower values = values are closer to model's most confident guesses. (default: 1.0, per repo).",
145
+ ),
146
+ ]
147
+ output_components = [
148
+ gr.File(type="filepath", file_types=[".mid", ".midi"], label="Output MIDI").set_info(
149
+ "Transcribed MIDI notes."
150
+ ),
151
+ gr.File(type="filepath", file_types=[".txt"], label="Instrument Matching").set_info(
152
+ "Which requested instrument names were matched or ignored."
153
+ ),
154
+ ]
155
+
156
+ build_endpoint(
157
+ model_card=model_card,
158
+ input_components=input_components,
159
+ output_components=output_components,
160
+ process_fn=process_fn,
161
+ )
162
+
163
+ demo.queue().launch(show_error=True, share=True, pwa=True)
requirements.txt CHANGED
@@ -1,2 +1,3 @@
1
  git+https://github.com/TEAMuP-dev/pyharp.git@v0.4.0
2
  muscriptor
 
 
1
  git+https://github.com/TEAMuP-dev/pyharp.git@v0.4.0
2
  muscriptor
3
+ spaces>=0.51.1