Spaces:
Running
on
A100
Running
on
A100
feat: shift
Browse files- acestep/api_server.py +17 -9
acestep/api_server.py
CHANGED
|
@@ -102,9 +102,13 @@ class GenerateMusicRequest(BaseModel):
|
|
| 102 |
cfg_interval_start: float = 0.0
|
| 103 |
cfg_interval_end: float = 1.0
|
| 104 |
infer_method: str = "ode" # "ode" or "sde" - diffusion inference method
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
timesteps: Optional[str] = Field(
|
| 106 |
default=None,
|
| 107 |
-
description="Custom timesteps (comma-separated, e.g., '0.97,0.76,0.615,0.5,0.395,0.28,0.18,0.085,0')"
|
| 108 |
)
|
| 109 |
|
| 110 |
audio_format: str = "mp3"
|
|
@@ -740,6 +744,15 @@ def create_app() -> FastAPI:
|
|
| 740 |
print(f"[api_server] Warning: format_sample failed: {format_result.error}, using original input")
|
| 741 |
|
| 742 |
print(f"[api_server] Before GenerationParams: thinking={thinking}, sample_mode={sample_mode}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 743 |
print(f"[api_server] Caption/Lyrics to use: caption_len={len(caption)}, lyrics_len={len(lyrics)}")
|
| 744 |
|
| 745 |
# Build GenerationParams using unified interface
|
|
@@ -758,12 +771,13 @@ def create_app() -> FastAPI:
|
|
| 758 |
keyscale=key_scale,
|
| 759 |
timesignature=time_signature,
|
| 760 |
duration=audio_duration if audio_duration else -1.0,
|
| 761 |
-
inference_steps=
|
| 762 |
seed=req.seed,
|
| 763 |
guidance_scale=req.guidance_scale,
|
| 764 |
use_adg=req.use_adg,
|
| 765 |
cfg_interval_start=req.cfg_interval_start,
|
| 766 |
cfg_interval_end=req.cfg_interval_end,
|
|
|
|
| 767 |
infer_method=req.infer_method,
|
| 768 |
timesteps=parsed_timesteps,
|
| 769 |
repainting_start=req.repainting_start,
|
|
@@ -1041,6 +1055,7 @@ def create_app() -> FastAPI:
|
|
| 1041 |
cfg_interval_start=_to_float(get("cfg_interval_start"), 0.0) or 0.0,
|
| 1042 |
cfg_interval_end=_to_float(get("cfg_interval_end"), 1.0) or 1.0,
|
| 1043 |
infer_method=str(_get_any("infer_method", "inferMethod", default="ode") or "ode"),
|
|
|
|
| 1044 |
audio_format=str(get("audio_format", "mp3") or "mp3"),
|
| 1045 |
use_tiled_decode=_to_bool(_get_any("use_tiled_decode", "useTiledDecode"), True),
|
| 1046 |
lm_model_path=str(get("lm_model_path") or "").strip() or None,
|
|
@@ -1293,12 +1308,5 @@ def main() -> None:
|
|
| 1293 |
workers=1,
|
| 1294 |
)
|
| 1295 |
|
| 1296 |
-
|
| 1297 |
-
if __name__ == "__main__":
|
| 1298 |
-
main()
|
| 1299 |
-
,
|
| 1300 |
-
)
|
| 1301 |
-
|
| 1302 |
-
|
| 1303 |
if __name__ == "__main__":
|
| 1304 |
main()
|
|
|
|
| 102 |
cfg_interval_start: float = 0.0
|
| 103 |
cfg_interval_end: float = 1.0
|
| 104 |
infer_method: str = "ode" # "ode" or "sde" - diffusion inference method
|
| 105 |
+
shift: float = Field(
|
| 106 |
+
default=3.0,
|
| 107 |
+
description="Timestep shift factor (range 1.0~5.0, default 3.0). Only effective for base models, not turbo models."
|
| 108 |
+
)
|
| 109 |
timesteps: Optional[str] = Field(
|
| 110 |
default=None,
|
| 111 |
+
description="Custom timesteps (comma-separated, e.g., '0.97,0.76,0.615,0.5,0.395,0.28,0.18,0.085,0'). Overrides inference_steps and shift."
|
| 112 |
)
|
| 113 |
|
| 114 |
audio_format: str = "mp3"
|
|
|
|
| 744 |
print(f"[api_server] Warning: format_sample failed: {format_result.error}, using original input")
|
| 745 |
|
| 746 |
print(f"[api_server] Before GenerationParams: thinking={thinking}, sample_mode={sample_mode}")
|
| 747 |
+
# Parse timesteps string to list of floats if provided
|
| 748 |
+
parsed_timesteps = None
|
| 749 |
+
if req.timesteps and req.timesteps.strip():
|
| 750 |
+
try:
|
| 751 |
+
parsed_timesteps = [float(t.strip()) for t in req.timesteps.split(",") if t.strip()]
|
| 752 |
+
except ValueError:
|
| 753 |
+
print(f"[api_server] Warning: Failed to parse timesteps '{req.timesteps}', using default")
|
| 754 |
+
parsed_timesteps = None
|
| 755 |
+
|
| 756 |
print(f"[api_server] Caption/Lyrics to use: caption_len={len(caption)}, lyrics_len={len(lyrics)}")
|
| 757 |
|
| 758 |
# Build GenerationParams using unified interface
|
|
|
|
| 771 |
keyscale=key_scale,
|
| 772 |
timesignature=time_signature,
|
| 773 |
duration=audio_duration if audio_duration else -1.0,
|
| 774 |
+
inference_steps=req.inference_steps,
|
| 775 |
seed=req.seed,
|
| 776 |
guidance_scale=req.guidance_scale,
|
| 777 |
use_adg=req.use_adg,
|
| 778 |
cfg_interval_start=req.cfg_interval_start,
|
| 779 |
cfg_interval_end=req.cfg_interval_end,
|
| 780 |
+
shift=req.shift,
|
| 781 |
infer_method=req.infer_method,
|
| 782 |
timesteps=parsed_timesteps,
|
| 783 |
repainting_start=req.repainting_start,
|
|
|
|
| 1055 |
cfg_interval_start=_to_float(get("cfg_interval_start"), 0.0) or 0.0,
|
| 1056 |
cfg_interval_end=_to_float(get("cfg_interval_end"), 1.0) or 1.0,
|
| 1057 |
infer_method=str(_get_any("infer_method", "inferMethod", default="ode") or "ode"),
|
| 1058 |
+
shift=_to_float(_get_any("shift"), 3.0) or 3.0,
|
| 1059 |
audio_format=str(get("audio_format", "mp3") or "mp3"),
|
| 1060 |
use_tiled_decode=_to_bool(_get_any("use_tiled_decode", "useTiledDecode"), True),
|
| 1061 |
lm_model_path=str(get("lm_model_path") or "").strip() or None,
|
|
|
|
| 1308 |
workers=1,
|
| 1309 |
)
|
| 1310 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1311 |
if __name__ == "__main__":
|
| 1312 |
main()
|