Spaces:
Running on Zero
Running on Zero
Bring the Space up to the pyharp example standard (taxonomy tags, __main__ guard, show_error, v0.4.0)
Browse files- README.md +1 -1
- app.py +36 -35
- requirements.txt +3 -2
README.md
CHANGED
|
@@ -4,7 +4,7 @@ emoji: 🎼
|
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: pink
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 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=[
|
| 107 |
)
|
| 108 |
|
| 109 |
# Gradio + HARP UI
|
| 110 |
-
|
| 111 |
-
gr.
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
|
|
|
|
|
| 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/
|
| 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
|