Cover the problem, the approach, how to run it and its measured limitations, and correct what no longer matched the code (the --mode flag, the .env file, the training directory). Update CLAUDE.md to the new layout and commands. Co-Authored-By: Claude Opus 5.5 <[email protected]>
51 lines
2.9 KiB
Markdown
51 lines
2.9 KiB
Markdown
# CLAUDE.md
|
||
|
||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||
|
||
## Project Overview
|
||
|
||
A computer vision pipeline that extracts rowing machine workout data (time, distance) from photos of Concept 2 PM5 displays: screen detection, classification, then Tesseract OCR with majority voting. A Claude vision reader produces the reference readings the OCR is validated against. See README.md for the approach and measured limitations.
|
||
|
||
## Layout
|
||
|
||
```
|
||
src/rowing_stats/
|
||
cli.py `rowing-stats <command>` dispatcher; imports a command's module lazily
|
||
crop.py find_screen / perspective_correct / crop_screen; CropParams holds the tuned defaults
|
||
classifier.py feature-based scorer and CNN (torch imported lazily)
|
||
ocr.py tesseract subprocess, preprocessing variants, validation report
|
||
parsing.py pure vote counting over OCR text (no image code)
|
||
claude.py Claude Haiku reader, reply parsing, sanity bounds
|
||
tune.py Optuna search over CropParams, scored by the CNN
|
||
results.py results CSV rows, pace/calories, reference loading
|
||
images.py list_images / read_image / open_image
|
||
errors.py RowingStatsError hierarchy
|
||
tests/ pytest; Tesseract and the Claude client are faked
|
||
photos/ source photos
|
||
train/0, train/1 CNN training crops (not rowing / rowing)
|
||
rowing_results.csv reference readings from the Claude reader
|
||
screen_classifier_model.pth trained CNN weights
|
||
```
|
||
|
||
## Commands
|
||
|
||
```bash
|
||
pip install -r requirements-dev.txt && pip install -e .
|
||
pytest
|
||
|
||
rowing-stats crop photos/ cropped/
|
||
rowing-stats classify predict --dir cropped/ [--model cnn]
|
||
rowing-stats classify train --data-dir train/
|
||
rowing-stats ocr --dir cropped/ --validate rowing_results.csv
|
||
rowing-stats claude --dir photos/ --output rowing_results.csv # requires ANTHROPIC_API_KEY
|
||
rowing-stats tune --n-trials 300 --photos-dir photos/
|
||
```
|
||
|
||
## Key Details
|
||
|
||
- Dependencies are pinned in `requirements*.txt` (core, `-claude`, `-ml`, `-dev`) with matching extras in `pyproject.toml`. `anthropic`, `torch`, `torchvision` and `optuna` are optional and must stay lazily imported.
|
||
- Raise a `RowingStatsError` subclass rather than printing or exiting from library code. `SetupError` subclasses mean every file would fail, so CLIs stop on them; anything else is reported per file and the batch continues.
|
||
- The crop parameters, preprocessing variants and vote counting are tuned to the sample photos. A refactor should leave `rowing-stats crop` output byte-identical and the per-image lines of `rowing-stats ocr --validate` unchanged.
|
||
- The Claude call uses `claude-haiku-4-5-20251001`. Validation bounds in claude.py mirror a Go handler (`handle_rowing.go`): distance 100–100k metres, time 30s–2hrs, pace 1:20–2:30 /500m.
|
||
- `.env` is gitignored but nothing loads it; the Claude reader takes its key from the environment.
|