Skip to content

KikuAI-Lab/Chart2CSV

Repository files navigation

Chart2CSV

Chart2CSV turns chart images into CSV-style data for analysts and operators who need a quick extraction path from visual reports.

Status: Alpha. Verify extracted values against the source chart before using them.

Try the live demo

Docs · Quick start · API request

Illustrative CSV format (not measured output):

label,value
Q1,42
Q2,57

License Python


Quick Start

# In one terminal, set MISTRAL_API_KEY in the environment and start the local API:
python -m uvicorn api.main:app --reload

# In another terminal:
curl -X POST "http://127.0.0.1:8000/v1/extract" \
  -F "file=@chart.png"

Project Structure

Chart2CSV/
├── api/                    # FastAPI REST API
│   └── main.py             # API endpoints
├── chart2csv/              # Core Python package
│   ├── core/               # Extraction logic
│   │   ├── llm_extraction.py   # Mistral-backed extraction
│   │   ├── pipeline.py         # CV pipeline (fallback)
│   │   └── ocr.py              # OCR for axis labels
│   └── cli/                # Command-line interface
├── deploy/                 # Deployment scripts
│   ├── deploy.sh           # Server deployment
│   └── nginx.conf          # Nginx config
├── scripts/                # Development utilities
├── Dockerfile              # Container build
├── docker-compose.yml      # Container orchestration
├── requirements.txt        # Python dependencies
└── setup.py                # Package installation

Features

Feature Description
🧠 Mistral extraction Vision-model extraction path
Automatic extraction Reads supported charts without manual point selection
📊 Multi-Chart Line, scatter, bar charts
🔧 Manual Mode Calibration endpoint for edge cases
🌐 REST API FastAPI endpoints for extraction workflows

Powered by Mistral AI


API Endpoints

Endpoint Description
POST /v1/extract LLM extraction (default)
POST /v1/extract/calibrated Manual calibration
GET /docs Swagger UI
GET /health Health check

Data Handling

The browser demo sends the selected chart image and user-provided API key directly to Mistral. It stores the API key in that browser's localStorage until the field or site data is cleared.

The local API uses MISTRAL_API_KEY for its default LLM-backed extraction path. The CLI uses the local CV/Tesseract path unless --use-mistral is supplied. Mistral-backed modes transmit image data to Mistral.


Installation

pip install -e .

Environment Variables

Variable Description
MISTRAL_API_KEY Mistral AI API key (required for Mistral-backed extraction)

License

AGPL-3.0. Copyright (c) 2025 KikuAI OÜ

Releases

Packages

Used by

Contributors

Languages