Spaces:
Sleeping
Sleeping
Fixed-BPM grid + piecewise fit + dual-mode support
Browse files- softchart/train.py +11 -4
softchart/train.py
CHANGED
|
@@ -144,6 +144,8 @@ def main():
|
|
| 144 |
help="beat/downbeat auxiliary head (labels from TJA measures)")
|
| 145 |
ap.add_argument("--beat-weight", type=float, default=0.1,
|
| 146 |
help="beat-head loss weight (raise for a dedicated beat model)")
|
|
|
|
|
|
|
| 147 |
ap.add_argument("--sync-token", action="store_true",
|
| 148 |
help="LHL syncopation-band condition token")
|
| 149 |
ap.add_argument("--plan", action="store_true",
|
|
@@ -156,6 +158,10 @@ def main():
|
|
| 156 |
help="slot-token mode: notes as exact TJA lattice indices "
|
| 157 |
"(measure*96+slot), measure-aligned windows, grid-phase "
|
| 158 |
"input channels — zero quantization error by construction")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
ap.add_argument("--dpo", default=None,
|
| 160 |
help="reference checkpoint: switch to DPO finetuning with synthetic negatives")
|
| 161 |
ap.add_argument("--dpo-beta", type=float, default=0.1)
|
|
@@ -181,14 +187,15 @@ def main():
|
|
| 181 |
tempo_aug=args.tempo_aug, sibling=args.sibling, style=args.style,
|
| 182 |
beat_head=args.beat_head, sync_token=args.sync_token,
|
| 183 |
plan=args.plan, mask_infill=args.mask_infill, complexity=args.complexity,
|
| 184 |
-
slot=args.slot,
|
| 185 |
)
|
| 186 |
val_ds = ChartWindowDataset(args.cache, val_ids, train=False, windows_per_chart=1,
|
| 187 |
use_ctx=args.ctx, aux=args.aux, global_ctx=args.global_ctx,
|
| 188 |
sibling=args.sibling, style=args.style,
|
| 189 |
beat_head=args.beat_head, sync_token=args.sync_token,
|
| 190 |
plan=args.plan, complexity=args.complexity,
|
| 191 |
-
slot=args.slot
|
|
|
|
| 192 |
print(f"train charts {len(train_ds.items)}, val charts {len(val_ds.items)}")
|
| 193 |
|
| 194 |
train_loader = DataLoader(
|
|
@@ -203,12 +210,12 @@ def main():
|
|
| 203 |
model = ChartModel(
|
| 204 |
d_model=args.d_model, enc_layers=args.enc_layers, dec_layers=args.dec_layers,
|
| 205 |
ffn=args.ffn, aux=args.aux, global_ctx=args.global_ctx,
|
| 206 |
-
func_time=args.func_time, in_ch=(_NM + 2) if args.slot else None,
|
| 207 |
).to(device)
|
| 208 |
if args.align:
|
| 209 |
model.enable_ptr()
|
| 210 |
if args.beat_head:
|
| 211 |
-
model.enable_beat()
|
| 212 |
model.to(device)
|
| 213 |
print(f"params: {count_params(model)/1e6:.1f}M, vocab {VOCAB.size}")
|
| 214 |
if args.init_from and os.path.exists(args.init_from):
|
|
|
|
| 144 |
help="beat/downbeat auxiliary head (labels from TJA measures)")
|
| 145 |
ap.add_argument("--beat-weight", type=float, default=0.1,
|
| 146 |
help="beat-head loss weight (raise for a dedicated beat model)")
|
| 147 |
+
ap.add_argument("--beat-hires", action="store_true",
|
| 148 |
+
help="frame-resolution beat head (11.6 ms bins instead of 46 ms)")
|
| 149 |
ap.add_argument("--sync-token", action="store_true",
|
| 150 |
help="LHL syncopation-band condition token")
|
| 151 |
ap.add_argument("--plan", action="store_true",
|
|
|
|
| 158 |
help="slot-token mode: notes as exact TJA lattice indices "
|
| 159 |
"(measure*96+slot), measure-aligned windows, grid-phase "
|
| 160 |
"input channels — zero quantization error by construction")
|
| 161 |
+
ap.add_argument("--dual", action="store_true",
|
| 162 |
+
help="dual-mode: mixed slot/time windows with an explicit "
|
| 163 |
+
"MODE token; one model serves both the grid-exact path "
|
| 164 |
+
"and the gridless fallback")
|
| 165 |
ap.add_argument("--dpo", default=None,
|
| 166 |
help="reference checkpoint: switch to DPO finetuning with synthetic negatives")
|
| 167 |
ap.add_argument("--dpo-beta", type=float, default=0.1)
|
|
|
|
| 187 |
tempo_aug=args.tempo_aug, sibling=args.sibling, style=args.style,
|
| 188 |
beat_head=args.beat_head, sync_token=args.sync_token,
|
| 189 |
plan=args.plan, mask_infill=args.mask_infill, complexity=args.complexity,
|
| 190 |
+
slot=args.slot, dual=args.dual, beat_hires=args.beat_hires,
|
| 191 |
)
|
| 192 |
val_ds = ChartWindowDataset(args.cache, val_ids, train=False, windows_per_chart=1,
|
| 193 |
use_ctx=args.ctx, aux=args.aux, global_ctx=args.global_ctx,
|
| 194 |
sibling=args.sibling, style=args.style,
|
| 195 |
beat_head=args.beat_head, sync_token=args.sync_token,
|
| 196 |
plan=args.plan, complexity=args.complexity,
|
| 197 |
+
slot=args.slot, dual=args.dual,
|
| 198 |
+
beat_hires=args.beat_hires)
|
| 199 |
print(f"train charts {len(train_ds.items)}, val charts {len(val_ds.items)}")
|
| 200 |
|
| 201 |
train_loader = DataLoader(
|
|
|
|
| 210 |
model = ChartModel(
|
| 211 |
d_model=args.d_model, enc_layers=args.enc_layers, dec_layers=args.dec_layers,
|
| 212 |
ffn=args.ffn, aux=args.aux, global_ctx=args.global_ctx,
|
| 213 |
+
func_time=args.func_time, in_ch=(_NM + 2) if (args.slot or args.dual) else None,
|
| 214 |
).to(device)
|
| 215 |
if args.align:
|
| 216 |
model.enable_ptr()
|
| 217 |
if args.beat_head:
|
| 218 |
+
model.enable_beat(hires=args.beat_hires)
|
| 219 |
model.to(device)
|
| 220 |
print(f"params: {count_params(model)/1e6:.1f}M, vocab {VOCAB.size}")
|
| 221 |
if args.init_from and os.path.exists(args.init_from):
|