Codex/use deepecg layout renderer#46
Open
robertavram-md wants to merge 4 commits into
Open
Conversation
Made-with: Cursor
… tools - Multi-layout renderer: renders NPY ECGs in 13 different layout types with mask generation for U-Net training (scripts/multi_layout_renderer.py) - Batch multi-layout rendering with phone augmentations and multi-layout-per-signal support (scripts/render_acs_multilayout.py) - U-Net multi-layout training with combined ACS + HuggingFace data, phone augmentations, and AMP support (scripts/train_unet_multilayout.py) - Layout classifier training on rendered data (scripts/train_layout_classifier.py) - ONNX export for all 4 models: U-Net, layout classifier, lead ID, WCR (scripts/export_all_onnx.py) - Auto-retrain orchestration script (scripts/auto_retrain_unet.sh) - Batch prediction and full pipeline scripts - Fix decode_image -> read_image compatibility in src/digitize.py - Add lead_layouts_deepecg.yml config for 13 ECG layout types Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(digitize): prevent silent layout fallback that mislabels leads
When the lead identifier couldn't match a layout, it silently defaulted to
the first entry in the candidate YAML and canonicalised leads against it,
producing CSVs that looked correct but had leads mapped to the wrong names
(e.g. a standard_3x4_with_r3 phone photo collapsed into precordial_6x1
with only one signal track populated). Three related problems:
- src/model/lead_identifier.py: the fallback warning was a plain print
and crashed with IndexError if the candidate set was empty (e.g. a
layout hint that didn't match any YAML entry). Raise on empty, emit a
RuntimeWarning otherwise so the unreliable fallback is visible.
- src/digitize.py: layout_should_include_substring was only populated
from a hardcoded filename heuristic ("limb"/"precordial"), so callers
with a layout classifier had no way to pass their prediction through.
Accept a literal substring in the config (e.g. "standard_3x4_with_r3")
and keep the legacy heuristic behind the sentinel "auto_from_filename".
- src/model/inference_wrapper.py: perspective detection + cropping raised
on zoomed-in photos without visible paper borders, aborting the whole
request. Fall back to the full-image rectangle (matching the backend
pipeline) and surface bounding_box_used so callers can flag this.
Also adds src/config/inference_wrapper_all_layouts.yml - a tracked
preset that points the lead identifier at lead_layouts_all.yml (13
layouts) instead of lead_layouts_reduced.yml (2 layouts), which was the
root cause of the observed fallback.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs+meta: surface layout-hint config and digitization status
- README: new "Constraining the layout match from an upstream classifier"
section documenting the three possible values for
DATA.layout_should_include_substring (null, a literal substring, or the
auto_from_filename sentinel) plus the new failure semantics (raise on
empty candidate set, RuntimeWarning on fallback).
- src/digitize.py: extend digitization_metadata.csv with bounding_box_used
and a status column (ok / no_canonical_lines), so runs that produced no
canonical lines are traceable in the metadata instead of appearing as
missing CSV files.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: robertavram-md <robertavram-md@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
No description provided.