dataflow-cv 1.2.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.2.0/dataflow_cv.egg-info → dataflow_cv-1.4.0}/PKG-INFO +63 -83
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/README.md +61 -77
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow/__init__.py +1 -1
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow/cli/commands/convert.py +71 -70
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow/cli/commands/evaluate.py +97 -100
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow/cli/commands/utils.py +10 -21
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow/cli/commands/visualize.py +50 -71
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow/cli/main.py +1 -7
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow/convert/base.py +123 -94
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow/convert/coco_and_labelme.py +21 -100
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow/convert/labelme_and_yolo.py +18 -62
- dataflow_cv-1.4.0/dataflow/convert/log_templates.py +93 -0
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow/convert/utils.py +140 -5
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow/convert/yolo_and_coco.py +32 -150
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow/evaluate/base.py +33 -41
- {dataflow_cv-1.2.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.4.0/dataflow/evaluate/metrics.py +461 -0
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow/evaluate/result.py +6 -1
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow/evaluate/utils.py +86 -98
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow/label/base.py +26 -0
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow/label/coco_handler.py +32 -7
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow/label/labelme_handler.py +4 -10
- {dataflow_cv-1.2.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.2.0 → dataflow_cv-1.4.0}/dataflow/visualize/base.py +46 -82
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow/visualize/coco_visualizer.py +8 -9
- {dataflow_cv-1.2.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.2.0 → dataflow_cv-1.4.0}/dataflow/visualize/yolo_visualizer.py +8 -9
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0/dataflow_cv.egg-info}/PKG-INFO +63 -83
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow_cv.egg-info/SOURCES.txt +4 -2
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow_cv.egg-info/requires.txt +0 -5
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/pyproject.toml +2 -11
- dataflow_cv-1.2.0/dataflow/evaluate/metrics.py +0 -276
- dataflow_cv-1.2.0/dataflow/util/__init__.py +0 -10
- dataflow_cv-1.2.0/dataflow/util/file_util.py +0 -128
- dataflow_cv-1.2.0/dataflow/util/logging_util.py +0 -271
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/LICENSE +0 -0
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow/cli/__init__.py +0 -0
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow/cli/commands/__init__.py +0 -0
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow/cli/exceptions.py +0 -0
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow/convert/__init__.py +0 -0
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow/convert/rle_converter.py +0 -0
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow/evaluate/__init__.py +0 -0
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow/label/__init__.py +0 -0
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow/label/models.py +0 -0
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow/label/utils.py +0 -0
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow/visualize/__init__.py +0 -0
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow/visualize/utils.py +0 -0
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow_cv.egg-info/dependency_links.txt +0 -0
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow_cv.egg-info/entry_points.txt +0 -0
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow_cv.egg-info/not-zip-safe +0 -0
- {dataflow_cv-1.2.0 → dataflow_cv-1.4.0}/dataflow_cv.egg-info/top_level.txt +0 -0
- {dataflow_cv-1.2.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
|
|
@@ -146,7 +112,7 @@ dataflow-cv convert coco2yolo input.json yolo_labels/
|
|
|
146
112
|
# COCO → LabelMe
|
|
147
113
|
dataflow-cv convert coco2labelme input.json labelme_json/
|
|
148
114
|
|
|
149
|
-
# YOLO predictions → COCO (
|
|
115
|
+
# YOLO predictions → COCO (output: plain JSON list — prediction format)
|
|
150
116
|
dataflow-cv convert yolo2coco --prediction images/ yolo_preds/ classes.txt pred.json
|
|
151
117
|
|
|
152
118
|
# Options
|
|
@@ -174,10 +140,10 @@ dataflow-cv visualize yolo --verbose --no-display images/ yolo_labels/ classes.t
|
|
|
174
140
|
|
|
175
141
|
Evaluate object detection and instance segmentation model outputs using COCO-standard metrics. Two COCO-format JSON files are required:
|
|
176
142
|
|
|
177
|
-
| File | Role | Source |
|
|
178
|
-
|
|
179
|
-
| **`anno.json`** | Ground Truth (GT) — reference annotations | `yolo2coco` (label mode) |
|
|
180
|
-
| **`pred.json`** | Detection (DT) — model predictions with `score` | `yolo2coco --prediction
|
|
143
|
+
| File | Role | Format | Source |
|
|
144
|
+
|------|------|--------|--------|
|
|
145
|
+
| **`anno.json`** | Ground Truth (GT) — reference annotations | Full COCO dict (`images`, `annotations`, `categories`) | `yolo2coco` (label mode) |
|
|
146
|
+
| **`pred.json`** | Detection (DT) — model predictions | Plain JSON list of annotation dicts (with `score`) | `yolo2coco --prediction`, Detectron2, MMDetection |
|
|
181
147
|
|
|
182
148
|
##### ① Preparing Evaluation Data
|
|
183
149
|
|
|
@@ -195,7 +161,9 @@ dataflow-cv convert yolo2coco images/ yolo_labels/ classes.txt anno.json
|
|
|
195
161
|
dataflow-cv convert yolo2coco --prediction images/ yolo_preds/ classes.txt pred.json
|
|
196
162
|
```
|
|
197
163
|
|
|
198
|
-
> ⚠️ **Important**: YOLO label files (GT) use **odd** token counts, while prediction files (DT) use **even** token counts with a trailing `confidence`. The `--prediction` flag is required for DT — it
|
|
164
|
+
> ⚠️ **Important**: YOLO label files (GT) use **odd** token counts, while prediction files (DT) use **even** token counts with a trailing `confidence`. The `--prediction` flag is required for DT — it outputs a **plain JSON list** of annotation dicts (not a full COCO dict with `images`/`categories`). Mixed label/prediction files in the same directory are not supported.
|
|
165
|
+
>
|
|
166
|
+
> ℹ️ **Note**: The `--prediction` flag is **only available for `yolo2coco`**. `labelme2coco` does not support prediction conversion — LabelMe files (.json) have no label vs prediction format distinction, so there is no equivalent prediction source format to convert from.
|
|
199
167
|
|
|
200
168
|
##### ② Detection vs Segmentation — Format Requirements
|
|
201
169
|
|
|
@@ -219,8 +187,11 @@ dataflow-cv evaluate detection anno.json pred.json
|
|
|
219
187
|
# Verbose per-class breakdown
|
|
220
188
|
dataflow-cv evaluate detection --verbose anno.json pred.json
|
|
221
189
|
|
|
222
|
-
#
|
|
223
|
-
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
|
|
192
|
+
|
|
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
|
|
224
195
|
|
|
225
196
|
# Instance segmentation evaluation (mask IoU)
|
|
226
197
|
dataflow-cv evaluate segmentation anno.json pred.json
|
|
@@ -235,19 +206,22 @@ dataflow-cv evaluate detection --output results.json anno.json pred.json
|
|
|
235
206
|
# Complete pipeline: YOLO → COCO → Evaluation
|
|
236
207
|
dataflow-cv convert yolo2coco images/ yolo_labels/ classes.txt anno.json
|
|
237
208
|
dataflow-cv convert yolo2coco --prediction images/ yolo_preds/ classes.txt pred.json
|
|
238
|
-
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
|
|
239
211
|
```
|
|
240
212
|
|
|
241
213
|
### 🐍 Python API
|
|
242
214
|
|
|
243
215
|
```python
|
|
216
|
+
from dataflow.util.logging import LogConfig
|
|
244
217
|
from dataflow.convert import YoloAndCocoConverter
|
|
245
218
|
from dataflow.visualize import YOLOVisualizer
|
|
246
219
|
from dataflow.evaluate import DetectionEvaluator, compute_pr_f1
|
|
247
220
|
|
|
248
221
|
# ── Convert ──────────────────────────────────────────
|
|
249
222
|
# YOLO labels → COCO (label mode)
|
|
250
|
-
|
|
223
|
+
log_cfg = LogConfig(name="convert", verbose=True)
|
|
224
|
+
converter = YoloAndCocoConverter(source_to_target=True, log_config=log_cfg, strict_mode=True)
|
|
251
225
|
result = converter.convert(
|
|
252
226
|
source_path="yolo_labels/", target_path="anno.json",
|
|
253
227
|
class_file="classes.txt", image_dir="images/",
|
|
@@ -264,21 +238,29 @@ result = converter.convert(
|
|
|
264
238
|
visualizer = YOLOVisualizer(
|
|
265
239
|
label_dir="yolo_labels/", image_dir="images/",
|
|
266
240
|
class_file="classes.txt", is_show=True, is_save=True,
|
|
267
|
-
output_dir="visualized/",
|
|
241
|
+
output_dir="visualized/", log_config=log_cfg,
|
|
268
242
|
)
|
|
269
243
|
result = visualizer.visualize()
|
|
270
244
|
|
|
271
245
|
# ── Evaluate ─────────────────────────────────────────
|
|
272
|
-
evaluator = DetectionEvaluator(verbose=True)
|
|
246
|
+
evaluator = DetectionEvaluator(log_config=LogConfig(name="eval", verbose=True))
|
|
273
247
|
result = evaluator.evaluate("anno.json", "pred.json")
|
|
274
248
|
print(f"AP: {result.metrics.ap:.3f}, AP50: {result.metrics.ap50:.3f}")
|
|
275
249
|
|
|
276
|
-
# Quick P/R/F1 at IoU=0.5
|
|
250
|
+
# Quick P/R/F1 at IoU=0.5 (default: macro averaging, bbox IoU)
|
|
277
251
|
prf1 = compute_pr_f1("anno.json", "pred.json", iou_threshold=0.5)
|
|
278
|
-
print(f"F1: {prf1.overall.f1_score:.3f}")
|
|
252
|
+
print(f"Macro F1: {prf1.overall.f1_score:.3f}")
|
|
253
|
+
|
|
254
|
+
# Micro averaging P/R/F1 (samples weighted equally)
|
|
255
|
+
prf1 = compute_pr_f1("anno.json", "pred.json", method="micro")
|
|
256
|
+
print(f"Micro F1: {prf1.overall.f1_score:.3f}")
|
|
257
|
+
|
|
258
|
+
# Segmentation P/R/F1 (mask IoU)
|
|
259
|
+
prf1 = compute_pr_f1("anno_segm.json", "pred_segm.json", iou_type="segm")
|
|
260
|
+
print(f"Segm F1: {prf1.overall.f1_score:.3f}")
|
|
279
261
|
```
|
|
280
262
|
|
|
281
|
-
> 📂 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).
|
|
282
264
|
|
|
283
265
|
---
|
|
284
266
|
|
|
@@ -294,15 +276,13 @@ print(f"F1: {prf1.overall.f1_score:.3f}")
|
|
|
294
276
|
|
|
295
277
|
### 💡 Key Concepts
|
|
296
278
|
|
|
297
|
-
- **Format-Native Coordinates**:
|
|
298
|
-
- **
|
|
299
|
-
- **
|
|
300
|
-
- **
|
|
301
|
-
- **
|
|
302
|
-
- **
|
|
303
|
-
- **
|
|
304
|
-
- **Evaluation Metrics**: COCO-standard 12-metric output with optional per-class breakdown and P/R/F1 computation.
|
|
305
|
-
- **Prediction Files**: YOLO prediction files (6 tokens detection, even tokens segmentation) differ from label files (5/odd tokens). Use `--prediction` flag.
|
|
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()`.
|
|
306
286
|
|
|
307
287
|
---
|
|
308
288
|
|
|
@@ -312,7 +292,7 @@ For detailed developer guidance including advanced test commands, debugging, and
|
|
|
312
292
|
|
|
313
293
|
### 🧪 Testing
|
|
314
294
|
|
|
315
|
-
**
|
|
295
|
+
**418 tests, 76% code coverage (3986 statements).**
|
|
316
296
|
|
|
317
297
|
```bash
|
|
318
298
|
pytest # All tests
|
|
@@ -326,12 +306,12 @@ pytest tests/evaluate/test_evaluator.py # Single module
|
|
|
326
306
|
|
|
327
307
|
| Module | Coverage | Highlights |
|
|
328
308
|
|--------|:--------:|------------|
|
|
329
|
-
| `dataflow/label/` | 68% | models (87%), coco_handler (
|
|
330
|
-
| `dataflow/convert/` |
|
|
331
|
-
| `dataflow/visualize/` | 81% | yolo_vis (
|
|
332
|
-
| `dataflow/evaluate/` |
|
|
309
|
+
| `dataflow/label/` | 68% | models (87%), coco_handler (75%), labelme_handler (70%), yolo_handler (58%) |
|
|
310
|
+
| `dataflow/convert/` | 87% | yolo_and_coco (90%), labelme_and_yolo (86%), coco_and_labelme (87%), rle (80%), base (83%), utils (92%) |
|
|
311
|
+
| `dataflow/visualize/` | 81% | yolo_vis (100%), labelme_vis (100%), coco_vis (97%), base (74%) |
|
|
312
|
+
| `dataflow/evaluate/` | 87% | evaluator (100%), metrics (93%), result (99%), base (91%), utils (68%) |
|
|
333
313
|
| `dataflow/cli/` | 59% | main (96%), convert cmd (48%), evaluate cmd (24%), visualize cmd (84%), utils (86%) |
|
|
334
|
-
| `dataflow/util/` | 93% | logging (
|
|
314
|
+
| `dataflow/util/` | 93% | logging (98%) |
|
|
335
315
|
|
|
336
316
|
</details>
|
|
337
317
|
|
|
@@ -362,12 +342,12 @@ pre-commit run --all-files # Manual run against all files
|
|
|
362
342
|
```
|
|
363
343
|
dataflow/
|
|
364
344
|
├── label/ # Annotation handlers + data models
|
|
365
|
-
├── convert/ # Format converters
|
|
366
|
-
├── visualize/ # OpenCV-based rendering
|
|
367
|
-
├── evaluate/ # pycocotools-based metrics
|
|
368
|
-
├── 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)
|
|
369
349
|
└── cli/ # CLI entry point, commands, validation
|
|
370
|
-
tests/ # Unit & integration tests
|
|
350
|
+
tests/ # Unit & integration tests (418 tests, conftest fixtures)
|
|
371
351
|
samples/ # Python API usage examples
|
|
372
352
|
assets/ # Test data (det/seg by format)
|
|
373
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
|
|
@@ -103,7 +73,7 @@ dataflow-cv convert coco2yolo input.json yolo_labels/
|
|
|
103
73
|
# COCO → LabelMe
|
|
104
74
|
dataflow-cv convert coco2labelme input.json labelme_json/
|
|
105
75
|
|
|
106
|
-
# YOLO predictions → COCO (
|
|
76
|
+
# YOLO predictions → COCO (output: plain JSON list — prediction format)
|
|
107
77
|
dataflow-cv convert yolo2coco --prediction images/ yolo_preds/ classes.txt pred.json
|
|
108
78
|
|
|
109
79
|
# Options
|
|
@@ -131,10 +101,10 @@ dataflow-cv visualize yolo --verbose --no-display images/ yolo_labels/ classes.t
|
|
|
131
101
|
|
|
132
102
|
Evaluate object detection and instance segmentation model outputs using COCO-standard metrics. Two COCO-format JSON files are required:
|
|
133
103
|
|
|
134
|
-
| File | Role | Source |
|
|
135
|
-
|
|
136
|
-
| **`anno.json`** | Ground Truth (GT) — reference annotations | `yolo2coco` (label mode) |
|
|
137
|
-
| **`pred.json`** | Detection (DT) — model predictions with `score` | `yolo2coco --prediction
|
|
104
|
+
| File | Role | Format | Source |
|
|
105
|
+
|------|------|--------|--------|
|
|
106
|
+
| **`anno.json`** | Ground Truth (GT) — reference annotations | Full COCO dict (`images`, `annotations`, `categories`) | `yolo2coco` (label mode) |
|
|
107
|
+
| **`pred.json`** | Detection (DT) — model predictions | Plain JSON list of annotation dicts (with `score`) | `yolo2coco --prediction`, Detectron2, MMDetection |
|
|
138
108
|
|
|
139
109
|
##### ① Preparing Evaluation Data
|
|
140
110
|
|
|
@@ -152,7 +122,9 @@ dataflow-cv convert yolo2coco images/ yolo_labels/ classes.txt anno.json
|
|
|
152
122
|
dataflow-cv convert yolo2coco --prediction images/ yolo_preds/ classes.txt pred.json
|
|
153
123
|
```
|
|
154
124
|
|
|
155
|
-
> ⚠️ **Important**: YOLO label files (GT) use **odd** token counts, while prediction files (DT) use **even** token counts with a trailing `confidence`. The `--prediction` flag is required for DT — it
|
|
125
|
+
> ⚠️ **Important**: YOLO label files (GT) use **odd** token counts, while prediction files (DT) use **even** token counts with a trailing `confidence`. The `--prediction` flag is required for DT — it outputs a **plain JSON list** of annotation dicts (not a full COCO dict with `images`/`categories`). Mixed label/prediction files in the same directory are not supported.
|
|
126
|
+
>
|
|
127
|
+
> ℹ️ **Note**: The `--prediction` flag is **only available for `yolo2coco`**. `labelme2coco` does not support prediction conversion — LabelMe files (.json) have no label vs prediction format distinction, so there is no equivalent prediction source format to convert from.
|
|
156
128
|
|
|
157
129
|
##### ② Detection vs Segmentation — Format Requirements
|
|
158
130
|
|
|
@@ -176,8 +148,11 @@ dataflow-cv evaluate detection anno.json pred.json
|
|
|
176
148
|
# Verbose per-class breakdown
|
|
177
149
|
dataflow-cv evaluate detection --verbose anno.json pred.json
|
|
178
150
|
|
|
179
|
-
#
|
|
180
|
-
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
|
|
153
|
+
|
|
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
|
|
181
156
|
|
|
182
157
|
# Instance segmentation evaluation (mask IoU)
|
|
183
158
|
dataflow-cv evaluate segmentation anno.json pred.json
|
|
@@ -192,19 +167,22 @@ dataflow-cv evaluate detection --output results.json anno.json pred.json
|
|
|
192
167
|
# Complete pipeline: YOLO → COCO → Evaluation
|
|
193
168
|
dataflow-cv convert yolo2coco images/ yolo_labels/ classes.txt anno.json
|
|
194
169
|
dataflow-cv convert yolo2coco --prediction images/ yolo_preds/ classes.txt pred.json
|
|
195
|
-
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
|
|
196
172
|
```
|
|
197
173
|
|
|
198
174
|
### 🐍 Python API
|
|
199
175
|
|
|
200
176
|
```python
|
|
177
|
+
from dataflow.util.logging import LogConfig
|
|
201
178
|
from dataflow.convert import YoloAndCocoConverter
|
|
202
179
|
from dataflow.visualize import YOLOVisualizer
|
|
203
180
|
from dataflow.evaluate import DetectionEvaluator, compute_pr_f1
|
|
204
181
|
|
|
205
182
|
# ── Convert ──────────────────────────────────────────
|
|
206
183
|
# YOLO labels → COCO (label mode)
|
|
207
|
-
|
|
184
|
+
log_cfg = LogConfig(name="convert", verbose=True)
|
|
185
|
+
converter = YoloAndCocoConverter(source_to_target=True, log_config=log_cfg, strict_mode=True)
|
|
208
186
|
result = converter.convert(
|
|
209
187
|
source_path="yolo_labels/", target_path="anno.json",
|
|
210
188
|
class_file="classes.txt", image_dir="images/",
|
|
@@ -221,21 +199,29 @@ result = converter.convert(
|
|
|
221
199
|
visualizer = YOLOVisualizer(
|
|
222
200
|
label_dir="yolo_labels/", image_dir="images/",
|
|
223
201
|
class_file="classes.txt", is_show=True, is_save=True,
|
|
224
|
-
output_dir="visualized/",
|
|
202
|
+
output_dir="visualized/", log_config=log_cfg,
|
|
225
203
|
)
|
|
226
204
|
result = visualizer.visualize()
|
|
227
205
|
|
|
228
206
|
# ── Evaluate ─────────────────────────────────────────
|
|
229
|
-
evaluator = DetectionEvaluator(verbose=True)
|
|
207
|
+
evaluator = DetectionEvaluator(log_config=LogConfig(name="eval", verbose=True))
|
|
230
208
|
result = evaluator.evaluate("anno.json", "pred.json")
|
|
231
209
|
print(f"AP: {result.metrics.ap:.3f}, AP50: {result.metrics.ap50:.3f}")
|
|
232
210
|
|
|
233
|
-
# Quick P/R/F1 at IoU=0.5
|
|
211
|
+
# Quick P/R/F1 at IoU=0.5 (default: macro averaging, bbox IoU)
|
|
234
212
|
prf1 = compute_pr_f1("anno.json", "pred.json", iou_threshold=0.5)
|
|
235
|
-
print(f"F1: {prf1.overall.f1_score:.3f}")
|
|
213
|
+
print(f"Macro F1: {prf1.overall.f1_score:.3f}")
|
|
214
|
+
|
|
215
|
+
# Micro averaging P/R/F1 (samples weighted equally)
|
|
216
|
+
prf1 = compute_pr_f1("anno.json", "pred.json", method="micro")
|
|
217
|
+
print(f"Micro F1: {prf1.overall.f1_score:.3f}")
|
|
218
|
+
|
|
219
|
+
# Segmentation P/R/F1 (mask IoU)
|
|
220
|
+
prf1 = compute_pr_f1("anno_segm.json", "pred_segm.json", iou_type="segm")
|
|
221
|
+
print(f"Segm F1: {prf1.overall.f1_score:.3f}")
|
|
236
222
|
```
|
|
237
223
|
|
|
238
|
-
> 📂 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).
|
|
239
225
|
|
|
240
226
|
---
|
|
241
227
|
|
|
@@ -251,15 +237,13 @@ print(f"F1: {prf1.overall.f1_score:.3f}")
|
|
|
251
237
|
|
|
252
238
|
### 💡 Key Concepts
|
|
253
239
|
|
|
254
|
-
- **Format-Native Coordinates**:
|
|
255
|
-
- **
|
|
256
|
-
- **
|
|
257
|
-
- **
|
|
258
|
-
- **
|
|
259
|
-
- **
|
|
260
|
-
- **
|
|
261
|
-
- **Evaluation Metrics**: COCO-standard 12-metric output with optional per-class breakdown and P/R/F1 computation.
|
|
262
|
-
- **Prediction Files**: YOLO prediction files (6 tokens detection, even tokens segmentation) differ from label files (5/odd tokens). Use `--prediction` flag.
|
|
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()`.
|
|
263
247
|
|
|
264
248
|
---
|
|
265
249
|
|
|
@@ -269,7 +253,7 @@ For detailed developer guidance including advanced test commands, debugging, and
|
|
|
269
253
|
|
|
270
254
|
### 🧪 Testing
|
|
271
255
|
|
|
272
|
-
**
|
|
256
|
+
**418 tests, 76% code coverage (3986 statements).**
|
|
273
257
|
|
|
274
258
|
```bash
|
|
275
259
|
pytest # All tests
|
|
@@ -283,12 +267,12 @@ pytest tests/evaluate/test_evaluator.py # Single module
|
|
|
283
267
|
|
|
284
268
|
| Module | Coverage | Highlights |
|
|
285
269
|
|--------|:--------:|------------|
|
|
286
|
-
| `dataflow/label/` | 68% | models (87%), coco_handler (
|
|
287
|
-
| `dataflow/convert/` |
|
|
288
|
-
| `dataflow/visualize/` | 81% | yolo_vis (
|
|
289
|
-
| `dataflow/evaluate/` |
|
|
270
|
+
| `dataflow/label/` | 68% | models (87%), coco_handler (75%), labelme_handler (70%), yolo_handler (58%) |
|
|
271
|
+
| `dataflow/convert/` | 87% | yolo_and_coco (90%), labelme_and_yolo (86%), coco_and_labelme (87%), rle (80%), base (83%), utils (92%) |
|
|
272
|
+
| `dataflow/visualize/` | 81% | yolo_vis (100%), labelme_vis (100%), coco_vis (97%), base (74%) |
|
|
273
|
+
| `dataflow/evaluate/` | 87% | evaluator (100%), metrics (93%), result (99%), base (91%), utils (68%) |
|
|
290
274
|
| `dataflow/cli/` | 59% | main (96%), convert cmd (48%), evaluate cmd (24%), visualize cmd (84%), utils (86%) |
|
|
291
|
-
| `dataflow/util/` | 93% | logging (
|
|
275
|
+
| `dataflow/util/` | 93% | logging (98%) |
|
|
292
276
|
|
|
293
277
|
</details>
|
|
294
278
|
|
|
@@ -319,12 +303,12 @@ pre-commit run --all-files # Manual run against all files
|
|
|
319
303
|
```
|
|
320
304
|
dataflow/
|
|
321
305
|
├── label/ # Annotation handlers + data models
|
|
322
|
-
├── convert/ # Format converters
|
|
323
|
-
├── visualize/ # OpenCV-based rendering
|
|
324
|
-
├── evaluate/ # pycocotools-based metrics
|
|
325
|
-
├── 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)
|
|
326
310
|
└── cli/ # CLI entry point, commands, validation
|
|
327
|
-
tests/ # Unit & integration tests
|
|
311
|
+
tests/ # Unit & integration tests (418 tests, conftest fixtures)
|
|
328
312
|
samples/ # Python API usage examples
|
|
329
313
|
assets/ # Test data (det/seg by format)
|
|
330
314
|
specs/ # Canonical specifications (evaluate/ + formats/ + modules/)
|