harp-dev commited on
Commit
38d0bd2
·
verified ·
1 Parent(s): 09377fe

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 +36 -35
  3. requirements.txt +3 -2
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 🎼
4
  colorFrom: purple
5
  colorTo: pink
6
  sdk: gradio
7
- sdk_version: 5.28.0
8
  app_file: app.py
9
  pinned: false
10
  license: apache-2.0
 
4
  colorFrom: purple
5
  colorTo: pink
6
  sdk: gradio
7
+ sdk_version: 6.24.0
8
  app_file: app.py
9
  pinned: false
10
  license: apache-2.0
app.py CHANGED
@@ -103,41 +103,42 @@ model_card = ModelCard(
103
  "Use the sliders to control the amount of creativity and length."
104
  ),
105
  author="Keshav Bhandari, Abhinaba Roy, Kyra Wang, Geeta Puri, Simon Colton, Dorien Herremans",
106
- tags=["text-to-music", "midi", "generation"]
107
  )
108
 
109
  # Gradio + HARP UI
110
- with gr.Blocks() as demo:
111
- gr.Markdown("## 🎶 text2midi")
112
-
113
- # Inputs
114
- prompt_in = gr.Textbox(
115
- label="Describe Your Music",
116
- info="Type a short phrase like 'calm piano with flowing arpeggios' ",
117
- ).harp_required(True)
118
- temperature_in = gr.Slider(minimum=0.8, maximum=1.1, value=0.9, step=0.1, label="Creativity", info=(
119
- "Adjusts how much freedom the model takes while composing.\n"
120
- "Lower = safer and more predictable (structured), "
121
- "Higher = more varied and expressive."
122
- ), interactive=True)
123
-
124
- maxlen_in = gr.Slider(minimum=500, maximum=1500, step=100, value=500, label="Composition Length", info=(
125
- "Determines how long the generated piece is in musical tokens.\n"
126
- "Higher values produce longer phrases (roughly more measures of music).")
127
- )
128
-
129
- # Outputs (JSON FIRST for HARP, then MIDI)
130
- labels_out = gr.JSON(label="Labels / Metadata")
131
- midi_out = gr.File(label="Generated MIDI", file_types=[".mid", ".midi"], type="filepath")
132
-
133
- # Build HARP endpoint
134
- _ = build_endpoint(
135
- model_card=model_card,
136
- input_components=[prompt_in, temperature_in, maxlen_in],
137
- output_components=[labels_out, midi_out], # JSON first
138
- process_fn=process_fn
139
- )
140
-
141
-
142
- # Launch App
143
- demo.launch(share=True, show_error=True, debug=True)
 
 
103
  "Use the sliders to control the amount of creativity and length."
104
  ),
105
  author="Keshav Bhandari, Abhinaba Roy, Kyra Wang, Geeta Puri, Simon Colton, Dorien Herremans",
106
+ tags=[Subcategory.HOLISTIC, 'text-to-music', 'midi', 'generation']
107
  )
108
 
109
  # Gradio + HARP UI
110
+ if __name__ == "__main__":
111
+ with gr.Blocks() as demo:
112
+ gr.Markdown("## 🎶 text2midi")
113
+
114
+ # Inputs
115
+ prompt_in = gr.Textbox(
116
+ label="Describe Your Music",
117
+ info="Type a short phrase like 'calm piano with flowing arpeggios' ",
118
+ ).harp_required(True)
119
+ temperature_in = gr.Slider(minimum=0.8, maximum=1.1, value=0.9, step=0.1, label="Creativity", info=(
120
+ "Adjusts how much freedom the model takes while composing.\n"
121
+ "Lower = safer and more predictable (structured), "
122
+ "Higher = more varied and expressive."
123
+ ), interactive=True)
124
+
125
+ maxlen_in = gr.Slider(minimum=500, maximum=1500, step=100, value=500, label="Composition Length", info=(
126
+ "Determines how long the generated piece is in musical tokens.\n"
127
+ "Higher values produce longer phrases (roughly more measures of music).")
128
+ )
129
+
130
+ # Outputs (JSON FIRST for HARP, then MIDI)
131
+ labels_out = gr.JSON(label="Labels / Metadata")
132
+ midi_out = gr.File(label="Generated MIDI", file_types=[".mid", ".midi"], type="filepath")
133
+
134
+ # Build HARP endpoint
135
+ _ = build_endpoint(
136
+ model_card=model_card,
137
+ input_components=[prompt_in, temperature_in, maxlen_in],
138
+ output_components=[labels_out, midi_out], # JSON first
139
+ process_fn=process_fn
140
+ )
141
+
142
+
143
+ # Launch App
144
+ demo.launch(pwa=True, share=True, show_error=True, debug=True)
requirements.txt CHANGED
@@ -1,5 +1,5 @@
1
  # PyHARP from correct branch
2
- git+https://github.com/lindseydeng/pyharp.git@main
3
  librosa==0.10.2
4
  wavio==0.0.9
5
  torch==2.2.2
@@ -9,4 +9,5 @@ st-moe-pytorch
9
  jsonlines
10
  miditok==3.0.3
11
  sentencepiece
12
- huggingface_hub
 
 
1
  # PyHARP from correct branch
2
+ git+https://github.com/TEAMuP-dev/pyharp.git@v0.4.0
3
  librosa==0.10.2
4
  wavio==0.0.9
5
  torch==2.2.2
 
9
  jsonlines
10
  miditok==3.0.3
11
  sentencepiece
12
+ huggingface_hub
13
+ spaces>=0.51.1