Skip to main content

widget2code-bench-exp

Benchmark evaluation for widget code generation — 12 quality metrics across layout, legibility, perceptual, style, and geometry.

Installation

# 1. Install PyTorch with CUDA support first (skip if CPU-only)
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu126

# 2. Install widget2code-bench-exp
pip install widget2code-bench-exp

Note: PyPI only ships CPU-only PyTorch. To use --cuda, you must install PyTorch from the official index before installing this package.

Usage

Single image mode

Evaluate one GT-prediction pair. Prints JSON results to stdout, no files saved.

widget2code-bench-exp \
  --gt_image /path/to/gt.png \
  --pred_image /path/to/pred.png \
  --cuda

Batch mode

Evaluate all matched pairs in directories.

widget2code-bench-exp \
  --gt_dir /path/to/GT \ # /shared/zhixiang_team/widget_research/Comparison/GT
  --pred_dir /path/to/predictions \
  --pred_name output.png \
  --cuda

Directory Structure (batch mode)

  • GT dir: flat image files with 4-digit IDs in filenames (e.g. gt_0001.png)
  • Pred dir: subfolders with 4-digit IDs in names, each containing --pred_name file
gt_dir/                     pred_dir/
  gt_0001.png                 image_0001/
  gt_0002.png                   output.png
  ...                         image_0002/
                                output.png

Options

Flag Default Description
--gt_image — Single GT image path
--pred_image — Single prediction image path
--gt_dir — GT directory (flat image files)
--pred_dir — Prediction directory (subfolders)
--pred_name output.png Prediction filename inside each subfolder
--output_dir {pred_dir}/.analysis Statistics output directory
--workers 4 Parallel threads
--cuda off Enable GPU
--skip_eval off Skip evaluation, only regenerate statistics xlsx files from existing evaluation.json
--minimal off Skip per-metric visualization PNGs (default: verbose with viz)

Output (batch mode)

Per-sample outputs

Every matched pair writes one evaluation.json plus (by default) a full per-metric visualization set into its sample folder:

<pred_dir>/
  image_0001/
    output.png
    evaluation/
      evaluation.json                 # 12 metrics
      viz/
        MarginAsymmetry.png
        ContentAspectDiff.png
        AreaRatioDiff.png
        TextJaccard.png
        ContrastDiff.png
        ContrastLocalDiff.png
        PaletteDistance.png
        Vibrancy.png
        PolarityConsistency.png
        ssim.png
        lp.png
        geo_score.png

Each viz PNG shows left/middle = GT/Pred intermediates and right = formula + intermediate values + final score, so you can see exactly how the metric was computed.

Pass --minimal to skip the viz/ directory (much faster, ~10x less disk).

Missing-prediction handling

The evaluator always produces all four fill modes. When a GT image has no matching prediction:

  • Existing subfolder, pred missing → fill results go in the same folder's evaluation/
  • No subfolder at all → evaluator creates pred_dir/fill_<id>/evaluation/

In either case it writes:

evaluation/
  evaluation_black.json   # GT vs all-black image
  evaluation_white.json   # GT vs all-white image

zero fill isn't a per-sample file — it's a worst-case contribution (LPIPS = 1.0, others = 0) used only when aggregating the combined summary.

Aggregate outputs (.analysis/)

<pred_dir>/.analysis/
  metrics_stats.json                 # per-metric quartiles/mean/std over matched pairs
  metrics.xlsx                       # 4-row combined summary (raw/black/white/zero)
  raw/<run>-raw-<ver>.xlsx           # single-row summary per mode
  black/<run>-black-<ver>.xlsx
  white/<run>-white-<ver>.xlsx
  zero/<run>-zero-<ver>.xlsx
Mode Description
raw Matched pairs only (missing skipped)
black Missing preds scored against an all-black image
white Missing preds scored against an all-white image
zero Missing preds contribute the worst-case value (LPIPS = 1.0, others = 0)

All numeric values are rounded to 2 decimals. Combined metrics.xlsx has a two-level header grouping metrics by category (Layout / Legibility / Style / Perceptual / Geometry) plus SuccessRate (ratio, count). Per-mode xlsx uses flat single-level headers.

All metrics are higher-is-better except lp (LPIPS), which is a distance (lower-is-better).

License

Apache-2.0

Metadata

Release files for widget2code-bench-exp 0.2.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for widget2code-bench-exp 0.2.9
File Size Uploaded Provenance Actions
widget2code_bench_exp-0.2.9.tar.gz 30.0 kB Without provenance Details for widget2code_bench_exp-0.2.9.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for widget2code-bench-exp 0.2.9
File Interpreter ABI Platform Actions
widget2code_bench_exp-0.2.9-py3-none-any.whl Python 3 none any Details for widget2code_bench_exp-0.2.9-py3-none-any.whl

Total release size: 63.9 kB

Release files / widget2code_bench_exp-0.2.9.tar.gz

Download URL widget2code_bench_exp-0.2.9.tar.gz
Size 30.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ce192a715c617522f0ab7e2decce13fb430362c84ca434d758ce16663a96e8e9
BLAKE2b-256 checksum
How to use checksums
80850747e30d55fbbae3ba3791fbd6752d91359007b91a9dc9fdda9f5a139957
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / widget2code_bench_exp-0.2.9-py3-none-any.whl

Download URL widget2code_bench_exp-0.2.9-py3-none-any.whl
Size 33.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a358fe8247fbe386c329df5880960e1a22d2771384d466364226d9d5521df9eb
BLAKE2b-256 checksum
How to use checksums
d4c3d2f933f06e76d92a1f92c10ec86c96c2d82aead60d7dc9e300699210b153
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Security for widget2code-bench-exp 0.2.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page