# Training Synthetic data generators and training scripts of the four networks in `../models`. Data and checkpoints go through Hugging Face repos (`HUB_REPO_ID`, `DATASET_REPO`, `MODEL_REPO`); the generators run on CPU, the window networks and the mask need a CUDA GPU. | model | data | train | |---|---|---| | `offsets.onnx` | `VERSION=v3 python3 build_canvases.py` (10 000 + 1 000 + 1 000 canvases) | `train_offsets.py` (200 epochs), then `export_onnx.py offsets` | | `detector.onnx` | `VERSION=v5 python3 build_canvases.py` (12 000 + 1 000 + 1 000 canvases) | `train_detector.py` (156 epochs), then `export_onnx.py detector` | | `mask.onnx` | `python3 build_masks.py` (6 000 + 500 pages) | `train_mask.py` (40 epochs, exports ONNX) | | `lattice.onnx` | generated on the fly (`lattice_points.py`) | `train_lattice.py` (30 000 steps, exports ONNX) | Setup: ``` pip install -r requirements.txt make -C renderer # C++ renderer -> renderer/mesh_render.so (Linux) ``` The renderer is [MeshAugmentor](https://github.com/pashaalex/mesh_augmentor). Instead of building it, take the prebuilt library from its [release 0.1.0](https://github.com/pashaalex/mesh_augmentor/releases/tag/0.1.0) and put the files from `mesh_augmentor/_lib/` into `renderer/`: `mesh_render.so` (Linux) or `mesh_render.dll` with the three MinGW runtime DLLs next to it (Windows). The seeds, sizes and hyper-parameters are those of the published models. The published models were trained on an earlier version of these generators that drew ECG traces from recorded ECGs and used another hand-writing font; everything else is unchanged. Bitwise reproducibility of GPU training is not expected. ## Files - `renderer/` — C++ ray-tracing mesh renderer from MeshAugmentor (thin lens, distortion, disk light, shadows) and its ctypes binding. - `sheet_geometry.py` — developable sheet: profile curve with cylinder / wave / ridge / crease / curl / fold components. - `ecg_synth.py` — synthetic 12-lead ECG (five Gaussian waves per lead, no data files). - `ecg_paper.py` — flat ECG sheet texture (grids, paper, ECG traces, text, stains). - `scene.py` — sheet + camera + renderer + photometry -> photo, mask, uv; `shadows.py` — sharp shadows (v5). - `canvas.py`, `build_canvases.py` — 320 x 320 training canvases with dense paper-coordinate labels. - `crops.py` — 224 x 224 windows and patch labels; `common.py` — shared training code. - `detector_data.py` — node ground truth, occlusions and CenterNet targets for the detector. - `mask_page.py`, `mask_backgrounds.py`, `mask_scene.py`, `build_masks.py` — whole-page photos with sheet / signal labels. - `lattice_points.py` — synthetic corrupted node sets for the lattice GNN. - `fonts/` — DejaVu Sans Mono and Caveat (hand-writing), with their licences.