| 86 | } |
| 87 | |
| 88 | void apply_repaint_mode_strength(AceStepGenerationOptions & options, const runtime::TaskRequest & request) { |
| 89 | const auto mode_value = runtime::find_option(request.options, {"repaint_mode"}); |
| 90 | const auto strength_value = runtime::find_option(request.options, {"repaint_strength"}); |
| 91 | if (!mode_value.has_value() && !strength_value.has_value()) { |
| 92 | return; |
| 93 | } |
| 94 | |
| 95 | const std::string mode = mode_value.value_or("balanced"); |
| 96 | const float strength = clamp_repaint_strength( |
| 97 | strength_value.has_value() ? runtime::parse_float_option(request.options, {"repaint_strength"}).value() : 0.5F); |
| 98 | if (mode == "aggressive") { |
| 99 | options.repaint_injection_ratio = 0.0F; |
| 100 | options.repaint_crossfade_frames = 0; |
| 101 | return; |
| 102 | } |
| 103 | if (mode == "conservative") { |
| 104 | options.repaint_injection_ratio = 1.0F; |
| 105 | options.repaint_crossfade_frames = 25; |
| 106 | return; |
| 107 | } |
| 108 | if (mode != "balanced") { |
| 109 | throw std::runtime_error("ACE-Step repaint_mode must be balanced, conservative, or aggressive"); |
| 110 | } |
| 111 | const float inv_strength = 1.0F - strength; |
| 112 | options.repaint_injection_ratio = inv_strength; |
| 113 | options.repaint_crossfade_frames = python_round_to_int(25.0F * inv_strength); |
| 114 | } |
| 115 | |
| 116 | } // namespace |
| 117 |
no test coverage detected