harp-dev commited on
Commit
d7f890d
·
verified ·
1 Parent(s): dd557c3

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 +33 -32
  3. requirements.txt +2 -1
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 📻
4
  colorFrom: blue
5
  colorTo: green
6
  sdk: gradio
7
- sdk_version: 5.28.0
8
  python_version: '3.11'
9
  app_file: app.py
10
  pinned: false
 
4
  colorFrom: blue
5
  colorTo: green
6
  sdk: gradio
7
+ sdk_version: 6.24.0
8
  python_version: '3.11'
9
  app_file: app.py
10
  pinned: false
app.py CHANGED
@@ -24,7 +24,7 @@ import torch
24
  import torchaudio
25
  from huggingface_hub import hf_hub_download
26
  from omegaconf import OmegaConf
27
- from pyharp import ModelCard, build_endpoint
28
 
29
  from model.config import CHECKPOINTS, CHECKPOINTS_REPO
30
  from model.cqtdiff import Unet_CQT_oct_with_attention
@@ -66,7 +66,7 @@ model_card = ModelCard(
66
  name="BABE-2",
67
  description="Restores degraded historical piano or singing-voice recordings with a diffusion-based generative equalizer.",
68
  author="Eloi Moliner, Maija Turunen, Filip Elvander, Vesa Välimäki",
69
- tags=["restoration", "equalizer", "diffusion", "historical recordings"],
70
  )
71
 
72
 
@@ -104,33 +104,34 @@ def update_strength_default(checkpoint_label):
104
  return gr.update(value=float(base_cfg.tester.posterior_sampling.xi))
105
 
106
 
107
- with gr.Blocks() as demo:
108
- checkpoint_dropdown = gr.Dropdown(
109
- choices=list(CHECKPOINTS.keys()),
110
- value="Piano (MAESTRO)",
111
- label="Voice / Instrument",
112
- info="Singer-specific models give the most faithful restoration when your recording actually resembles that singer.",
113
- )
114
-
115
- input_components = [
116
- gr.Audio(type="filepath", label="Input Audio").harp_required(True),
117
- checkpoint_dropdown,
118
- gr.Slider(minimum=10, maximum=100, step=1, value=51, label="Processing Steps",
119
- info="More steps can improve quality at the cost of processing time."),
120
- gr.Slider(minimum=0.0, maximum=2.0, step=0.05, value=1.0, label="Restoration Strength",
121
- info="How strongly the output is guided to match the input recording."),
122
- ]
123
- output_components = [
124
- gr.Audio(type="filepath", label="Restored Audio").set_info("The restored recording."),
125
- ]
126
-
127
- checkpoint_dropdown.change(fn=update_strength_default, inputs=checkpoint_dropdown, outputs=input_components[3])
128
-
129
- build_endpoint(
130
- model_card=model_card,
131
- input_components=input_components,
132
- output_components=output_components,
133
- process_fn=process_fn,
134
- )
135
-
136
- demo.queue().launch(pwa=True)
 
 
24
  import torchaudio
25
  from huggingface_hub import hf_hub_download
26
  from omegaconf import OmegaConf
27
+ from pyharp import ModelCard, build_endpoint, Subcategory
28
 
29
  from model.config import CHECKPOINTS, CHECKPOINTS_REPO
30
  from model.cqtdiff import Unet_CQT_oct_with_attention
 
66
  name="BABE-2",
67
  description="Restores degraded historical piano or singing-voice recordings with a diffusion-based generative equalizer.",
68
  author="Eloi Moliner, Maija Turunen, Filip Elvander, Vesa Välimäki",
69
+ tags=[Subcategory.RESTORATION, 'restoration', 'equalizer', 'diffusion', 'historical recordings'],
70
  )
71
 
72
 
 
104
  return gr.update(value=float(base_cfg.tester.posterior_sampling.xi))
105
 
106
 
107
+ if __name__ == "__main__":
108
+ with gr.Blocks() as demo:
109
+ checkpoint_dropdown = gr.Dropdown(
110
+ choices=list(CHECKPOINTS.keys()),
111
+ value="Piano (MAESTRO)",
112
+ label="Voice / Instrument",
113
+ info="Singer-specific models give the most faithful restoration when your recording actually resembles that singer.",
114
+ )
115
+
116
+ input_components = [
117
+ gr.Audio(type="filepath", label="Input Audio").harp_required(True),
118
+ checkpoint_dropdown,
119
+ gr.Slider(minimum=10, maximum=100, step=1, value=51, label="Processing Steps",
120
+ info="More steps can improve quality at the cost of processing time."),
121
+ gr.Slider(minimum=0.0, maximum=2.0, step=0.05, value=1.0, label="Restoration Strength",
122
+ info="How strongly the output is guided to match the input recording."),
123
+ ]
124
+ output_components = [
125
+ gr.Audio(type="filepath", label="Restored Audio").set_info("The restored recording."),
126
+ ]
127
+
128
+ checkpoint_dropdown.change(fn=update_strength_default, inputs=checkpoint_dropdown, outputs=input_components[3])
129
+
130
+ build_endpoint(
131
+ model_card=model_card,
132
+ input_components=input_components,
133
+ output_components=output_components,
134
+ process_fn=process_fn,
135
+ )
136
+
137
+ demo.queue().launch(show_error=True, share=True, pwa=True)
requirements.txt CHANGED
@@ -1,4 +1,4 @@
1
- git+https://github.com/TEAMuP-dev/pyharp.git@v0.3.0
2
  torch
3
  torchaudio
4
  numpy
@@ -7,3 +7,4 @@ soundfile
7
  tqdm
8
  omegaconf
9
  huggingface_hub
 
 
1
+ git+https://github.com/TEAMuP-dev/pyharp.git@v0.4.0
2
  torch
3
  torchaudio
4
  numpy
 
7
  tqdm
8
  omegaconf
9
  huggingface_hub
10
+ spaces>=0.51.1