dataflow-cv 1.3.0__tar.gz → 1.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dataflow_cv-1.3.0/dataflow_cv.egg-info → dataflow_cv-1.4.0}/PKG-INFO +40 -73
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/README.md +38 -67
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/__init__.py +1 -1
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/cli/commands/convert.py +68 -68
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/cli/commands/evaluate.py +88 -92
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/cli/commands/utils.py +10 -21
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/cli/commands/visualize.py +50 -71
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/cli/main.py +1 -7
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/convert/base.py +25 -31
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/convert/coco_and_labelme.py +5 -6
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/convert/labelme_and_yolo.py +5 -6
- dataflow_cv-1.4.0/dataflow/convert/log_templates.py +93 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/convert/yolo_and_coco.py +3 -3
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/evaluate/base.py +26 -38
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/evaluate/evaluator.py +10 -28
- dataflow_cv-1.4.0/dataflow/evaluate/log_templates.py +208 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/evaluate/metrics.py +9 -4
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/evaluate/result.py +1 -1
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/evaluate/utils.py +14 -126
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/label/base.py +3 -3
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/label/coco_handler.py +0 -2
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/label/labelme_handler.py +4 -10
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/label/yolo_handler.py +9 -28
- dataflow_cv-1.4.0/dataflow/util/__init__.py +14 -0
- dataflow_cv-1.4.0/dataflow/util/logging.py +319 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/visualize/base.py +43 -74
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/visualize/coco_visualizer.py +8 -9
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/visualize/labelme_visualizer.py +4 -4
- dataflow_cv-1.4.0/dataflow/visualize/log_templates.py +100 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/visualize/yolo_visualizer.py +8 -9
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0/dataflow_cv.egg-info}/PKG-INFO +40 -73
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow_cv.egg-info/SOURCES.txt +4 -2
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow_cv.egg-info/requires.txt +0 -5
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/pyproject.toml +2 -11
- dataflow_cv-1.3.0/dataflow/util/__init__.py +0 -10
- dataflow_cv-1.3.0/dataflow/util/file_util.py +0 -128
- dataflow_cv-1.3.0/dataflow/util/logging_util.py +0 -338
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/LICENSE +0 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/cli/__init__.py +0 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/cli/commands/__init__.py +0 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/cli/exceptions.py +0 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/convert/__init__.py +0 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/convert/rle_converter.py +0 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/convert/utils.py +0 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/evaluate/__init__.py +0 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/label/__init__.py +0 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/label/models.py +0 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/label/utils.py +0 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/visualize/__init__.py +0 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow/visualize/utils.py +0 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow_cv.egg-info/dependency_links.txt +0 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow_cv.egg-info/entry_points.txt +0 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow_cv.egg-info/not-zip-safe +0 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/dataflow_cv.egg-info/top_level.txt +0 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.4.0}/setup.cfg +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dataflow-cv
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.0
|
|
4
4
|
Summary: A computer vision dataset processing library
|
|
5
|
-
Author
|
|
5
|
+
Author: DataFlow-CV Team
|
|
6
6
|
License: MIT
|
|
7
7
|
Project-URL: Bug Reports, https://github.com/zjykzj/DataFlow-CV/issues
|
|
8
8
|
Project-URL: Source, https://github.com/zjykzj/DataFlow-CV
|
|
@@ -35,10 +35,6 @@ Requires-Dist: black>=22.0.0; extra == "dev"
|
|
|
35
35
|
Requires-Dist: isort>=5.12.0; extra == "dev"
|
|
36
36
|
Requires-Dist: flake8>=6.0.0; extra == "dev"
|
|
37
37
|
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
38
|
-
Requires-Dist: pylint>=3.0.0; extra == "dev"
|
|
39
|
-
Provides-Extra: docs
|
|
40
|
-
Requires-Dist: sphinx>=7.0.0; extra == "docs"
|
|
41
|
-
Requires-Dist: sphinx-rtd-theme>=1.3.0; extra == "docs"
|
|
42
38
|
Dynamic: license-file
|
|
43
39
|
|
|
44
40
|
# DataFlow-CV
|
|
@@ -54,66 +50,36 @@ Dynamic: license-file
|
|
|
54
50
|
<img src="https://img.shields.io/badge/Linux-Supported-fcc624?logo=linux" alt="Linux">
|
|
55
51
|
<img src="https://img.shields.io/badge/Windows-Supported-00a2e8?logo=windows" alt="Windows">
|
|
56
52
|
<img src="https://img.shields.io/badge/macOS-Supported-999999?logo=apple" alt="macOS">
|
|
53
|
+
<img src="https://img.shields.io/badge/YOLO-.txt-00a86b?style=flat-square" alt="YOLO">
|
|
54
|
+
<img src="https://img.shields.io/badge/LabelMe-.json-f39c12?style=flat-square" alt="LabelMe">
|
|
55
|
+
<img src="https://img.shields.io/badge/COCO-.json-e74c3c?style=flat-square" alt="COCO">
|
|
57
56
|
</p>
|
|
58
57
|
|
|
59
|
-
A computer vision dataset processing library
|
|
60
|
-
|
|
61
|
-
```mermaid
|
|
62
|
-
graph LR
|
|
63
|
-
A[YOLO<br/>.txt] -->|convert| D[DataFlow-CV]
|
|
64
|
-
B[LabelMe<br/>.json] -->|convert| D
|
|
65
|
-
C[COCO<br/>.json] -->|convert| D
|
|
66
|
-
D -->|visualize| E[🎨 Rendered<br/>Images]
|
|
67
|
-
D -->|evaluate| F[📊 mAP / AR<br/>Metrics]
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
---
|
|
71
|
-
|
|
72
|
-
## ✨ Features
|
|
58
|
+
A computer vision dataset processing library — convert, visualize, and evaluate annotations across YOLO, LabelMe, and COCO formats.
|
|
73
59
|
|
|
74
60
|
| | | |
|
|
75
61
|
|:---|:---|:---|
|
|
76
|
-
| 🔄 **
|
|
77
|
-
|
|
|
78
|
-
|
|
|
79
|
-
|
|
|
80
|
-
| 💻 **Command-line Interface** | Intuitive CLI with `convert`, `visualize`, and `evaluate` subcommands — positional args, rich `--help` |
|
|
81
|
-
| 🐍 **Python API** | Programmatic access for integration into larger ML pipelines |
|
|
82
|
-
| 📝 **Verbose Logging** | File-based debug logging with timestamps — toggle with `--verbose` |
|
|
83
|
-
| 🖥️ **Headless Mode** | Server/Docker-friendly: `--no-display` + `--save` for off-screen rendering |
|
|
84
|
-
| 🛡️ **Flexible Error Handling** | Strict mode (abort on error) or lenient mode (skip & continue with warnings) via `--no-strict` |
|
|
62
|
+
| 🔄 **Convert** | 6 directions: YOLO ↔ LabelMe ↔ COCO, plus model predictions | `dataflow-cv convert yolo2coco ...` |
|
|
63
|
+
| 🎨 **Visualize** | OpenCV rendering with color-coded classes, display & save modes | `dataflow-cv visualize yolo ...` |
|
|
64
|
+
| 📊 **Evaluate** | COCO mAP via pycocotools, single-threshold P/R/F1 per class | `dataflow-cv evaluate detection ...` |
|
|
65
|
+
| 💻 **CLI + API** | Click-based CLI with rich `--help`; Python API for pipelines | `from dataflow.convert import ...` |
|
|
85
66
|
|
|
86
67
|
---
|
|
87
68
|
|
|
88
69
|
## 📦 Installation
|
|
89
70
|
|
|
90
|
-
### From PyPI
|
|
91
|
-
|
|
92
71
|
```bash
|
|
93
|
-
pip install dataflow-cv
|
|
72
|
+
pip install dataflow-cv # from PyPI
|
|
73
|
+
pip install pycocotools # optional: COCO RLE + evaluation
|
|
94
74
|
```
|
|
95
75
|
|
|
96
|
-
|
|
76
|
+
Or from source:
|
|
97
77
|
|
|
98
78
|
```bash
|
|
99
79
|
git clone https://github.com/zjykzj/DataFlow-CV.git
|
|
100
|
-
cd DataFlow-CV
|
|
101
|
-
|
|
102
|
-
# Regular installation
|
|
103
|
-
pip install .
|
|
104
|
-
|
|
105
|
-
# Editable installation (for development)
|
|
106
|
-
pip install -e .
|
|
80
|
+
cd DataFlow-CV && pip install .
|
|
107
81
|
```
|
|
108
82
|
|
|
109
|
-
> 💡 **Tip**: When installed in editable mode, use `python -m dataflow.cli` instead of the `dataflow-cv` command.
|
|
110
|
-
|
|
111
|
-
### Optional Dependencies
|
|
112
|
-
|
|
113
|
-
| Dependency | Purpose | Install |
|
|
114
|
-
|-----------|---------|---------|
|
|
115
|
-
| `pycocotools` | COCO RLE segmentation + evaluation | `pip install pycocotools` |
|
|
116
|
-
|
|
117
83
|
---
|
|
118
84
|
|
|
119
85
|
## 🚀 Quick Start
|
|
@@ -221,11 +187,11 @@ dataflow-cv evaluate detection anno.json pred.json
|
|
|
221
187
|
# Verbose per-class breakdown
|
|
222
188
|
dataflow-cv evaluate detection --verbose anno.json pred.json
|
|
223
189
|
|
|
224
|
-
#
|
|
225
|
-
dataflow-cv evaluate detection --prf1
|
|
190
|
+
# P/R/F1 only (skips mAP computation) — default: macro averaging
|
|
191
|
+
dataflow-cv evaluate detection --prf1 anno.json pred.json
|
|
226
192
|
|
|
227
|
-
#
|
|
228
|
-
dataflow-cv evaluate detection --prf1 --prf1-method micro anno.json pred.json
|
|
193
|
+
# P/R/F1 with custom IoU threshold and micro averaging
|
|
194
|
+
dataflow-cv evaluate detection --prf1 --prf1-iou 0.75 --prf1-method micro anno.json pred.json
|
|
229
195
|
|
|
230
196
|
# Instance segmentation evaluation (mask IoU)
|
|
231
197
|
dataflow-cv evaluate segmentation anno.json pred.json
|
|
@@ -240,19 +206,22 @@ dataflow-cv evaluate detection --output results.json anno.json pred.json
|
|
|
240
206
|
# Complete pipeline: YOLO → COCO → Evaluation
|
|
241
207
|
dataflow-cv convert yolo2coco images/ yolo_labels/ classes.txt anno.json
|
|
242
208
|
dataflow-cv convert yolo2coco --prediction images/ yolo_preds/ classes.txt pred.json
|
|
243
|
-
dataflow-cv evaluate detection --verbose
|
|
209
|
+
dataflow-cv evaluate detection --verbose anno.json pred.json # mAP
|
|
210
|
+
dataflow-cv evaluate detection --prf1 anno.json pred.json # P/R/F1
|
|
244
211
|
```
|
|
245
212
|
|
|
246
213
|
### 🐍 Python API
|
|
247
214
|
|
|
248
215
|
```python
|
|
216
|
+
from dataflow.util.logging import LogConfig
|
|
249
217
|
from dataflow.convert import YoloAndCocoConverter
|
|
250
218
|
from dataflow.visualize import YOLOVisualizer
|
|
251
219
|
from dataflow.evaluate import DetectionEvaluator, compute_pr_f1
|
|
252
220
|
|
|
253
221
|
# ── Convert ──────────────────────────────────────────
|
|
254
222
|
# YOLO labels → COCO (label mode)
|
|
255
|
-
|
|
223
|
+
log_cfg = LogConfig(name="convert", verbose=True)
|
|
224
|
+
converter = YoloAndCocoConverter(source_to_target=True, log_config=log_cfg, strict_mode=True)
|
|
256
225
|
result = converter.convert(
|
|
257
226
|
source_path="yolo_labels/", target_path="anno.json",
|
|
258
227
|
class_file="classes.txt", image_dir="images/",
|
|
@@ -269,12 +238,12 @@ result = converter.convert(
|
|
|
269
238
|
visualizer = YOLOVisualizer(
|
|
270
239
|
label_dir="yolo_labels/", image_dir="images/",
|
|
271
240
|
class_file="classes.txt", is_show=True, is_save=True,
|
|
272
|
-
output_dir="visualized/",
|
|
241
|
+
output_dir="visualized/", log_config=log_cfg,
|
|
273
242
|
)
|
|
274
243
|
result = visualizer.visualize()
|
|
275
244
|
|
|
276
245
|
# ── Evaluate ─────────────────────────────────────────
|
|
277
|
-
evaluator = DetectionEvaluator(verbose=True)
|
|
246
|
+
evaluator = DetectionEvaluator(log_config=LogConfig(name="eval", verbose=True))
|
|
278
247
|
result = evaluator.evaluate("anno.json", "pred.json")
|
|
279
248
|
print(f"AP: {result.metrics.ap:.3f}, AP50: {result.metrics.ap50:.3f}")
|
|
280
249
|
|
|
@@ -291,7 +260,7 @@ prf1 = compute_pr_f1("anno_segm.json", "pred_segm.json", iou_type="segm")
|
|
|
291
260
|
print(f"Segm F1: {prf1.overall.f1_score:.3f}")
|
|
292
261
|
```
|
|
293
262
|
|
|
294
|
-
> 📂 See the `samples/` directory for complete examples: `samples/visualize/` (YOLO, LabelMe, COCO
|
|
263
|
+
> 📂 See the `samples/` directory for complete examples: `samples/convert/` (6 conversion directions), `samples/visualize/` (YOLO, LabelMe, COCO), `samples/evaluate/` (detection & segmentation), `samples/cli/` (CLI workflows).
|
|
295
264
|
|
|
296
265
|
---
|
|
297
266
|
|
|
@@ -307,15 +276,13 @@ print(f"Segm F1: {prf1.overall.f1_score:.3f}")
|
|
|
307
276
|
|
|
308
277
|
### 💡 Key Concepts
|
|
309
278
|
|
|
310
|
-
- **Format-Native Coordinates**:
|
|
311
|
-
- **
|
|
312
|
-
- **
|
|
313
|
-
- **
|
|
314
|
-
- **
|
|
315
|
-
- **
|
|
316
|
-
- **
|
|
317
|
-
- **Evaluation Metrics**: COCO-standard 12-metric output with optional per-class breakdown. P/R/F1 supports both macro (default) and micro averaging, and both bbox and mask IoU.
|
|
318
|
-
- **Prediction Files**: YOLO prediction files use 6 tokens (detection) or even tokens (segmentation) vs 5/odd for labels. `--prediction` outputs a plain JSON list of annotation dicts — the standard prediction exchange format compatible with pycocotools `loadRes()`.
|
|
279
|
+
- **Format-Native Coordinates**: YOLO uses normalized [0,1] center-based coordinates; LabelMe and COCO use absolute pixel top-left. There is no hidden internal normalization — check `DatasetAnnotations.format` to interpret coordinate semantics.
|
|
280
|
+
- **Strict Mode** (default): Validation errors raise exceptions immediately. Disable with `--no-strict` (CLI) or `strict_mode=False` (API) to skip invalid annotations and continue.
|
|
281
|
+
- **Verbose Logging**: `--verbose` enables per-module file logging via `LogManager` — console shows INFO-level progress, log files capture DEBUG details. All logging is owned by modules; the CLI uses `click.echo()` for terminal output.
|
|
282
|
+
- **Headless Support**: Use `--no-display` for servers/Docker — pair with `--save` to render visualization images without a GUI window.
|
|
283
|
+
- **Keyboard Shortcuts** (visualization): `q` / `ESC` to exit, `Enter` / `Space` to advance, any other key to continue.
|
|
284
|
+
- **Evaluation**: `--prf1` computes P/R/F1 only (single-threshold, per-class TP/FP/FN) — skips the full COCOeval mAP pipeline for speed. Supports macro/micro averaging and bbox/mask IoU. Run without `--prf1` for standard COCO mAP. For both metrics, run twice.
|
|
285
|
+
- **Prediction Files**: YOLO predictions use 6 tokens (detection) or even tokens (segmentation) vs 5/odd for labels. Use `--prediction` with `yolo2coco` — outputs a plain JSON list of annotation dicts compatible with pycocotools `loadRes()`.
|
|
319
286
|
|
|
320
287
|
---
|
|
321
288
|
|
|
@@ -325,7 +292,7 @@ For detailed developer guidance including advanced test commands, debugging, and
|
|
|
325
292
|
|
|
326
293
|
### 🧪 Testing
|
|
327
294
|
|
|
328
|
-
**
|
|
295
|
+
**418 tests, 76% code coverage (3986 statements).**
|
|
329
296
|
|
|
330
297
|
```bash
|
|
331
298
|
pytest # All tests
|
|
@@ -344,7 +311,7 @@ pytest tests/evaluate/test_evaluator.py # Single module
|
|
|
344
311
|
| `dataflow/visualize/` | 81% | yolo_vis (100%), labelme_vis (100%), coco_vis (97%), base (74%) |
|
|
345
312
|
| `dataflow/evaluate/` | 87% | evaluator (100%), metrics (93%), result (99%), base (91%), utils (68%) |
|
|
346
313
|
| `dataflow/cli/` | 59% | main (96%), convert cmd (48%), evaluate cmd (24%), visualize cmd (84%), utils (86%) |
|
|
347
|
-
| `dataflow/util/` | 93% | logging (98%)
|
|
314
|
+
| `dataflow/util/` | 93% | logging (98%) |
|
|
348
315
|
|
|
349
316
|
</details>
|
|
350
317
|
|
|
@@ -375,12 +342,12 @@ pre-commit run --all-files # Manual run against all files
|
|
|
375
342
|
```
|
|
376
343
|
dataflow/
|
|
377
344
|
├── label/ # Annotation handlers + data models
|
|
378
|
-
├── convert/ # Format converters
|
|
379
|
-
├── visualize/ # OpenCV-based rendering
|
|
380
|
-
├── evaluate/ # pycocotools-based metrics
|
|
381
|
-
├── util/ #
|
|
345
|
+
├── convert/ # Format converters, RLE utility, log templates
|
|
346
|
+
├── visualize/ # OpenCV-based rendering, log templates
|
|
347
|
+
├── evaluate/ # pycocotools-based metrics, log templates
|
|
348
|
+
├── util/ # Unified logging (LogManager + format helpers)
|
|
382
349
|
└── cli/ # CLI entry point, commands, validation
|
|
383
|
-
tests/ # Unit & integration tests
|
|
350
|
+
tests/ # Unit & integration tests (418 tests, conftest fixtures)
|
|
384
351
|
samples/ # Python API usage examples
|
|
385
352
|
assets/ # Test data (det/seg by format)
|
|
386
353
|
specs/ # Canonical specifications (evaluate/ + formats/ + modules/)
|
|
@@ -11,66 +11,36 @@
|
|
|
11
11
|
<img src="https://img.shields.io/badge/Linux-Supported-fcc624?logo=linux" alt="Linux">
|
|
12
12
|
<img src="https://img.shields.io/badge/Windows-Supported-00a2e8?logo=windows" alt="Windows">
|
|
13
13
|
<img src="https://img.shields.io/badge/macOS-Supported-999999?logo=apple" alt="macOS">
|
|
14
|
+
<img src="https://img.shields.io/badge/YOLO-.txt-00a86b?style=flat-square" alt="YOLO">
|
|
15
|
+
<img src="https://img.shields.io/badge/LabelMe-.json-f39c12?style=flat-square" alt="LabelMe">
|
|
16
|
+
<img src="https://img.shields.io/badge/COCO-.json-e74c3c?style=flat-square" alt="COCO">
|
|
14
17
|
</p>
|
|
15
18
|
|
|
16
|
-
A computer vision dataset processing library
|
|
17
|
-
|
|
18
|
-
```mermaid
|
|
19
|
-
graph LR
|
|
20
|
-
A[YOLO<br/>.txt] -->|convert| D[DataFlow-CV]
|
|
21
|
-
B[LabelMe<br/>.json] -->|convert| D
|
|
22
|
-
C[COCO<br/>.json] -->|convert| D
|
|
23
|
-
D -->|visualize| E[🎨 Rendered<br/>Images]
|
|
24
|
-
D -->|evaluate| F[📊 mAP / AR<br/>Metrics]
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
---
|
|
28
|
-
|
|
29
|
-
## ✨ Features
|
|
19
|
+
A computer vision dataset processing library — convert, visualize, and evaluate annotations across YOLO, LabelMe, and COCO formats.
|
|
30
20
|
|
|
31
21
|
| | | |
|
|
32
22
|
|:---|:---|:---|
|
|
33
|
-
| 🔄 **
|
|
34
|
-
|
|
|
35
|
-
|
|
|
36
|
-
|
|
|
37
|
-
| 💻 **Command-line Interface** | Intuitive CLI with `convert`, `visualize`, and `evaluate` subcommands — positional args, rich `--help` |
|
|
38
|
-
| 🐍 **Python API** | Programmatic access for integration into larger ML pipelines |
|
|
39
|
-
| 📝 **Verbose Logging** | File-based debug logging with timestamps — toggle with `--verbose` |
|
|
40
|
-
| 🖥️ **Headless Mode** | Server/Docker-friendly: `--no-display` + `--save` for off-screen rendering |
|
|
41
|
-
| 🛡️ **Flexible Error Handling** | Strict mode (abort on error) or lenient mode (skip & continue with warnings) via `--no-strict` |
|
|
23
|
+
| 🔄 **Convert** | 6 directions: YOLO ↔ LabelMe ↔ COCO, plus model predictions | `dataflow-cv convert yolo2coco ...` |
|
|
24
|
+
| 🎨 **Visualize** | OpenCV rendering with color-coded classes, display & save modes | `dataflow-cv visualize yolo ...` |
|
|
25
|
+
| 📊 **Evaluate** | COCO mAP via pycocotools, single-threshold P/R/F1 per class | `dataflow-cv evaluate detection ...` |
|
|
26
|
+
| 💻 **CLI + API** | Click-based CLI with rich `--help`; Python API for pipelines | `from dataflow.convert import ...` |
|
|
42
27
|
|
|
43
28
|
---
|
|
44
29
|
|
|
45
30
|
## 📦 Installation
|
|
46
31
|
|
|
47
|
-
### From PyPI
|
|
48
|
-
|
|
49
32
|
```bash
|
|
50
|
-
pip install dataflow-cv
|
|
33
|
+
pip install dataflow-cv # from PyPI
|
|
34
|
+
pip install pycocotools # optional: COCO RLE + evaluation
|
|
51
35
|
```
|
|
52
36
|
|
|
53
|
-
|
|
37
|
+
Or from source:
|
|
54
38
|
|
|
55
39
|
```bash
|
|
56
40
|
git clone https://github.com/zjykzj/DataFlow-CV.git
|
|
57
|
-
cd DataFlow-CV
|
|
58
|
-
|
|
59
|
-
# Regular installation
|
|
60
|
-
pip install .
|
|
61
|
-
|
|
62
|
-
# Editable installation (for development)
|
|
63
|
-
pip install -e .
|
|
41
|
+
cd DataFlow-CV && pip install .
|
|
64
42
|
```
|
|
65
43
|
|
|
66
|
-
> 💡 **Tip**: When installed in editable mode, use `python -m dataflow.cli` instead of the `dataflow-cv` command.
|
|
67
|
-
|
|
68
|
-
### Optional Dependencies
|
|
69
|
-
|
|
70
|
-
| Dependency | Purpose | Install |
|
|
71
|
-
|-----------|---------|---------|
|
|
72
|
-
| `pycocotools` | COCO RLE segmentation + evaluation | `pip install pycocotools` |
|
|
73
|
-
|
|
74
44
|
---
|
|
75
45
|
|
|
76
46
|
## 🚀 Quick Start
|
|
@@ -178,11 +148,11 @@ dataflow-cv evaluate detection anno.json pred.json
|
|
|
178
148
|
# Verbose per-class breakdown
|
|
179
149
|
dataflow-cv evaluate detection --verbose anno.json pred.json
|
|
180
150
|
|
|
181
|
-
#
|
|
182
|
-
dataflow-cv evaluate detection --prf1
|
|
151
|
+
# P/R/F1 only (skips mAP computation) — default: macro averaging
|
|
152
|
+
dataflow-cv evaluate detection --prf1 anno.json pred.json
|
|
183
153
|
|
|
184
|
-
#
|
|
185
|
-
dataflow-cv evaluate detection --prf1 --prf1-method micro anno.json pred.json
|
|
154
|
+
# P/R/F1 with custom IoU threshold and micro averaging
|
|
155
|
+
dataflow-cv evaluate detection --prf1 --prf1-iou 0.75 --prf1-method micro anno.json pred.json
|
|
186
156
|
|
|
187
157
|
# Instance segmentation evaluation (mask IoU)
|
|
188
158
|
dataflow-cv evaluate segmentation anno.json pred.json
|
|
@@ -197,19 +167,22 @@ dataflow-cv evaluate detection --output results.json anno.json pred.json
|
|
|
197
167
|
# Complete pipeline: YOLO → COCO → Evaluation
|
|
198
168
|
dataflow-cv convert yolo2coco images/ yolo_labels/ classes.txt anno.json
|
|
199
169
|
dataflow-cv convert yolo2coco --prediction images/ yolo_preds/ classes.txt pred.json
|
|
200
|
-
dataflow-cv evaluate detection --verbose
|
|
170
|
+
dataflow-cv evaluate detection --verbose anno.json pred.json # mAP
|
|
171
|
+
dataflow-cv evaluate detection --prf1 anno.json pred.json # P/R/F1
|
|
201
172
|
```
|
|
202
173
|
|
|
203
174
|
### 🐍 Python API
|
|
204
175
|
|
|
205
176
|
```python
|
|
177
|
+
from dataflow.util.logging import LogConfig
|
|
206
178
|
from dataflow.convert import YoloAndCocoConverter
|
|
207
179
|
from dataflow.visualize import YOLOVisualizer
|
|
208
180
|
from dataflow.evaluate import DetectionEvaluator, compute_pr_f1
|
|
209
181
|
|
|
210
182
|
# ── Convert ──────────────────────────────────────────
|
|
211
183
|
# YOLO labels → COCO (label mode)
|
|
212
|
-
|
|
184
|
+
log_cfg = LogConfig(name="convert", verbose=True)
|
|
185
|
+
converter = YoloAndCocoConverter(source_to_target=True, log_config=log_cfg, strict_mode=True)
|
|
213
186
|
result = converter.convert(
|
|
214
187
|
source_path="yolo_labels/", target_path="anno.json",
|
|
215
188
|
class_file="classes.txt", image_dir="images/",
|
|
@@ -226,12 +199,12 @@ result = converter.convert(
|
|
|
226
199
|
visualizer = YOLOVisualizer(
|
|
227
200
|
label_dir="yolo_labels/", image_dir="images/",
|
|
228
201
|
class_file="classes.txt", is_show=True, is_save=True,
|
|
229
|
-
output_dir="visualized/",
|
|
202
|
+
output_dir="visualized/", log_config=log_cfg,
|
|
230
203
|
)
|
|
231
204
|
result = visualizer.visualize()
|
|
232
205
|
|
|
233
206
|
# ── Evaluate ─────────────────────────────────────────
|
|
234
|
-
evaluator = DetectionEvaluator(verbose=True)
|
|
207
|
+
evaluator = DetectionEvaluator(log_config=LogConfig(name="eval", verbose=True))
|
|
235
208
|
result = evaluator.evaluate("anno.json", "pred.json")
|
|
236
209
|
print(f"AP: {result.metrics.ap:.3f}, AP50: {result.metrics.ap50:.3f}")
|
|
237
210
|
|
|
@@ -248,7 +221,7 @@ prf1 = compute_pr_f1("anno_segm.json", "pred_segm.json", iou_type="segm")
|
|
|
248
221
|
print(f"Segm F1: {prf1.overall.f1_score:.3f}")
|
|
249
222
|
```
|
|
250
223
|
|
|
251
|
-
> 📂 See the `samples/` directory for complete examples: `samples/visualize/` (YOLO, LabelMe, COCO
|
|
224
|
+
> 📂 See the `samples/` directory for complete examples: `samples/convert/` (6 conversion directions), `samples/visualize/` (YOLO, LabelMe, COCO), `samples/evaluate/` (detection & segmentation), `samples/cli/` (CLI workflows).
|
|
252
225
|
|
|
253
226
|
---
|
|
254
227
|
|
|
@@ -264,15 +237,13 @@ print(f"Segm F1: {prf1.overall.f1_score:.3f}")
|
|
|
264
237
|
|
|
265
238
|
### 💡 Key Concepts
|
|
266
239
|
|
|
267
|
-
- **Format-Native Coordinates**:
|
|
268
|
-
- **
|
|
269
|
-
- **
|
|
270
|
-
- **
|
|
271
|
-
- **
|
|
272
|
-
- **
|
|
273
|
-
- **
|
|
274
|
-
- **Evaluation Metrics**: COCO-standard 12-metric output with optional per-class breakdown. P/R/F1 supports both macro (default) and micro averaging, and both bbox and mask IoU.
|
|
275
|
-
- **Prediction Files**: YOLO prediction files use 6 tokens (detection) or even tokens (segmentation) vs 5/odd for labels. `--prediction` outputs a plain JSON list of annotation dicts — the standard prediction exchange format compatible with pycocotools `loadRes()`.
|
|
240
|
+
- **Format-Native Coordinates**: YOLO uses normalized [0,1] center-based coordinates; LabelMe and COCO use absolute pixel top-left. There is no hidden internal normalization — check `DatasetAnnotations.format` to interpret coordinate semantics.
|
|
241
|
+
- **Strict Mode** (default): Validation errors raise exceptions immediately. Disable with `--no-strict` (CLI) or `strict_mode=False` (API) to skip invalid annotations and continue.
|
|
242
|
+
- **Verbose Logging**: `--verbose` enables per-module file logging via `LogManager` — console shows INFO-level progress, log files capture DEBUG details. All logging is owned by modules; the CLI uses `click.echo()` for terminal output.
|
|
243
|
+
- **Headless Support**: Use `--no-display` for servers/Docker — pair with `--save` to render visualization images without a GUI window.
|
|
244
|
+
- **Keyboard Shortcuts** (visualization): `q` / `ESC` to exit, `Enter` / `Space` to advance, any other key to continue.
|
|
245
|
+
- **Evaluation**: `--prf1` computes P/R/F1 only (single-threshold, per-class TP/FP/FN) — skips the full COCOeval mAP pipeline for speed. Supports macro/micro averaging and bbox/mask IoU. Run without `--prf1` for standard COCO mAP. For both metrics, run twice.
|
|
246
|
+
- **Prediction Files**: YOLO predictions use 6 tokens (detection) or even tokens (segmentation) vs 5/odd for labels. Use `--prediction` with `yolo2coco` — outputs a plain JSON list of annotation dicts compatible with pycocotools `loadRes()`.
|
|
276
247
|
|
|
277
248
|
---
|
|
278
249
|
|
|
@@ -282,7 +253,7 @@ For detailed developer guidance including advanced test commands, debugging, and
|
|
|
282
253
|
|
|
283
254
|
### 🧪 Testing
|
|
284
255
|
|
|
285
|
-
**
|
|
256
|
+
**418 tests, 76% code coverage (3986 statements).**
|
|
286
257
|
|
|
287
258
|
```bash
|
|
288
259
|
pytest # All tests
|
|
@@ -301,7 +272,7 @@ pytest tests/evaluate/test_evaluator.py # Single module
|
|
|
301
272
|
| `dataflow/visualize/` | 81% | yolo_vis (100%), labelme_vis (100%), coco_vis (97%), base (74%) |
|
|
302
273
|
| `dataflow/evaluate/` | 87% | evaluator (100%), metrics (93%), result (99%), base (91%), utils (68%) |
|
|
303
274
|
| `dataflow/cli/` | 59% | main (96%), convert cmd (48%), evaluate cmd (24%), visualize cmd (84%), utils (86%) |
|
|
304
|
-
| `dataflow/util/` | 93% | logging (98%)
|
|
275
|
+
| `dataflow/util/` | 93% | logging (98%) |
|
|
305
276
|
|
|
306
277
|
</details>
|
|
307
278
|
|
|
@@ -332,12 +303,12 @@ pre-commit run --all-files # Manual run against all files
|
|
|
332
303
|
```
|
|
333
304
|
dataflow/
|
|
334
305
|
├── label/ # Annotation handlers + data models
|
|
335
|
-
├── convert/ # Format converters
|
|
336
|
-
├── visualize/ # OpenCV-based rendering
|
|
337
|
-
├── evaluate/ # pycocotools-based metrics
|
|
338
|
-
├── util/ #
|
|
306
|
+
├── convert/ # Format converters, RLE utility, log templates
|
|
307
|
+
├── visualize/ # OpenCV-based rendering, log templates
|
|
308
|
+
├── evaluate/ # pycocotools-based metrics, log templates
|
|
309
|
+
├── util/ # Unified logging (LogManager + format helpers)
|
|
339
310
|
└── cli/ # CLI entry point, commands, validation
|
|
340
|
-
tests/ # Unit & integration tests
|
|
311
|
+
tests/ # Unit & integration tests (418 tests, conftest fixtures)
|
|
341
312
|
samples/ # Python API usage examples
|
|
342
313
|
assets/ # Test data (det/seg by format)
|
|
343
314
|
specs/ # Canonical specifications (evaluate/ + formats/ + modules/)
|