A computer vision dataset processing library
Project description
DataFlow-CV
๐ Where Vibe Coding meets CV data. Convert, visualize & evaluate datasets โ built with the flow of Claude Code.
A computer vision dataset processing library for seamless format conversion, visualization, and evaluation between YOLO, LabelMe, and COCO annotation formats. Designed for researchers and developers working with multi-format annotation pipelines.
graph LR
A[YOLO<br/>.txt] -->|convert| D[DataFlow-CV]
B[LabelMe<br/>.json] -->|convert| D
C[COCO<br/>.json] -->|convert| D
D -->|visualize| E[๐จ Rendered<br/>Images]
D -->|evaluate| F[๐ mAP / AR<br/>Metrics]
โจ Features
| ๐ Format Conversion | Convert between YOLO, LabelMe, and COCO in any direction โ 6 conversion paths, plus prediction file support with confidence scores | |
| ๐ฏ Detection & Segmentation | Handle both object detection (bbox) and instance segmentation (polygon/RLE) annotations | |
| ๐จ Visualization | Render annotations with OpenCV โ color-coded classes, semi-transparent masks, display & save modes | |
| ๐ Evaluation | COCO-standard 12-metric output (mAP, AP50, AP75, AR) via pycocotools, with per-class breakdowns | |
| ๐ป Command-line Interface | Intuitive CLI with convert, visualize, and evaluate subcommands โ positional args, rich --help |
|
| ๐ Python API | Programmatic access for integration into larger ML pipelines | |
| ๐ Verbose Logging | File-based debug logging with timestamps โ toggle with --verbose |
|
| ๐ฅ๏ธ Headless Mode | Server/Docker-friendly: --no-display + --save for off-screen rendering |
|
| ๐ก๏ธ Flexible Error Handling | Strict mode (abort on error) or lenient mode (skip & continue with warnings) via --no-strict |
๐ฆ Installation
From PyPI
pip install dataflow-cv
From Source
git clone https://github.com/zjykzj/DataFlow-CV.git
cd DataFlow-CV
# Regular installation
pip install .
# Editable installation (for development)
pip install -e .
๐ก Tip: When installed in editable mode, use
python -m dataflow.cliinstead of thedataflow-cvcommand.
Optional Dependencies
| Dependency | Purpose | Install |
|---|---|---|
pycocotools |
COCO RLE segmentation + evaluation | pip install pycocotools |
๐ Quick Start
Command-line Interface
All required parameters (image directories, label directories, class files, output paths) are positional arguments for better usability. Use --help on any subcommand for detailed usage.
๐ Format Conversion
# YOLO โ COCO
dataflow-cv convert yolo2coco images/ yolo_labels/ classes.txt output.json
# YOLO โ COCO (with RLE encoding)
dataflow-cv convert yolo2coco images/ yolo_labels/ classes.txt output.json --do-rle
# YOLO โ LabelMe
dataflow-cv convert yolo2labelme images/ yolo_labels/ classes.txt labelme_json/
# LabelMe โ YOLO
dataflow-cv convert labelme2yolo labelme_json/ classes.txt yolo_labels/
# LabelMe โ COCO
dataflow-cv convert labelme2coco labelme_json/ classes.txt output.json
# COCO โ YOLO
dataflow-cv convert coco2yolo input.json yolo_labels/
# COCO โ LabelMe
dataflow-cv convert coco2labelme input.json labelme_json/
# YOLO predictions โ COCO (with confidence scores)
dataflow-cv convert yolo2coco --prediction images/ yolo_preds/ classes.txt pred.json
# Options
dataflow-cv convert yolo2coco --verbose images/ labels/ classes.txt output.json
dataflow-cv convert yolo2coco --no-strict images/ labels/ classes.txt output.json
๐จ Visualization
# Visualize YOLO annotations
dataflow-cv visualize yolo images/ yolo_labels/ classes.txt --save visualized/
# Visualize LabelMe annotations
dataflow-cv visualize labelme images/ labelme_json/ --save visualized/
# Visualize COCO annotations
dataflow-cv visualize coco images/ coco_annotations.json --save visualized/
# Verbose logging + headless mode
dataflow-cv visualize yolo --verbose --no-display images/ yolo_labels/ classes.txt --save visualized/
๐ Evaluation
Evaluate object detection and instance segmentation model outputs using COCO-standard metrics. Two COCO-format JSON files are required:
| File | Role | Source |
|---|---|---|
anno.json |
Ground Truth (GT) โ reference annotations | yolo2coco (label mode) |
pred.json |
Detection (DT) โ model predictions with score |
yolo2coco --prediction |
โ Preparing Evaluation Data
If your annotations and predictions are in YOLO format, convert them to COCO JSON first:
# Step 1: YOLO ground truth labels โ COCO GT (anno.json)
# Label format: class_id cx cy w h โ 5 tokens (detection)
# class_id x1 y1 ... xn yn โ odd tokens (segmentation)
dataflow-cv convert yolo2coco images/ yolo_labels/ classes.txt anno.json
# Step 2: YOLO predictions โ COCO DT (pred.json)
# Prediction fmt: class_id cx cy w h confidence โ 6 tokens (detection)
# class_id x1 y1 ... xn yn confidence โ even tokens (segmentation)
dataflow-cv convert yolo2coco --prediction images/ yolo_preds/ classes.txt pred.json
โ ๏ธ Important: YOLO label files (GT) use odd token counts, while prediction files (DT) use even token counts with a trailing
confidence. The--predictionflag is required for DT โ it preserves confidence as the COCOscorefield. Mixed label/prediction files in the same directory are not supported.
โก Detection vs Segmentation โ Format Requirements
| Field | Detection GT | Detection DT | Segmentation GT | Segmentation DT |
|---|---|---|---|---|
bbox |
โ Required | โ Required | โ Required (for area) | โ Required (for area) |
score |
โ | โ Required | โ | โ Required |
segmentation |
โ Not required | โ Not required | โ Required | โ Required |
area |
โช Recommended | โช Recommended | โ Required | โ Required |
iscrowd |
โช Optional | โ | โช Optional | โ |
- Object Detection (
iouType='bbox'): Bounding box overlap evaluation. Onlybbox+scoremandatory in DT. - Instance Segmentation (
iouType='segm'): Mask overlap evaluation. GT and DT must includesegmentation(polygon or RLE),area, andbbox.
โข CLI Commands
# Object detection evaluation (bbox IoU)
dataflow-cv evaluate detection anno.json pred.json
# Verbose per-class breakdown
dataflow-cv evaluate detection --verbose anno.json pred.json
# With P/R/F1 at IoU=0.5
dataflow-cv evaluate detection --prf1 --prf1-iou 0.5 anno.json pred.json
# Instance segmentation evaluation (mask IoU)
dataflow-cv evaluate segmentation anno.json pred.json
# Save results as JSON
dataflow-cv evaluate detection --output results.json anno.json pred.json
โฃ End-to-End Workflow
# Complete pipeline: YOLO โ COCO โ Evaluation
dataflow-cv convert yolo2coco images/ yolo_labels/ classes.txt anno.json
dataflow-cv convert yolo2coco --prediction images/ yolo_preds/ classes.txt pred.json
dataflow-cv evaluate detection --verbose --prf1 anno.json pred.json
๐ Python API
from dataflow.convert import YoloAndCocoConverter
from dataflow.visualize import YOLOVisualizer
from dataflow.evaluate import DetectionEvaluator, compute_pr_f1
# โโ Convert โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# YOLO labels โ COCO (label mode)
converter = YoloAndCocoConverter(source_to_target=True, verbose=True, strict_mode=True)
result = converter.convert(
source_path="yolo_labels/", target_path="anno.json",
class_file="classes.txt", image_dir="images/",
)
# YOLO predictions โ COCO (prediction mode)
converter = YoloAndCocoConverter(source_to_target=True, prediction=True)
result = converter.convert(
source_path="yolo_preds/", target_path="pred.json",
class_file="classes.txt", image_dir="images/",
)
# โโ Visualize โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
visualizer = YOLOVisualizer(
label_dir="yolo_labels/", image_dir="images/",
class_file="classes.txt", is_show=True, is_save=True,
output_dir="visualized/", verbose=True, strict_mode=True,
)
result = visualizer.visualize()
# โโ Evaluate โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
evaluator = DetectionEvaluator(verbose=True)
result = evaluator.evaluate("anno.json", "pred.json")
print(f"AP: {result.metrics.ap:.3f}, AP50: {result.metrics.ap50:.3f}")
# Quick P/R/F1 at IoU=0.5
prf1 = compute_pr_f1("anno.json", "pred.json", iou_threshold=0.5)
print(f"F1: {prf1.overall.f1_score:.3f}")
๐ See the
samples/directory for complete examples:samples/visualize/(YOLO, LabelMe, COCO demos),samples/convert/(conversion examples).
๐ Documentation
| Resource | Description |
|---|---|
| CLAUDE.md | Architecture overview, development guide, and known gotchas |
| CHANGELOG.md | Version history and breaking changes |
| specs/evaluate/ | Evaluation metric contracts โ IoU, matching, AP/mAP/AR |
| specs/formats/ | External format contracts โ YOLO, LabelMe, COCO, conversion rules |
| specs/modules/ | Internal module architecture, interface contracts, dependency constraints |
๐ก Key Concepts
- Format-Native Coordinates: Coordinates stored in each format's native representation โ YOLO normalized [0,1] center-based, LabelMe/COCO absolute pixels top-left. Check
DatasetAnnotations.formatto determine semantics. - Explicit Coordinate Transforms: Converters handle all coordinate transformations between formats โ no hidden normalization.
- Strict Mode: Validation errors raise exceptions by default. Disable with
--no-strict(CLI) orstrict_mode=False(API). - Verbose Logging: Detailed debug logs saved to files when
--verboseis used. The CLI prints the log file path after each operation. - Headless Support: Use
--no-displayfor servers/Docker; pair with--saveto output visualization images without a window. - Keyboard Shortcuts: During visualization โ
q/ESCto exit,Enter/Spaceto advance, any other key to continue. - Color Management: Each class ID gets a unique color from an HSV-based palette (up to 1000 classes) for consistent visualization.
- Evaluation Metrics: COCO-standard 12-metric output with optional per-class breakdown and P/R/F1 computation.
- Prediction Files: YOLO prediction files (6 tokens detection, even tokens segmentation) differ from label files (5/odd tokens). Use
--predictionflag.
๐ง Development
For detailed developer guidance including advanced test commands, debugging, and architecture overview, see CLAUDE.md.
๐งช Testing
370 tests, 75% code coverage.
pytest # All tests
pytest --cov=dataflow --cov-report=term # With coverage
pytest tests/convert/test_yolo_and_coco.py # Single module
pytest tests/evaluate/test_evaluator.py # Single module
๐ Coverage by module
| Module | Coverage | Highlights |
|---|---|---|
dataflow/label/ |
68% | models (87%), coco_handler (74%), labelme_handler (72%), yolo_handler (57%) |
dataflow/convert/ |
84% | yolo_and_coco (89%), labelme_and_yolo (93%), coco_and_labelme (88%), rle (81%) |
dataflow/visualize/ |
81% | yolo_vis (97%), labelme_vis (100%), coco_vis (97%), base (80%) |
dataflow/evaluate/ |
88% | evaluator (100%), metrics (96%), result (99%), base (91%), utils (69%) |
dataflow/cli/ |
59% | main (96%), convert cmd (48%), evaluate cmd (24%), visualize cmd (84%), utils (86%) |
dataflow/util/ |
93% | logging (99%), file_util (84%) |
๐จ Code Quality
pip install -e .[dev] # Install dev dependencies
black dataflow tests samples # Format
isort dataflow tests samples # Sort imports
mypy dataflow # Type check
flake8 dataflow tests samples # Lint
๐ Pre-commit Hooks (Optional)
pip install pre-commit
pre-commit install # Install git hooks (run once)
# After this, every `git commit` auto-runs:
# black โ isort โ flake8 โ whitespace checks
pre-commit run --all-files # Manual run against all files
๐ Project Structure
dataflow/
โโโ label/ # Annotation handlers + data models
โโโ convert/ # Format converters + RLE utility
โโโ visualize/ # OpenCV-based rendering
โโโ evaluate/ # pycocotools-based metrics
โโโ util/ # Logging & file utilities
โโโ cli/ # CLI entry point, commands, validation
tests/ # Unit & integration tests
samples/ # Python API usage examples
assets/ # Test data (det/seg by format)
specs/ # Canonical specifications (evaluate/ + formats/ + modules/)
๐ค Contributing
Contributions are welcome! Please review CLAUDE.md for architecture and development patterns before contributing.
- ๐ด Fork the repository
- ๐ฟ Create a feature branch
- โ๏ธ Make your changes
- ๐งช Add or update tests as needed
- โ Ensure code passes formatting and linting checks
- ๐ฌ Submit a pull request
๐ License
This project is licensed under the MIT License โ see LICENSE for details.
๐ Acknowledgments
- Thanks to the creators of YOLO, LabelMe, and COCO formats for establishing these annotation standards
- Built with OpenCV, NumPy, Click, and pycocotools
- Inspired by the need for seamless format conversion in multi-tool CV pipelines
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dataflow_cv-1.2.0.tar.gz.
File metadata
- Download URL: dataflow_cv-1.2.0.tar.gz
- Upload date:
- Size: 79.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d2dbf6b206b51b7b47fad32f16c1d872848da45a1ef50d7726f637b223571dc
|
|
| MD5 |
9c4053c64da731031c02defbc7ebf9e4
|
|
| BLAKE2b-256 |
d4a100656c66e738577ed8f317b831883af00c75f637cce49f2346cc5b8edf04
|
Provenance
The following attestation bundles were made for dataflow_cv-1.2.0.tar.gz:
Publisher:
python-publish.yml on zjykzj/DataFlow-CV
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dataflow_cv-1.2.0.tar.gz -
Subject digest:
4d2dbf6b206b51b7b47fad32f16c1d872848da45a1ef50d7726f637b223571dc - Sigstore transparency entry: 1790374052
- Sigstore integration time:
-
Permalink:
zjykzj/DataFlow-CV@5ff8db36d74b827d5b2ced71eb619bac1a9f6de3 -
Branch / Tag:
refs/tags/v1.2.0 - Owner: https://github.com/zjykzj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@5ff8db36d74b827d5b2ced71eb619bac1a9f6de3 -
Trigger Event:
release
-
Statement type:
File details
Details for the file dataflow_cv-1.2.0-py3-none-any.whl.
File metadata
- Download URL: dataflow_cv-1.2.0-py3-none-any.whl
- Upload date:
- Size: 94.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe7dc774b6fd72f8269982f7d91a8728f1359f00f132b708961f8fbd72e36e37
|
|
| MD5 |
e2f601217f99599ebe1362bb2cd567fe
|
|
| BLAKE2b-256 |
01d3cd1cc0b1d34c9362436299dca9be4c747f41495bacf6db2a388b9771a1b4
|
Provenance
The following attestation bundles were made for dataflow_cv-1.2.0-py3-none-any.whl:
Publisher:
python-publish.yml on zjykzj/DataFlow-CV
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dataflow_cv-1.2.0-py3-none-any.whl -
Subject digest:
fe7dc774b6fd72f8269982f7d91a8728f1359f00f132b708961f8fbd72e36e37 - Sigstore transparency entry: 1790374063
- Sigstore integration time:
-
Permalink:
zjykzj/DataFlow-CV@5ff8db36d74b827d5b2ced71eb619bac1a9f6de3 -
Branch / Tag:
refs/tags/v1.2.0 - Owner: https://github.com/zjykzj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@5ff8db36d74b827d5b2ced71eb619bac1a9f6de3 -
Trigger Event:
release
-
Statement type: