# fall-state-legality **Repository Path**: xm2284/fall-state-legality ## Basic Information - **Project Name**: fall-state-legality - **Description**: Code and derived statistics for: Certified State Legality for Fallen-State Monitoring - A Headroom Test for Transition Constraints - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-11-04 - **Last Updated**: 2026-11-04 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Certified State Legality for Fallen-State Monitoring Code and derived statistics for the paper *"Certified State Legality for Fallen-State Monitoring: A Headroom Test for Transition Constraints"* (Pattern Recognition Letters, submitted). The paper asks a deliberately narrow question: **when a video detector is scored on short windows that carry a single state label, how much of the trajectory signal can a state transition constraint actually correct?** This repository contains the pieces needed to reproduce the two figures that answer it, and the single source of truth for the legality mask used throughout. ## What is here ``` code/transitions_empirical.py HAND_A (the hand-written legality mask) and the annotation-count folding / empirical prior estimators code/fsad_state_head.py the differentiable penalty (L_illegal + L_ent) and the state head; this is "the constraint" of the paper code/plot_style.py Okabe-Ito colour-blind-safe matplotlib style analysis/make_figure_legality.py Figure 2 of the paper analysis/make_figure_gain.py Figure 3 of the paper data/transition_counts_6x6_staged7.csv 6x6 adjacent-segment transition counts data/majority_vote_runs.json 14 evaluation checkpoints: arg-max mF1, majority-vote mF1, per-class F1 change figures/ output of the two scripts ``` ## Reproducing the figures ```bash pip install -r requirements.txt python analysis/make_figure_legality.py # -> figures/fig_legality_graph.{pdf,png} python analysis/make_figure_gain.py # -> figures/fig_vote_gain.{pdf,png} ``` Both scripts print every number they plot and assert the values quoted in the paper, so a mismatch fails loudly instead of producing a plausible-looking figure. `make_figure_legality.py` checks, among others: | quantity | value | where it appears in the paper | |---|---|---| | adjacent-segment transitions, staged-7 | 4,673 | §2.2, Table 4 | | entries into `fallen` | 1,024 | Fig. 2 | | of which from `falling` | 1,020 (99.6 %) | Fig. 2, Table 4 | | off-diagonal cells with no annotation count | 11 | Table 4 | | legal cells never observed | 4 | Fig. 2 | | cells the mask refuses yet annotations contain | 3 (65 transitions) | §2.1, §3.6, Fig. 2 | `make_figure_gain.py` reproduces the per-class gain of the window majority vote over the 14 evaluation checkpoints (`falling` +10.05 points, 14/14; `lying` exactly 0.00, 0/14). ## The legality mask `HAND_A` in `code/transitions_empirical.py` is the only definition of legality in the paper: `fallen` is reachable only from `falling` (the catch-all bucket included); `lying` and `standing` interchange only through `sitting`; `fallen` cannot re-enter `falling`. It is fixed before any evaluation output is seen. Everything else — the empirical prior used during training — is *derived* from the annotations and is never used to decide legality. ## Data **No video, frame or annotation file is redistributed here.** The OmniFall annotations and the GMDCSA24 videos are released by their authors under CC BY-NC-SA 4.0; obtain them from the OmniFall distribution (`arXiv:2505.19889`; ) and from the GMDCSA-24 data article (*Data in Brief* 57 (2024) 110892, ). `data/transition_counts_6x6_staged7.csv` is a **derived statistic**: it counts adjacent segments in the released annotation tables for the seven openly available staged subsets. It is not a redistribution of the annotations. To regenerate it, run `fold_counts()` from `code/transitions_empirical.py` against a local copy of the OmniFall `labels/*.csv` tables (set `TRANSITION_COUNTS_CSV` or `TRANSITION_COUNTS_TAG`). `data/majority_vote_runs.json` contains only per-checkpoint summary statistics (mF1 values and per-class F1 changes); no model outputs or logits are included. ## Licence Code: **Apache-2.0** (see `LICENSE`). Model weights trained on the OmniFall annotations, if released, are **CC BY-NC-SA 4.0**, the non-commercial term required by the source data. They are not part of this repository. ## Citation ```bibtex @article{he2026certified, author = {He, Ming}, title = {Certified State Legality for Fallen-State Monitoring: A Headroom Test for Transition Constraints}, journal = {Pattern Recognition Letters}, year = {2026}, note = {submitted} } ```