Repository navigation
feat(ml): real-data ingestion and frozen eval set from CGHD, Roboflow and Sampleimages - #26
Merged
Merged
Conversation
…ow, Sampleimages) Fetch a 4-drafter CGHD pilot (pinned HF revision), convert VOC to YOLO in the classes.yaml vocabulary, relabel transistor.fet into NMOS/PMOS with our own reference pass propagated across photos, merge the 46 Roboflow images (polygon to box) and label the 4 spare Sampleimages. Splits are by drafter or source image; a script verifies no drafter, source image, image content or near-duplicate crosses splits. Commits only scripts, label decisions, the manifest with hashes, the per-class report and DATA_LICENSES.md; fetched data stays gitignored under ml/data_real/.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
✅ Deploy Preview for digisim canceled.
|
This branch was successfully deployed
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.
Intent
DigiSim is a neglected project. Pull up the latest changes in Linux. It is high time to start training the model for it. I have not been able to provide the data. Figure out, get the data, train a model, make improvements and fix that. Do not come to me until you absolutely need me.
Context: the scout report at ~/linux-fleet-home/data/digisim-ml-scout/report.md found that the only trained detector uses 12 gate-era classes and detects nothing on the transistor-first schematics the app now uses, that the transistor-level training data does not exist yet, and that the wire/net tracing assumes left-to-right gates. It split the work into tasks T1-T11; this change is one of them, the real-data ingestion and frozen eval set. T1 (the class schema, ml/classes.yaml as single source of truth) is already merged. This task: fetch a small pilot of the CGHD hand-drawn circuit dataset (3-4 drafters, under 1 GB, via the Hugging Face mirror), convert its VOC annotations to YOLO using the class remap onto the classes.yaml vocabulary, relabel CGHD transistor.fet into NMOS/PMOS with our own manual or heuristic-assisted pass and flag uncertain ones, merge the 46 Roboflow images already in the repo (polygon to box) and label the 4 spare Sampleimages, split by drafter (never by image), and write ml/DATA_LICENSES.md (source, licence, attribution; CGHD CC BY 4.0, Roboflow export CC BY 4.0) plus a manifest with hashes. Fetched data stays out of git; commit only scripts, split manifests, hashes and the licences file. Acceptance: per-class real counts reported against the data-plan table with an explicit 'real count too low, synthetic-only claim' flag for any class under 30 test instances; no drafter or source image appears in two splits (script-verified); licence file reviewed. No Roboflow Universe downloads and no Kaggle or Roboflow credentials.
What Changed
ml/real_data/package, run aspython -m real_data.build fetch|sheets|convert|verify|report.fetchpulls a 4-drafter CGHD pilot (drafters 16, 19, 20, 25) from the Hugging Face mirror, pinned to a revision.convertturns the CGHD VOC annotations into YOLO labels using theml/classes.yamlvocabulary. It also merges the 46 Roboflow images (polygons to boxes) and the 4 spare Sampleimages. CGHDtransistor.fetis relabelled NMOS/PMOS from our own manual pass inlabels/fet_polarity.json. Uncertain transistors, terminals, supply symbols and unmapped classes are kept as ignore regions, not labels. Fetched and converted data go to the gitignoredml/data_real/.verifyre-checks the committed manifest for any drafter, source image or image content (exact and near-duplicate hash) in two splits.ml/data_manifest.jsonrecords SHA-256 hashes of every image and label, split membership and a frozen hash per split.ml/REAL_DATA_REPORT.mdis generated from it and lists per-class real counts against the data-plan targets. It flags any class with fewer than 30 real test instances asreal count too low, synthetic-only claim. In this pilot those are OUTPUT_PORT, NOT, NAND, NOR, XOR, XNOR, INDUCTOR, BJT_NPN, BJT_PNP and CLOCK.ml/DATA_LICENSES.mdwith source, licence and attribution for CGHD (CC BY 4.0) and the Roboflow export (CC BY 4.0). Updated the README data-sources table andagent_docs/ml-pipeline.md. Addedpillow,scipyandhuggingface_hubtoml/pyproject.toml(anduv.lock), gitignoredml/data_real/, and addedml/tests/test_real_data.py.Risk Assessment
✅ Low: The three fix-round changes are correct as traced: GND text is tested before the numeric rule, tiny FETs still consume an ordinal, and vss and voltage.dc go through text triage. The new tests and the regenerated manifest and report are consistent with that code. I did not run tests or the leakage verifier, per instructions.
Testing
I ran the real-data CLI against the fetched CGHD pilot, Roboflow and Sampleimages data in the worktree. The 43 targeted tests passed.
verifypassed, and a freshconvertregenerated the committed manifest and report byte-for-byte with 0 leakage violations. Direct probes confirmed the three review fixes. "0V" and its variants now map to GND, and the tiny-FET case keeps polarity keys aligned (a 2px FET before two normal ones gave NMOS and PMOS to the right boxes). vss and voltage.dc are no longer direct remaps; they resolve by nearby text (VSS gives GND, 5V gives VDD) and are otherwiseuncertain_supplyignore regions. Moving images between splits madeverifyreport drafter/group leakage and stale split hashes. The report flags classes with fewer than 30 real test instances as "real count too low, synthetic-only claim". The licence file lists CC BY 4.0 for CGHD and Roboflow and notes the CGHD licence conflict between its sources. There is no UI surface; evidence is CLI and API-level output only.real_data.build convert-> 'wrote data_manifest.json: 434 images, 0 violations'; git status clean after, so manifest and report match the committed ones;verifyOKgit ls-files ml/data_realreturns 0 files, the path is gitignored, and ml/DATA_LICENSES.md covers CGHD, Roboflow and SampleimagesEvidence: Probe output: convert_annotation fixes and leakage rejection
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
🔧 **Rebase** - 1 issue found → auto-fixed ✅
ml/uv.lock- merge conflict rebasing onto origin/main🔧 Fix applied.
✅ Re-checked - no issues remain.
🔧 **Review** - 3 issues found → auto-fixed ✅
ml/real_data/class_remap.py:84- classify_terminal labels a "0V" terminal as VDD._VOLTAGE_TEXT(\d+(\.\d+)?v) is tested before_GND_TEXT, so "0v", "0V", "+0v" and "0.0v" all match the voltage branch, and 0 <= MAX_RAIL_VOLTS returns VDD._GND_TEXTlists0v, which shows GND was intended, but that alternative is unreachable. I ran classify_terminal("0V"), which returned VDD, while "0" returned GND. A "0V" ground reference is common in textbook schematics, so real GND terminals end up in the frozen train/valid/test labels as VDD. That corrupts the GND and VDD real counts and the frozen eval set. Fix: check_GND_TEXTbefore_VOLTAGE_TEXT, or require a positive value for the VDD branch, add a "0V" test case, and regenerate the manifest and split hashes. No test covers it: tests/test_real_data.py:84-100 has no zero-volt case.ml/real_data/cghd.py:173- The per-image transistor ordinal is counted two different ways, so a tiny transistor shifts every later polarity label. fet_polarity.fet_objects (fet_polarity.py:64) numbers every transistor.fet object, including ones under MIN_BOX_SIDE. propagate_polarity, load_polarity and the reference decisions key polarity as "<key>#<ordinal>" with that numbering. convert_annotation (cghd.py:172-180) skips boxes smaller than 4px before incrementingfet_seen. If any FET box has a side under 4px, every later FET in that image looks up the previous FET's decision. That gives wrong NMOS/PMOS labels with no error. The propagate_polarity checksorted(decisions) == range(count)cannot catch it because it uses the unfiltered count. Fix: countfet_seenfor every transistor.fet object before the size filter, or filter inside fet_objects so both sides agree. Add a test with a tiny FET followed by a real one.ml/real_data/class_remap.py:24- CGHDvsssymbols are remapped to VDD in CGHD_DIRECT, while the text triage in the same module treats the labelvssas GND (_GND_TEXT:v_?ss). The same concept therefore gets opposite classes depending on which path sees it. VSS is the negative or ground rail, so labelling the symbol VDD injects wrong labels into a power class that is already scarce. The change's intent does not require mappingvss. The smallest honest remedy is to removevssfrom CGHD_DIRECT so it becomes an ignore region, or to map it to GND if that is the intended meaning. Related:voltage.dc-> VDD (class_remap.py:23) maps any DC source symbol, including batteries and bias sources in non-supply positions, to VDD. This needs a human decision on the labelling policy.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
real_data.build convert-> 'wrote data_manifest.json: 434 images, 0 violations'; git status clean after, so manifest and report match the committed ones;verifyOKgit ls-files ml/data_realreturns 0 files, the path is gitignored, and ml/DATA_LICENSES.md covers CGHD, Roboflow and SampleimagesPYTHONPATH=. python -m pytest tests/test_real_data.py -q(43 passed)python -m real_data.build verifyagainst the committed manifest (OK, no leakage)python -m real_data.build convertre-run on the fetched CGHD pilot, Roboflow and Sampleimages data (434 images, 0 violations; ml/data_manifest.json and ml/REAL_DATA_REPORT.md came out byte-identical to the committed ones)Probe of classify_terminal and classify_supply with 0V, 0v, +0v, 0.0v, 0, 5V, +5, VDD, vss, 1000V, R1, Vin and NoneProbe of convert_annotation with a 2px FET before two normal FETs, vss and voltage.dc symbols next to different labels, and a terminal labelled 0VTampered manifest copies (a drafter_20 image moved to train; a different image moved to another split) run through build.verifyRead ml/REAL_DATA_REPORT.md and ml/DATA_LICENSES.md; confirmed ml/data_real is gitignored with 0 tracked files✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.