Skip to content

Repository files navigation

Figure Extractor logo

Figure Extractor

Turn research papers into complete, reviewable figures and tables.

An installable AI-agent skill and standalone CLI for PDF, arXiv, OpenReview, ACL Anthology, and HTML papers. It finds captions, reconstructs the full exhibit, renders publication-quality crops, and produces a contact sheet for verification.

MIT License CI Release Python Agents

Install · Use it · Real output · Benchmarks · Usage guide · 中文

A complete scientific figure extracted by Figure Extractor
Real output from TransMem (arXiv:2607.29032), extracted at publication quality.

Why it exists

PDF figures are rarely single embedded images. A chart may combine vector paths, text labels, legends, and raster fragments. Extracting embedded images often returns incomplete pieces that still look plausible.

Figure Extractor treats extraction as a document-layout problem:

  • detects figures, tables, algorithms, listings, schemes, charts, boxes, and CJK captions;
  • infers columns and keeps each crop inside the correct reading band;
  • prevents one exhibit from stealing another caption or neighboring prose;
  • stitches exhibits split across columns or pages;
  • exports high-DPI crops, manifest.json, contact_sheet.jpg, and an optional ZIP;
  • marks every result ok, suspect, or failed instead of hiding uncertainty.

Install the skill

Install globally for Codex:

npx skills add Sunrich-HT/figure-extractor --global --agent codex --skill figure-extractor --yes --copy

Then start a new Codex task. Type $ and select figure-extractor, or begin your request with $figure-extractor. Skills use a $ mention, not a slash command.

Install the CLI instead
git clone https://github.com/Sunrich-HT/figure-extractor.git
cd figure-extractor
pip install -e .
figure-extractor --help

The runtime dependency is PyMuPDF. beautifulsoup4 is optional; the standard library handles HTML when it is absent.

Use it

Let the agent extract and verify everything

$figure-extractor

Extract every figure and table from this paper:
https://arxiv.org/abs/1706.03762

Save publication-quality crops, generate a contact sheet and manifest, inspect
all suspect or failed items, and give me the output directory plus a short QA report.

Extract only the figures that carry the argument

$figure-extractor

Extract the figures from the attached paper. Prioritize tier A items, inspect the
contact sheet, and tell me which three figures I should study first and why.

Use the CLI directly

figure-extractor extract https://arxiv.org/abs/1512.03385 \
  --out ./figures --dpi 300 --zip

See the full usage guide for local PDFs, HTML papers, selected kinds, manual crop correction, follow-up prompts, and output interpretation.

Real output

The contact sheet below is generated from the extracted results for TransMem (arXiv:2607.29032). It contains 4 figures and 13 tables; all 17 crops were classified ok.

Real contact sheet with 17 extracted figures and tables

The files shown here are committed outputs, not a mockup. Open the image to inspect the crops at full resolution.

For a reproducible end-to-end run, see the live Attention Is All You Need example: 5/5 figures, 5 ok · 0 suspect · 0 failed, with the generated contact sheet committed.

How it works

paper or article
      |
      v
source normalization  ->  caption discovery  ->  layout-aware region inference
      |                                                   |
      v                                                   v
HTML originals when available                    300-DPI page render and crop
      |                                                   |
      +------------------------->  QA scoring  <----------+
                                      |
                                      v
                  crops + manifest + contact sheet + ZIP

The core rule is simple: retrieve exhaustively, judge visibly. Extraction does not silently filter the long tail. Triage tiers help prioritize reading, while quality status tells you which crops require inspection.

Measured behavior

Results were checked visually against generated contact sheets on papers chosen for different layouts:

Paper Layout Recovered Quality status
ResNet two-column CVPR 7/7 figures, 14/14 tables 21 ok · 0 suspect · 0 failed
Attention Is All You Need single column 5/5 figures, 4/4 tables 9 ok · 0 suspect · 0 failed
Secret Hitler two columns, tables captioned below, listing split across pages 5/5 figures, 13/13 tables 21 ok · 0 suspect · 0 failed
KAN arXiv HTML 25 images, 7 text tables 32/32 containers accounted for

These cases demonstrate coverage, not a universal accuracy claim. Unseen layouts can still need manual correction, which is why the manifest and contact sheet are part of the product rather than optional debugging artifacts.

Supported sources

Source Handling
Local PDF or HTML processed directly; inline data: images work offline
Browser PDF viewer unwraps ?file=, #file=, or ?url= to the real document
arXiv /abs/ or /pdf/ normalized to the PDF
arXiv /html/ preserves original HTML figure assets
OpenReview forum normalized to its PDF endpoint
ACL Anthology landing page normalized to .pdf
bioRxiv / medRxiv normalized to .full.pdf
General article URL reads <figure>, <picture>, srcset, lazy images, SVG, object, embed, and tables

Output contract

figures/
  fig1_p01.png          figure crop named from the paper
  figB-1_p14.png        appendix numbering preserved
  tab3_p06.png          rendered PDF table
  tab1.md               HTML text table
  contact_sheet.jpg     all results with QA status
  manifest.json         caption, page, bbox, tier, status, and reasons
  figures.zip           optional archive

An exhibit split across a column or page break includes parts in the manifest. Always inspect suspect and failed entries before reuse. A failed crop means the region could not be established confidently, not that the source contains no figure.

Runs in constrained environments

The preferred CLI needs Python and PyMuPDF. If package installation or network is unavailable, the repository also includes:

PYTHONPATH=src python -m figure_extractor extract paper.pdf
python standalone/figure_extractor_standalone.py extract paper.pdf

SKILL.md carries reduced no-repository fallbacks for PyMuPDF and pure-Python pypdf environments. Those paths report their reduced fidelity explicitly. Network is only required to fetch a URL; uploaded or local documents can be processed offline.

Development

pip install -e ".[dev]"
pytest -q
python tools/build_standalone.py --check

The tests build synthetic documents and check caption identity, columns, ownership boundaries, stacked figures, text tables, split exhibits, offline HTML, viewer URL normalization, standalone parity, and degraded paths.

Contributions that include a failing layout fixture and a measurable correction are especially useful.

License

MIT

About

Extract complete, reviewable figures and tables from PDF, arXiv, and HTML papers — an installable AI-agent skill and CLI with contact-sheet QA.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages