[WIP] Adding adapter for event detection on Chronos v1#35
Open
AnneMaelle wants to merge 36 commits into
Open
Conversation
- Add EventHead (Transformer-decoder, 10 learned queries) and ChronosEventAdapter in benchmark_utils/adapters/event_detection.py - Add Chronos-EventDetection solver in solvers/chronos_event.py: frozen Chronos encoder + trainable head, with model_path param for offline/local model loading - Add event_detection task branch to objective.py - Add event_span_iou and event_class_f1 metrics to metrics.py - Fix chronos.py: defer ChronosPipeline import to set_objective to avoid import-time crash when chronos-forecasting is not installed Co-authored-by: Cursor <cursoragent@cursor.com>
ENH add Chronos event-detection solver with EventHead adapter
Add matching_strategy ("greedy"/"hungarian") and mode ("micro"/"macro")
parameters. Greedy now sorts predictions by descending confidence before
claiming the highest-IoU free ground-truth span. Penalise unmatched and
duplicate predictions as false positives over their active class columns.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add matching_strategy ("greedy"/"hungarian") and mode ("micro"/"macro")
parameters. Greedy now sorts predictions by descending confidence before
claiming the highest-IoU free ground-truth span. Penalise unmatched and
duplicate predictions as false positives over their active class columns.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Move _get_linear_cosine_scheduler, precompute_embeddings, fit_event_head from solvers/chronos_event.py to benchmark_utils/adapters/event_detection.py - Add event_detection branch to solvers/chronos.py (import, SUPPORTED_TASKS, _CHRONOS_D, parameters, set_objective block, run() elif) - Delete solvers/chronos_event.py Co-authored-by: Cursor <cursoragent@cursor.com>
- Add num_queries parameter to Solver.parameters, __init__, and fit_event_head call in chronos.py - Add _pad_or_truncate_labels helper in event_detection.py that truncates or zero-pads label arrays to exactly num_queries rows - Apply padding/truncation upfront in fit_event_head so variable-length label lists can be batched safely Co-authored-by: Cursor <cursoragent@cursor.com>
model code refactoring and add truncate padding on the model side
EventHead.compute_loss: - Replace naive slot-aligned loss with DETR-style Hungarian matching - Build (N, M) cost matrix per sample: L1 position cost + class cost - Solve optimal assignment via scipy.optimize.linear_sum_assignment - Matched slots: smooth_l1 position loss + GT class target - Unmatched slots: BCE toward no-event (all-zero) class target MITDB dataset: - Add window_size=512 and window_overlap=0.5 parameters - Add _extract_window_events helper: includes only beat events whose full span (start, length) = (R-peak - beat_window, 2*beat_window) lies entirely within the window; boundary-straddling events are discarded - get_data now emits one (512, 2) window per stride step instead of one element per full record segment - Positions normalised to [0, 1] over window_size Co-authored-by: Cursor <cursoragent@cursor.com>
Chronos2Pipeline.from_pretrained raises AttributeError when the model config references T5ForConditionalGeneration (Chronos-1 architecture). load_model now catches AttributeError/ValueError and retries with the legacy ChronosPipeline, so local chronos_t5_* checkpoints work without any solver parameter changes. Co-authored-by: Cursor <cursoragent@cursor.com>
hungarian matching, data windowing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add event detection task with MITDB dataset and Chronos adapter
Introduces event_detection as a new benchmark task:
5-class AAMI beat grouping, events encoded as normalized (start, length, one-hot-class) slots
classification), trained on frozen Chronos encoder embeddings
ChronosPipeline for local T5 checkpoints, and configurable training hyperparameters
matching strategy)