harp-dev Claude Opus 5.5 commited on
Commit
87ad34e
·
verified ·
1 Parent(s): c4d2b3e

Download and build the pipeline in the worker, and declare the format

Browse files

Downloads the snapshot and constructs the pipeline in the worker, and declares 48 kHz stereo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Files changed (2) hide show
  1. README.md +2 -0
  2. app.py +26 -26
README.md CHANGED
@@ -19,6 +19,8 @@ tags:
19
  - input:text
20
  - input:audio
21
  - output:audio
 
 
22
  ---
23
 
24
  Text-to-music generation with lyrics and style control, using
 
19
  - input:text
20
  - input:audio
21
  - output:audio
22
+ - sample-rate:48000
23
+ - channels:stereo
24
  ---
25
 
26
  Text-to-music generation with lyrics and style control, using
app.py CHANGED
@@ -16,30 +16,6 @@ from huggingface_hub import snapshot_download
16
  from pyharp import *
17
  from pipeline_ace_step import ACEStepPipeline
18
 
19
- # Fetched when the Space builds (preload_from_hub in README.md), so this resolves the local copy.
20
- # Its layout is the one the pipeline expects of a checkpoint directory.
21
- CHECKPOINT_DIR = snapshot_download("ACE-Step/ACE-Step-v1-3.5B",
22
- revision="82cd0d7b6322bd28cd4e830fe675ddb6180ce36c")
23
-
24
- # The LoRA the interface offers, fetched pinned in the worker, which runs process_fn, rather than
25
- # inside the GPU call the first time a request picks it. The pipeline is handed its local path,
26
- # which it loads as it is.
27
- LORAS = {}
28
- if __name__ != "__main__":
29
- LORAS["ACE-Step/ACE-Step-v1-chinese-rap-LoRA"] = snapshot_download(
30
- "ACE-Step/ACE-Step-v1-chinese-rap-LoRA", revision="e40a223cb69a60ba8a8c46752987c152b8a5f828"
31
- )
32
-
33
- # Construction only records where the weights are. They load on the first call, inside the GPU
34
- # reservation, which is how the authors' Space runs it as well.
35
- pipeline = ACEStepPipeline(
36
- checkpoint_dir=CHECKPOINT_DIR,
37
- dtype="bfloat16",
38
- persistent_storage_path=tempfile.gettempdir(),
39
- torch_compile=False,
40
- )
41
-
42
-
43
  model_card = ModelCard(
44
  name="ACE-Step",
45
  description=(
@@ -49,13 +25,37 @@ model_card = ModelCard(
49
  "genre, instrumentation and mood, and the lyrics are sung. Turning on Audio2Audio "
50
  "conditions the result on a reference recording so it takes on that recording's "
51
  "character. Audio Duration sets the length, up to four minutes, or -1 to let the model "
52
- "choose. Repository: https://github.com/ace-step/ACE-Step "
53
  "Paper: https://arxiv.org/abs/2506.00045"
54
  ),
55
  author="Junmin Gong, Wenxiao Zhao, Sen Wang, Shengyuan Xu, Jing Guo",
56
- tags=[Subcategory.HOLISTIC],
57
  )
58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
 
60
  # PyHARP stops a job that runs past its timeout_s, 15 minutes by default, so a request whose
61
  # reservation would exceed that is refused rather than started. A shorter one is left to
 
16
  from pyharp import *
17
  from pipeline_ace_step import ACEStepPipeline
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  model_card = ModelCard(
20
  name="ACE-Step",
21
  description=(
 
25
  "genre, instrumentation and mood, and the lyrics are sung. Turning on Audio2Audio "
26
  "conditions the result on a reference recording so it takes on that recording's "
27
  "character. Audio Duration sets the length, up to four minutes, or -1 to let the model "
28
+ "choose. It writes 48 kHz stereo audio. Repository: https://github.com/ace-step/ACE-Step "
29
  "Paper: https://arxiv.org/abs/2506.00045"
30
  ),
31
  author="Junmin Gong, Wenxiao Zhao, Sen Wang, Shengyuan Xu, Jing Guo",
32
+ tags=[Subcategory.HOLISTIC, SampleRate(48000), Channels(2)],
33
  )
34
 
35
+ # pyharp runs process_fn in a worker, which imports this file as __mp_main__ and starts with the
36
+ # server, so the checkpoint and the LoRA the interface offers are resolved there alone, pinned,
37
+ # rather than inside the GPU call the first time a request needs them. The checkpoint was fetched
38
+ # when the Space built (preload_from_hub in README.md), so this resolves the local copy, whose
39
+ # layout is the one the pipeline expects of a checkpoint directory. The pipeline is handed the
40
+ # local path of the LoRA, which it loads as it is.
41
+ LORAS = {}
42
+ if __name__ != "__main__":
43
+ CHECKPOINT_DIR = snapshot_download("ACE-Step/ACE-Step-v1-3.5B",
44
+ revision="82cd0d7b6322bd28cd4e830fe675ddb6180ce36c")
45
+ LORAS["ACE-Step/ACE-Step-v1-chinese-rap-LoRA"] = snapshot_download(
46
+ "ACE-Step/ACE-Step-v1-chinese-rap-LoRA", revision="e40a223cb69a60ba8a8c46752987c152b8a5f828"
47
+ )
48
+
49
+ # Construction only records where the weights are. They load on the first call, inside the
50
+ # GPU reservation, which is how the authors' Space runs it as well: holding the whole model
51
+ # in the worker would keep about 7 GB there.
52
+ pipeline = ACEStepPipeline(
53
+ checkpoint_dir=CHECKPOINT_DIR,
54
+ dtype="bfloat16",
55
+ persistent_storage_path=tempfile.gettempdir(),
56
+ torch_compile=False,
57
+ )
58
+
59
 
60
  # PyHARP stops a job that runs past its timeout_s, 15 minutes by default, so a request whose
61
  # reservation would exceed that is refused rather than started. A shorter one is left to