Extract structured data from chart and table images using IBM Granite 4.0 3B Vision.
Uses the Granite 4.0 Vision model to convert images of charts and tables into machine readable formats: JSON, CSV, HTML, Python code, or OTSL.
cd /Users/sebastien/Documents/Projects/img2data
# macOS Apple Silicon (MLX acceleration)
uv sync --extra mlx
# Linux/Windows with NVIDIA GPU (CUDA acceleration)
uv sync --extra cuda
# Default: extract table as JSON
uv run img2json.py table.png
# Extract chart data as CSV
uv run img2json.py --csv chart.png
# Generate Python code to recreate a chart
uv run img2json.py --code chart.png
# Generate a text summary of a chart
uv run img2json.py --summary chart.png
# Extract table as HTML
uv run img2json.py --html table.png
# Extract table as OTSL markup
uv run img2json.py --otsl table.png
# Specify custom output file
uv run img2json.py --json table.png -o result.json
| Flag | Model Tag | Output Extension | Description |
|---|---|---|---|
--json (default) | <tables_json> | .json | Table extraction as JSON |
--csv | <chart2csv> | .csv | Chart data as CSV |
--code | <chart2code> | .py | Python code to recreate chart |
--summary | <chart2summary> | .txt | Text summary of chart |
--html | <tables_html> | .html | Table as HTML markup |
--otsl | <tables_otsl> | .otsl | Table as OTSL markup |
By default, the output file is the input filename with the format extension:
chart.png + --csv produces chart.csvtable.jpg + --json produces table.jsonUse -o/--output to override.
The tool auto detects the best available backend:
mlx-community/granite-4.0-3b-vision-4bit (quantized, ~3 GB)ibm-granite/granite-4.0-3b-vision via transformersThe model is downloaded and cached on first run (~3 GB for MLX, larger for transformers).
PNG, JPG, JPEG, TIFF, BMP, WEBP
IBM Granite 4.0 3B Vision: a compact vision language model designed for enterprise grade document data extraction, released under Apache 2.0 license.
1 commits
Python
100.0%
Extract structured data from chart and table images using IBM Granite 4.0 3B Vision.
Uses the Granite 4.0 Vision model to convert images of charts and tables into machine readable formats: JSON, CSV, HTML, Python code, or OTSL.
cd /Users/sebastien/Documents/Projects/img2data
# macOS Apple Silicon (MLX acceleration)
uv sync --extra mlx
# Linux/Windows with NVIDIA GPU (CUDA acceleration)
uv sync --extra cuda
# Default: extract table as JSON
uv run img2json.py table.png
# Extract chart data as CSV
uv run img2json.py --csv chart.png
# Generate Python code to recreate a chart
uv run img2json.py --code chart.png
# Generate a text summary of a chart
uv run img2json.py --summary chart.png
# Extract table as HTML
uv run img2json.py --html table.png
# Extract table as OTSL markup
uv run img2json.py --otsl table.png
# Specify custom output file
uv run img2json.py --json table.png -o result.json
| Flag | Model Tag | Output Extension | Description |
|---|---|---|---|
--json (default) | <tables_json> | .json | Table extraction as JSON |
--csv | <chart2csv> | .csv | Chart data as CSV |
--code | <chart2code> | .py | Python code to recreate chart |
--summary | <chart2summary> | .txt | Text summary of chart |
--html | <tables_html> | .html | Table as HTML markup |
--otsl | <tables_otsl> | .otsl | Table as OTSL markup |
By default, the output file is the input filename with the format extension:
chart.png + --csv produces chart.csvtable.jpg + --json produces table.jsonUse -o/--output to override.
The tool auto detects the best available backend:
mlx-community/granite-4.0-3b-vision-4bit (quantized, ~3 GB)ibm-granite/granite-4.0-3b-vision via transformersThe model is downloaded and cached on first run (~3 GB for MLX, larger for transformers).
PNG, JPG, JPEG, TIFF, BMP, WEBP
IBM Granite 4.0 3B Vision: a compact vision language model designed for enterprise grade document data extraction, released under Apache 2.0 license.
1 commits
Python
100.0%