Spaces:
Runtime error
Runtime error
|
Download EVAL_LOG.md from jkos9/plotscribe: direct link, hf CLI and curl.
- Browser
- Download file 17.5 kB
-
https://huggingface.co/spaces/jkos9/plotscribe/resolve/main/EVAL_LOG.md
- Command line
-
hf download hf://spaces/jkos9/plotscribe/EVAL_LOG.md
-
curl -L -o EVAL_LOG.md https://huggingface.co/spaces/jkos9/plotscribe/resolve/main/EVAL_LOG.md
17.5 kB
| # plotscribe evaluation log | |
| Per-stage results, failure analysis and what was changed. Errors are fractions of | |
| the axis range (log10 space for log axes). "clean" = default matplotlib PNG export; | |
| "perturbed" = random style/font/resolution/JPEG/log/markers/dashes/legend position. | |
| Regenerate any table with the command shown (data is generated deterministically | |
| from the seed). | |
| ## Stage 1 — scaffold, synthetic generator, evaluation harness | |
| - `tests/synth.py` renders random charts with matplotlib and stores exact ground | |
| truth: data, axis limits/scale, and the *pixel* plot box and tick positions taken | |
| from matplotlib's transforms (verified by overlaying them on renders). | |
| - `tests/metrics.py`: per-point error (numeric x: GT x interpolated on the | |
| predicted polyline; categorical: matched by category; scatter: optimal 1-1 point | |
| matching), series matched by Hungarian assignment; calibration error at the GT | |
| tick pixels; tick recall (±1.5 px). | |
| - `tests/evaluate.py`: parallel evaluation, summaries by chart type / tier / | |
| perturbation, and debug overlays of the worst cases in `<out>/worst/`. | |
| ## Stage 2 — axes, ticks, OCR, calibration | |
| `python -m tests.evaluate --n 100 --tier clean` | |
| | metric (100 clean charts, all types) | first run | after fixes | | |
| |---|---|---| | |
| | plot-box IoU (median) | 0.986 | 0.988 | | |
| | x / y tick recall | 0.99 / 0.999 | 1.00 / 1.00 | | |
| | y axis type correct (linear/log/categorical) | 0.75 | 1.00 | | |
| | y calibration error median / p90 | 0.08% / 0.17% | 0.07% / 0.14% | | |
| | y calibration failures (>1% error or none) | 26% | 0% | | |
| Failures found and fixed: | |
| 1. Gridlines lose the pixels where they cross a spine, so the box edge was 4 px | |
| inside the spine and tick marks leaked into the label region (OCR read "100 -"). | |
| Fix: snap box edges onto spines; drop thin tick remnants at the region border. | |
| 2. Bars interrupting gridlines out-voted the spines for the plot bottom (negative | |
| bar charts used the zero line as the x axis -> tick length 24 px -> the last | |
| digit of every y label cut off -> a *consistent but 10x wrong* calibration). | |
| Fix: plot box from the outer extent of long lines; per-axis tick length. | |
| 3. Tesseract misreads isolated single digits and drops the U+2212 minus sign. | |
| Fix: geometric minus-sign detection; each numeric label is read three ways | |
| (line/numeric line/numeric word) and RANSAC chooses among the candidate values. | |
| Residual error (~0.1-0.2%) is dominated by matplotlib snapping tick marks to the | |
| pixel grid (up to 0.5 px), i.e. a property of the rendering, not of the fit. | |
| ## Stage 3 — line charts end to end | |
| `python -m tests.evaluate --n 100 --tier clean --kinds line --oracle-type --start-seed 2000` | |
| (`--oracle-type` passes the true chart type so this stage is scored in isolation.) | |
| | metric (100 clean line charts) | first run (20 charts) | final | | |
| |---|---|---| | |
| | point recall | 0.85 | 0.997 | | |
| | series count correct | 0.60 | 1.00 | | |
| | median of per-chart median error | 0.16% | 0.19% | | |
| | p90 of per-chart median error | 0.60% | 0.39% | | |
| | per-chart max error: median / p90 | | 1.5% / 5.6% | | |
| Failures found and fixed: | |
| 1. Long category labels touch/overlap -> merged OCR boxes -> wrong category | |
| positions. Fix: assign label glyphs to tick cells when ticks are regular; one | |
| label per tick (fragments re-read together). | |
| 2. matplotlib offset text ("+1.063e3" at the end of the axis) made all x values | |
| relative. Fix: detect and parse offset/multiplier text, apply to labels. | |
| 3. Anti-aliased edges formed their own colour peaks (one series became 2-3). | |
| Blending is linear in sRGB, not Lab, so the blend test and soft assignment now | |
| run in sRGB. | |
| 4. Semi-transparent legends over data lines: glyphs and swatches fused with the | |
| faded lines -> legend entries missed. Fix: text from dark achromatic pixels, | |
| swatches from strong-contrast pixels only. | |
| Remaining worst cases (clean): max errors of 10-20% at isolated points where | |
| several lines cross and one series is occluded around a vertex; the polyline | |
| interpolates across the occlusion and cuts the corner. | |
| Perturbed lines (`--tier perturbed`, 100 charts): calibration fails on 45% — | |
| almost entirely non-default styles (Solarize, ggplot, fivethirtyeight: no spines | |
| or tinted panels; bmh/classic: inward ticks) and low resolution. Deferred to | |
| stage 7 by design. | |
| ## Stage 4 — bar charts (simple, grouped, stacked, negative) | |
| `python -m tests.evaluate --n 150 --tier clean --kinds bar,grouped_bar,stacked_bar --oracle-type --start-seed 3000` | |
| | 150 clean bar charts | first run | final | | |
| |---|---|---| | |
| | median of per-chart median error | — (bars sliced) | 0.12% | | |
| | worst point error (all charts) | 54% | 0.86% | | |
| | recall | | 98.8% (rest = bars hidden by the legend, left empty) | | |
| Failures found and fixed: | |
| 1. matplotlib draws gridlines *over* bars; removing grey pixels sliced every bar and | |
| the grey/colour blend became a fake series. Fix: inpaint gridlines with a | |
| per-pixel "semi-transparent grey overlay" model (P = N + a(g - N)). | |
| 2. The gridline detector estimated "background" as the region median, which is a bar | |
| colour in stacked charts. Fix: use the detected panel background. | |
| 3. Bar edges integrated alpha from edge to mid-bar, picking up interior deficits | |
| (tall bars read 1-2% low). Fix: integrate across the edge zone only. | |
| 4. Bar tops coinciding with a gridline split off slivers. Fix: merge pieces | |
| (symmetric adjacency test). | |
| 5. Legend placed over tall bars (`loc="best"`) truncated them. Fix: bars ending | |
| at the legend box are reported as occluded (empty + warning). | |
| ## Stage 5 — scatter | |
| `python -m tests.evaluate --n 100 --tier clean --kinds scatter --oracle-type --start-seed 4000` | |
| Median error 0.096%, recall 98.3%, series count 97%. Fixes: tick at the plot corner | |
| extended the spine and moved the plot bottom 8 px (digits cut → "0" read as "U"); | |
| legend markers sit ~2 glyphs from their text (wider pairing gap). Remaining misses | |
| are markers >70% hidden by other series. | |
| ## Stage 6 — chart type, legend pairing, series count (no oracle) | |
| 200 clean charts: chart type 100% (stacked vs grouped included), series count 99%, | |
| recall 98.7%, median 0.11%, 0 silent failures. | |
| ## Stage 7 — robustness (perturbed tier, 200 charts, seed 6000) | |
| | metric | baseline | final | | |
| |---|---|---| | |
| | silent failures (status ok, wrong) | 28.5% | 8% | | |
| | y calibration failures | 38% | 29% | | |
| | chart type accuracy | 85% | 92% | | |
| | median of per-chart median error | 0.42% | 0.26% | | |
| Fixes: low-contrast and tinted panels (Solarize/ggplot: neutral-colour candidates, | |
| opening + cell growth); ticks hanging from the panel edge without axis lines; label | |
| glyphs selected without clipping (a clipped last digit gave consistent 10x-wrong | |
| calibrations); clipped-label and data-outside-plot checks lower the status; | |
| `10^n` superscript labels (geometric split, single-char OCR, log-only fit, bounded | |
| tick snapping); line vs scatter by chaining continuity; stacked detection robust to | |
| JPEG fragments; categories re-anchored on bar groups when labels merge. | |
| Remaining perturbed failures (from `eval_out/stage7_perturbed`): category labels | |
| merging on bmh/whitegrid/fivethirtyeight bars without tick marks; fivethirtyeight | |
| plot box; frameless legends on top of data; low-resolution classic-style JPEG bars | |
| misclassified as line. | |
| ## Consolidation for deployment | |
| Dropped scikit-learn (unused) and scikit-image (peaks + watershed replaced with | |
| SciPy/OpenCV; scatter points on 12 clean charts: 950 vs 949 before). Added a | |
| FastAPI upload page (`plotscribe/web.py`), Dockerfile, pytest suite (31 tests, | |
| including the clean-chart < 1% target) and `tests/eval_real.py`. | |
| ## Stage 8 — public benchmark (PlotQA) and fixes | |
| Benchmark: Hugging Face `martinsinnona/plotqa` (PlotQA images + plotted values, | |
| single series; line, dot and bar charts rendered by Bokeh). Tuned on the 100-chart | |
| test split, then checked on 300 unseen charts from the train split, comparing with | |
| the previous commit (`18b6371`) run on the same charts. Figure: `docs/progress.png` | |
| (`python -m tests.plot_progress`). | |
| | held-out PlotQA (287 scoreable) | before | after | | |
| |---|---|---| | |
| | RNSS | 84.4 | 97.3 | | |
| | point recall | 50% | 91% | | |
| | charts within 1% median error | 54% | 93% | | |
| | status ok | 4% | 93% | | |
| | silent failures | 4.2% | 4.2% | | |
| Failures found and fixed (in order of impact): | |
| 1. Rotated (90°) x tick labels were OCR'd upright -> garbage categories. Fix: | |
| detect vertical text (glyph shape, label shape vs. the upright y-label glyph | |
| size, and vertical stacking), group glyphs vertically, OCR the crop turned | |
| +/-90° (direction chosen per axis by OCR score). | |
| 2. With tiny tick fonts the rotated y-axis *title* sat next to the tick labels and | |
| its letters became dozens of fake labels -> y axis "categorical". Fix: remove | |
| long vertical glyph runs before choosing the label column. | |
| 3. Fine dotted lines were deleted as specks. Fix: keep many small components of | |
| consistent size. | |
| 4. Lines sampled at the tick positions produced noisy RDP vertices. Fix: coarser | |
| tolerance for dotted lines; when every corner sits on an x tick, report values | |
| at the ticks (x = the tick's own label value). | |
| 5. Evenly spaced but non-consecutive years (1990, 1991, 1996, ...) were fitted as a | |
| numeric axis with half the labels rejected. Fix: increasing integer x labels that | |
| are not linear in position become categories. | |
| 6. Bar outlines in a different colour became extra series. Fix: drop colour | |
| clusters that are thin and only border another series. | |
| 7. Scatter on a categorical x axis wrote pixel positions into the `category` column | |
| (export bug). | |
| 8. Data outside the axis range is clipped by the frame (frequent in PlotQA). New | |
| check: a line that leaves the plot area and comes back, or several bars ending at | |
| the frame, lowers the status to `low_confidence`. | |
| Regressions found and fixed along the way: the rotation cue misfired on low-res | |
| JPEGs with touching letters (wide upright words) and the categorical fallback fired | |
| on log/noisy y axes; both were restricted. Synthetic results after this stage: | |
| clean unchanged (0.11% median error, 0 silent failures); perturbed silent failures | |
| 8% -> 6.5%, series count 86% -> 88%, status ok 57.5% -> 55%. | |
| Remaining: held-out silent failures (4.2%) are mostly lines whose data leaves the | |
| plotted range at one end only (indistinguishable from a maximum on the frame), and | |
| bars 1-3 px tall that cannot be measured. | |
| ## Stage 9 — smooth crossing curves (real MATLAB figure), web re-plot | |
| Trigger: `data/vcsel_response_test.png` (7 smooth curves sharing an origin and | |
| crossing). Before: dozens of clustered points per curve, y labels misread, curve | |
| starts hidden under other curves missing. | |
| Failures found and fixed: | |
| 1. Line thickness was inflated by markers/crossings (14.7 px on some charts), which | |
| drove over-smoothing and vertex thinning. Fix: slope-corrected 30th-percentile | |
| run thickness. | |
| 2. RDP on a jittery centreline gave clusters of vertices. Fix: Savitzky–Golay | |
| de-jitter, tolerance from a MAD noise estimate, Visvalingam thinning to a minimum | |
| vertex spacing (~1% of the width). | |
| 3. Markers hidden under another series' marker left gaps. Fix: add the line's | |
| corners inside gaps >= 1.6x the marker spacing; reject marker "blobs" smaller than | |
| the line could produce. | |
| 4. Curves whose start is hidden under another curve: continued along the occluding | |
| trace (within 2x thickness) and reported in the warnings. | |
| 5. Y-label crops included the axis line -> misreads. Fix: crops clipped at the axis. | |
| 6. Legend "ImA" -> "1mA" repair when the other entries share a digit pattern. | |
| 7. The labels-touching-the-frame check used a fixed gap; now relative to label | |
| height (it had been catching otherwise-silent perturbed failures). | |
| 8. Optional `--resample N` (web: "even x spacing") reports lines on a shared round x grid. | |
| | regression check | before | after | | |
| |---|---|---| | |
| | clean 200: median error / silent | 0.11% / 0% | 0.11% / 0% | | |
| | clean lines 100 (oracle): median / p90 chart median | 0.19% / 0.39% | 0.13% / 0.25% | | |
| | perturbed 200: silent / status ok / recall | 6.5% / 55% / 79% | 6.5% / 57.5% / 80% | | |
| | PlotQA test RNSS / held-out RNSS | 99.5 / 97.3 | 99.5 / 97.1 | | |
| ## Stage 10 — silent failures on perturbed charts | |
| Of 13 perturbed charts reported `ok` but wrong (6.5%), 7 were bar charts with | |
| misread categories. | |
| Fixes: | |
| 1. Grouped bars separated by edge strokes / JPEG erosion became one category per | |
| bar (and labels were split across them). The within-group gap tolerance is now | |
| taken from the gap distribution (largest jump between small and large gaps). | |
| 2. Category names that look misread (stray symbols, unbalanced brackets, fused | |
| words, 1-2 letter fragments at the edges) lower the status when >= 1/3 of them. | |
| 3. Linear tick values must be multiples of their spacing (a digit misread on every | |
| label, "0" -> "6", still fits a line). | |
| 4. Rejected labels exactly 10^k smaller than the fit (decimal points lost on the | |
| inliers) lower the confidence. | |
| 5. Status also drops when the x calibration is very weak or most legend colours are | |
| missing from the plot. | |
| | 200 charts | before | after | | |
| |---|---|---| | |
| | perturbed: silent failures | 6.5% | 0.5% | | |
| | perturbed: point recall | 80% | 84% | | |
| | perturbed: status ok | 57.5% | 48.5% | | |
| | clean: silent failures / median error | 0% / 0.11% | 0% / 0.11% | | |
| | clean: status ok | 100% | 97% (6 line charts with misread rotated category names, correctly flagged) | | |
| | PlotQA test / held-out RNSS | 99.5 / 97.1 | 99.5 / 97.1 | | |
| ## Stage 11 — real pgfplots / xmgrace figures (user examples) | |
| Four user figures (`data/my_figs/tricky_examples`, not in the repo; checked by | |
| `tests/test_tricky.py` when present) failed: dotted lines with markers on a log axis | |
| read as ~1000 scatter points; black legend entries and a black dashed data line lost; | |
| bar legend with paired-bar swatches missed; light tints of other series' colours | |
| merged away; a bar against the frame cut the plot area at mid-height. | |
| Fixes: | |
| 1. Legend: swatch colour from the saturated interior (black-outlined markers); | |
| swatch outlines are not text; taller marker swatches; label words joined across | |
| wide spaces; a missed entry (2x spacing) no longer breaks the column; a grid pass | |
| adds entries the pairing missed (black/grey or dashed swatches, coloured text), | |
| only with a new colour and readable text. | |
| 2. Colours: peaks below the threshold no longer stop the search (thin-line | |
| anti-aliasing peaks came first); blends are merged before thresholding; a tint | |
| that fills solid areas is its own colour, and pixels prefer the colour they match | |
| at full strength. | |
| 3. Same-colour legend entries of different kinds (markers vs line) are split by | |
| shape; marks attached to markers (error bars) and outlines of other series dropped. | |
| 4. Annotation text drawn in a series colour (glyph-sized, thick, collinear marks of | |
| varied size or touching) is removed; black/grey marks not in a multi-entry legend | |
| are ignored as annotations. | |
| 5. Markers on dotted lines: the larger blobs are the markers; lone same-colour marks | |
| with no line into them are not markers; corners in marker gaps must leave the | |
| straight line; a line running past its last visible marker ends at a hidden marker, | |
| aligned with the other series' marker x. | |
| 6. Gridline removal only at tick-label grid positions / detected long lines (a black | |
| dashed reference line is data). | |
| 7. Plot bottom/top from a full-width line beyond the vertical lines; grouped bars on | |
| a numeric x axis give one row per group at the tick value; no-legend bar series | |
| ordered left to right; empty non-legend colours dropped. | |
| 8. Status: legend and plot colours not matching up lowers it. | |
| | 200 charts | before | after | | |
| |---|---|---| | |
| | clean: silent / median error / series count | 0% / 0.11% / 99% | 0% / 0.10% / 99.5% | | |
| | perturbed: silent / series count / recall / type | 0.5% / 88.5% / 84% / 91% | 0.5% / 90.5% / 85.5% / 92% | | |
| | PlotQA test / held-out RNSS | 99.5 / 97.1 | 99.6 / 97.1 | | |
| | user figures t_1..t_4 | all wrong | all correct (t_2 low_confidence: 3 y labels covered) | | |
| ## Stage 12 — bar charts as screenshots / JPEGs | |
| The user figures t_3/t_4 passed as the original PNGs (also inside the Space's Docker | |
| image) but failed when uploaded as screenshots: rescaled 0.5-2x or saved as JPEG, | |
| 11 of 20 variants were wrong, most with status `ok`. | |
| Fixes: | |
| 1. Bar pieces: overlapping same-series pieces, edge slivers with the same top, and | |
| bottoms blurred by compression are merged into one bar. | |
| 2. Unnamed colours whose every bar lies on (or just outside) another series' bar are | |
| outlines/fringes, not series. | |
| 3. Two unnamed similar colours whose bars fill different groups at the same slot are | |
| one series split by compression. | |
| 4. Small clusters next to a much heavier colour merge with a looser blend tolerance | |
| (JPEG fringes); legend swatches washed out by JPEG match the nearest free colour. | |
| 5. Collinear line segments split by a one-pixel step (rescaled images) are joined; | |
| this had cut the plot area at mid-width. | |
| 6. Status: a legend of line swatches on a chart read as scatter is `low_confidence`. | |
| t_3/t_4 at scales 0.5/0.75/1/1.5/2, PNG and JPEG q75: 9 -> 19 of 20 correct (the | |
| remaining 240x188 JPEG is `low_confidence`); checked in `tests/test_tricky.py`. | |
| Synthetic and PlotQA results unchanged (clean 0% silent, 0.10% median error; | |
| perturbed 0.5% silent; PlotQA RNSS 99.6 / 97.1). | |