dataflow-cv 1.3.0__tar.gz → 1.5.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.5.0}/PKG-INFO +62 -117
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/README.md +60 -111
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/__init__.py +1 -1
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/cli/commands/convert.py +68 -68
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/cli/commands/evaluate.py +88 -92
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/cli/commands/utils.py +10 -21
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/cli/commands/visualize.py +50 -71
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/cli/main.py +8 -7
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/convert/base.py +25 -31
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/convert/coco_and_labelme.py +5 -6
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/convert/labelme_and_yolo.py +5 -6
- dataflow_cv-1.5.0/dataflow/convert/log_templates.py +93 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/convert/yolo_and_coco.py +3 -3
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/evaluate/base.py +26 -38
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/evaluate/evaluator.py +10 -28
- dataflow_cv-1.5.0/dataflow/evaluate/log_templates.py +208 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/evaluate/metrics.py +9 -4
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/evaluate/result.py +1 -1
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/evaluate/utils.py +14 -126
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/label/base.py +3 -3
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/label/coco_handler.py +0 -2
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/label/labelme_handler.py +4 -10
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/label/yolo_handler.py +9 -28
- dataflow_cv-1.5.0/dataflow/util/__init__.py +14 -0
- dataflow_cv-1.5.0/dataflow/util/logging.py +319 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/visualize/base.py +63 -81
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/visualize/coco_visualizer.py +14 -9
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/visualize/labelme_visualizer.py +10 -4
- dataflow_cv-1.5.0/dataflow/visualize/log_templates.py +100 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/visualize/utils.py +0 -30
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/visualize/yolo_visualizer.py +14 -9
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0/dataflow_cv.egg-info}/PKG-INFO +62 -117
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow_cv.egg-info/SOURCES.txt +4 -2
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow_cv.egg-info/requires.txt +0 -5
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.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.5.0}/LICENSE +0 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/cli/__init__.py +0 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/cli/commands/__init__.py +0 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/cli/exceptions.py +0 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/convert/__init__.py +0 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/convert/rle_converter.py +0 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/convert/utils.py +0 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/evaluate/__init__.py +0 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/label/__init__.py +0 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/label/models.py +0 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/label/utils.py +0 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/visualize/__init__.py +0 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow_cv.egg-info/dependency_links.txt +0 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow_cv.egg-info/entry_points.txt +0 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow_cv.egg-info/not-zip-safe +0 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow_cv.egg-info/top_level.txt +0 -0
- {dataflow_cv-1.3.0 → dataflow_cv-1.5.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.5.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
|
|
@@ -170,89 +136,70 @@ dataflow-cv visualize coco images/ coco_annotations.json --save visualized/
|
|
|
170
136
|
dataflow-cv visualize yolo --verbose --no-display images/ yolo_labels/ classes.txt --save visualized/
|
|
171
137
|
```
|
|
172
138
|
|
|
173
|
-
|
|
139
|
+
<p align="center">
|
|
140
|
+
<img src="assets/showcase/seg_demo_1.jpg" width="45%" alt="Segmentation visualization demo 1">
|
|
141
|
+
<img src="assets/showcase/seg_demo_2.jpg" width="45%" alt="Segmentation visualization demo 2">
|
|
142
|
+
</p>
|
|
174
143
|
|
|
175
|
-
|
|
144
|
+
#### 📊 Evaluation
|
|
176
145
|
|
|
177
|
-
|
|
178
|
-
|------|------|--------|--------|
|
|
179
|
-
| **`anno.json`** | Ground Truth (GT) — reference annotations | Full COCO dict (`images`, `annotations`, `categories`) | `yolo2coco` (label mode) |
|
|
180
|
-
| **`pred.json`** | Detection (DT) — model predictions | Plain JSON list of annotation dicts (with `score`) | `yolo2coco --prediction`, Detectron2, MMDetection |
|
|
146
|
+
Evaluate object detection and instance segmentation models with COCO-standard metrics. Two COCO-format JSON files are required:
|
|
181
147
|
|
|
182
|
-
|
|
148
|
+
| File | Role | Format | How to create |
|
|
149
|
+
|------|------|--------|---------------|
|
|
150
|
+
| **`anno.json`** | Ground Truth (GT) | Full COCO dict (`images`, `annotations`, `categories`) | `yolo2coco` (label mode) |
|
|
151
|
+
| **`pred.json`** | Detection (DT) | Plain JSON list (with `score`) | `yolo2coco --prediction` |
|
|
183
152
|
|
|
184
|
-
|
|
153
|
+
##### ① Prepare Data
|
|
185
154
|
|
|
186
155
|
```bash
|
|
187
|
-
#
|
|
188
|
-
# Label format: class_id cx cy w h ← 5 tokens (detection)
|
|
189
|
-
# class_id x1 y1 ... xn yn ← odd tokens (segmentation)
|
|
156
|
+
# GT: YOLO labels → COCO
|
|
190
157
|
dataflow-cv convert yolo2coco images/ yolo_labels/ classes.txt anno.json
|
|
191
158
|
|
|
192
|
-
#
|
|
193
|
-
# Prediction fmt: class_id cx cy w h confidence ← 6 tokens (detection)
|
|
194
|
-
# class_id x1 y1 ... xn yn confidence ← even tokens (segmentation)
|
|
159
|
+
# DT: YOLO predictions → COCO (add --prediction for model output)
|
|
195
160
|
dataflow-cv convert yolo2coco --prediction images/ yolo_preds/ classes.txt pred.json
|
|
196
161
|
```
|
|
197
162
|
|
|
198
|
-
> ⚠️
|
|
199
|
-
>
|
|
200
|
-
> ℹ️ **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.
|
|
201
|
-
|
|
202
|
-
##### ② Detection vs Segmentation — Format Requirements
|
|
203
|
-
|
|
204
|
-
| Field | Detection GT | Detection DT | Segmentation GT | Segmentation DT |
|
|
205
|
-
|-------|:-----------:|:-----------:|:---------------:|:---------------:|
|
|
206
|
-
| `bbox` | ✅ Required | ✅ Required | ✅ Required (for area) | ✅ Required (for area) |
|
|
207
|
-
| `score` | — | ✅ **Required** | — | ✅ **Required** |
|
|
208
|
-
| `segmentation` | ❌ Not required | ❌ Not required | ✅ **Required** | ✅ **Required** |
|
|
209
|
-
| `area` | ⚪ Recommended | ⚪ Recommended | ✅ **Required** | ✅ **Required** |
|
|
210
|
-
| `iscrowd` | ⚪ Optional | — | ⚪ Optional | — |
|
|
211
|
-
|
|
212
|
-
- **Object Detection** (`iouType='bbox'`): Bounding box overlap evaluation. Only `bbox` + `score` mandatory in DT.
|
|
213
|
-
- **Instance Segmentation** (`iouType='segm'`): Mask overlap evaluation. GT and DT must include `segmentation` (polygon or RLE), `area`, and `bbox`.
|
|
163
|
+
> ⚠️ `--prediction` is required for YOLO prediction files — they have an extra `confidence` token per line. The flag outputs a **plain JSON list** (not a full COCO dict), which is the standard DT format for `loadRes()`. Only `yolo2coco` supports `--prediction`; `labelme2coco` does not need it (LabelMe has no label vs prediction distinction).
|
|
214
164
|
|
|
215
|
-
#####
|
|
165
|
+
##### ② Run Evaluation
|
|
216
166
|
|
|
217
167
|
```bash
|
|
218
|
-
# Object detection
|
|
168
|
+
# Object detection (bbox IoU)
|
|
219
169
|
dataflow-cv evaluate detection anno.json pred.json
|
|
170
|
+
dataflow-cv evaluate detection --verbose anno.json pred.json # per-class breakdown
|
|
171
|
+
dataflow-cv evaluate detection --prf1 anno.json pred.json # P/R/F1 only (skip mAP)
|
|
172
|
+
dataflow-cv evaluate detection --prf1 --prf1-iou 0.75 --prf1-method micro anno.json pred.json
|
|
220
173
|
|
|
221
|
-
#
|
|
222
|
-
dataflow-cv evaluate detection --verbose anno.json pred.json
|
|
223
|
-
|
|
224
|
-
# With P/R/F1 at IoU=0.5 (default: macro averaging)
|
|
225
|
-
dataflow-cv evaluate detection --prf1 --prf1-iou 0.5 anno.json pred.json
|
|
226
|
-
|
|
227
|
-
# With P/R/F1 using micro averaging
|
|
228
|
-
dataflow-cv evaluate detection --prf1 --prf1-method micro anno.json pred.json
|
|
229
|
-
|
|
230
|
-
# Instance segmentation evaluation (mask IoU)
|
|
174
|
+
# Instance segmentation (mask IoU)
|
|
231
175
|
dataflow-cv evaluate segmentation anno.json pred.json
|
|
176
|
+
dataflow-cv evaluate segmentation --verbose anno.json pred.json
|
|
232
177
|
|
|
233
178
|
# Save results as JSON
|
|
234
179
|
dataflow-cv evaluate detection --output results.json anno.json pred.json
|
|
235
180
|
```
|
|
236
181
|
|
|
237
|
-
#####
|
|
182
|
+
##### ③ Detection vs Segmentation
|
|
238
183
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
184
|
+
Two evaluation modes, distinguished by how overlap is measured:
|
|
185
|
+
|
|
186
|
+
- **Object Detection** — bounding box IoU. GT and DT require `bbox`; DT additionally requires `score`.
|
|
187
|
+
- **Instance Segmentation** — mask IoU. GT and DT require `bbox`, `segmentation` (polygon or RLE), and `area`; DT additionally requires `score`.
|
|
188
|
+
|
|
189
|
+
`yolo2coco` (label mode) and `yolo2coco --prediction` (prediction mode) automatically populate all required fields for both modes — no manual editing needed.
|
|
245
190
|
|
|
246
191
|
### 🐍 Python API
|
|
247
192
|
|
|
248
193
|
```python
|
|
194
|
+
from dataflow.util.logging import LogConfig
|
|
249
195
|
from dataflow.convert import YoloAndCocoConverter
|
|
250
196
|
from dataflow.visualize import YOLOVisualizer
|
|
251
197
|
from dataflow.evaluate import DetectionEvaluator, compute_pr_f1
|
|
252
198
|
|
|
253
199
|
# ── Convert ──────────────────────────────────────────
|
|
254
200
|
# YOLO labels → COCO (label mode)
|
|
255
|
-
|
|
201
|
+
log_cfg = LogConfig(name="convert", verbose=True)
|
|
202
|
+
converter = YoloAndCocoConverter(source_to_target=True, log_config=log_cfg, strict_mode=True)
|
|
256
203
|
result = converter.convert(
|
|
257
204
|
source_path="yolo_labels/", target_path="anno.json",
|
|
258
205
|
class_file="classes.txt", image_dir="images/",
|
|
@@ -269,12 +216,12 @@ result = converter.convert(
|
|
|
269
216
|
visualizer = YOLOVisualizer(
|
|
270
217
|
label_dir="yolo_labels/", image_dir="images/",
|
|
271
218
|
class_file="classes.txt", is_show=True, is_save=True,
|
|
272
|
-
output_dir="visualized/",
|
|
219
|
+
output_dir="visualized/", log_config=log_cfg,
|
|
273
220
|
)
|
|
274
221
|
result = visualizer.visualize()
|
|
275
222
|
|
|
276
223
|
# ── Evaluate ─────────────────────────────────────────
|
|
277
|
-
evaluator = DetectionEvaluator(verbose=True)
|
|
224
|
+
evaluator = DetectionEvaluator(log_config=LogConfig(name="eval", verbose=True))
|
|
278
225
|
result = evaluator.evaluate("anno.json", "pred.json")
|
|
279
226
|
print(f"AP: {result.metrics.ap:.3f}, AP50: {result.metrics.ap50:.3f}")
|
|
280
227
|
|
|
@@ -291,7 +238,7 @@ prf1 = compute_pr_f1("anno_segm.json", "pred_segm.json", iou_type="segm")
|
|
|
291
238
|
print(f"Segm F1: {prf1.overall.f1_score:.3f}")
|
|
292
239
|
```
|
|
293
240
|
|
|
294
|
-
> 📂 See the `samples/` directory for complete examples: `samples/visualize/` (YOLO, LabelMe, COCO
|
|
241
|
+
> 📂 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
242
|
|
|
296
243
|
---
|
|
297
244
|
|
|
@@ -307,15 +254,13 @@ print(f"Segm F1: {prf1.overall.f1_score:.3f}")
|
|
|
307
254
|
|
|
308
255
|
### 💡 Key Concepts
|
|
309
256
|
|
|
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()`.
|
|
257
|
+
- **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.
|
|
258
|
+
- **Strict Mode** (default): Validation errors raise exceptions immediately. Disable with `--no-strict` (CLI) or `strict_mode=False` (API) to skip invalid annotations and continue.
|
|
259
|
+
- **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.
|
|
260
|
+
- **Headless Support**: Use `--no-display` for servers/Docker — pair with `--save` to render visualization images without a GUI window.
|
|
261
|
+
- **Keyboard Shortcuts** (visualization): `q` / `ESC` to exit, `Enter` / `Space` to advance, any other key to continue.
|
|
262
|
+
- **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.
|
|
263
|
+
- **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
264
|
|
|
320
265
|
---
|
|
321
266
|
|
|
@@ -325,7 +270,7 @@ For detailed developer guidance including advanced test commands, debugging, and
|
|
|
325
270
|
|
|
326
271
|
### 🧪 Testing
|
|
327
272
|
|
|
328
|
-
**
|
|
273
|
+
**418 tests, 76% code coverage (3986 statements).**
|
|
329
274
|
|
|
330
275
|
```bash
|
|
331
276
|
pytest # All tests
|
|
@@ -344,7 +289,7 @@ pytest tests/evaluate/test_evaluator.py # Single module
|
|
|
344
289
|
| `dataflow/visualize/` | 81% | yolo_vis (100%), labelme_vis (100%), coco_vis (97%), base (74%) |
|
|
345
290
|
| `dataflow/evaluate/` | 87% | evaluator (100%), metrics (93%), result (99%), base (91%), utils (68%) |
|
|
346
291
|
| `dataflow/cli/` | 59% | main (96%), convert cmd (48%), evaluate cmd (24%), visualize cmd (84%), utils (86%) |
|
|
347
|
-
| `dataflow/util/` | 93% | logging (98%)
|
|
292
|
+
| `dataflow/util/` | 93% | logging (98%) |
|
|
348
293
|
|
|
349
294
|
</details>
|
|
350
295
|
|
|
@@ -375,12 +320,12 @@ pre-commit run --all-files # Manual run against all files
|
|
|
375
320
|
```
|
|
376
321
|
dataflow/
|
|
377
322
|
├── label/ # Annotation handlers + data models
|
|
378
|
-
├── convert/ # Format converters
|
|
379
|
-
├── visualize/ # OpenCV-based rendering
|
|
380
|
-
├── evaluate/ # pycocotools-based metrics
|
|
381
|
-
├── util/ #
|
|
323
|
+
├── convert/ # Format converters, RLE utility, log templates
|
|
324
|
+
├── visualize/ # OpenCV-based rendering, log templates
|
|
325
|
+
├── evaluate/ # pycocotools-based metrics, log templates
|
|
326
|
+
├── util/ # Unified logging (LogManager + format helpers)
|
|
382
327
|
└── cli/ # CLI entry point, commands, validation
|
|
383
|
-
tests/ # Unit & integration tests
|
|
328
|
+
tests/ # Unit & integration tests (418 tests, conftest fixtures)
|
|
384
329
|
samples/ # Python API usage examples
|
|
385
330
|
assets/ # Test data (det/seg by format)
|
|
386
331
|
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
|
|
@@ -127,89 +97,70 @@ dataflow-cv visualize coco images/ coco_annotations.json --save visualized/
|
|
|
127
97
|
dataflow-cv visualize yolo --verbose --no-display images/ yolo_labels/ classes.txt --save visualized/
|
|
128
98
|
```
|
|
129
99
|
|
|
130
|
-
|
|
100
|
+
<p align="center">
|
|
101
|
+
<img src="assets/showcase/seg_demo_1.jpg" width="45%" alt="Segmentation visualization demo 1">
|
|
102
|
+
<img src="assets/showcase/seg_demo_2.jpg" width="45%" alt="Segmentation visualization demo 2">
|
|
103
|
+
</p>
|
|
131
104
|
|
|
132
|
-
|
|
105
|
+
#### 📊 Evaluation
|
|
133
106
|
|
|
134
|
-
|
|
135
|
-
|------|------|--------|--------|
|
|
136
|
-
| **`anno.json`** | Ground Truth (GT) — reference annotations | Full COCO dict (`images`, `annotations`, `categories`) | `yolo2coco` (label mode) |
|
|
137
|
-
| **`pred.json`** | Detection (DT) — model predictions | Plain JSON list of annotation dicts (with `score`) | `yolo2coco --prediction`, Detectron2, MMDetection |
|
|
107
|
+
Evaluate object detection and instance segmentation models with COCO-standard metrics. Two COCO-format JSON files are required:
|
|
138
108
|
|
|
139
|
-
|
|
109
|
+
| File | Role | Format | How to create |
|
|
110
|
+
|------|------|--------|---------------|
|
|
111
|
+
| **`anno.json`** | Ground Truth (GT) | Full COCO dict (`images`, `annotations`, `categories`) | `yolo2coco` (label mode) |
|
|
112
|
+
| **`pred.json`** | Detection (DT) | Plain JSON list (with `score`) | `yolo2coco --prediction` |
|
|
140
113
|
|
|
141
|
-
|
|
114
|
+
##### ① Prepare Data
|
|
142
115
|
|
|
143
116
|
```bash
|
|
144
|
-
#
|
|
145
|
-
# Label format: class_id cx cy w h ← 5 tokens (detection)
|
|
146
|
-
# class_id x1 y1 ... xn yn ← odd tokens (segmentation)
|
|
117
|
+
# GT: YOLO labels → COCO
|
|
147
118
|
dataflow-cv convert yolo2coco images/ yolo_labels/ classes.txt anno.json
|
|
148
119
|
|
|
149
|
-
#
|
|
150
|
-
# Prediction fmt: class_id cx cy w h confidence ← 6 tokens (detection)
|
|
151
|
-
# class_id x1 y1 ... xn yn confidence ← even tokens (segmentation)
|
|
120
|
+
# DT: YOLO predictions → COCO (add --prediction for model output)
|
|
152
121
|
dataflow-cv convert yolo2coco --prediction images/ yolo_preds/ classes.txt pred.json
|
|
153
122
|
```
|
|
154
123
|
|
|
155
|
-
> ⚠️
|
|
156
|
-
>
|
|
157
|
-
> ℹ️ **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.
|
|
158
|
-
|
|
159
|
-
##### ② Detection vs Segmentation — Format Requirements
|
|
160
|
-
|
|
161
|
-
| Field | Detection GT | Detection DT | Segmentation GT | Segmentation DT |
|
|
162
|
-
|-------|:-----------:|:-----------:|:---------------:|:---------------:|
|
|
163
|
-
| `bbox` | ✅ Required | ✅ Required | ✅ Required (for area) | ✅ Required (for area) |
|
|
164
|
-
| `score` | — | ✅ **Required** | — | ✅ **Required** |
|
|
165
|
-
| `segmentation` | ❌ Not required | ❌ Not required | ✅ **Required** | ✅ **Required** |
|
|
166
|
-
| `area` | ⚪ Recommended | ⚪ Recommended | ✅ **Required** | ✅ **Required** |
|
|
167
|
-
| `iscrowd` | ⚪ Optional | — | ⚪ Optional | — |
|
|
168
|
-
|
|
169
|
-
- **Object Detection** (`iouType='bbox'`): Bounding box overlap evaluation. Only `bbox` + `score` mandatory in DT.
|
|
170
|
-
- **Instance Segmentation** (`iouType='segm'`): Mask overlap evaluation. GT and DT must include `segmentation` (polygon or RLE), `area`, and `bbox`.
|
|
124
|
+
> ⚠️ `--prediction` is required for YOLO prediction files — they have an extra `confidence` token per line. The flag outputs a **plain JSON list** (not a full COCO dict), which is the standard DT format for `loadRes()`. Only `yolo2coco` supports `--prediction`; `labelme2coco` does not need it (LabelMe has no label vs prediction distinction).
|
|
171
125
|
|
|
172
|
-
#####
|
|
126
|
+
##### ② Run Evaluation
|
|
173
127
|
|
|
174
128
|
```bash
|
|
175
|
-
# Object detection
|
|
129
|
+
# Object detection (bbox IoU)
|
|
176
130
|
dataflow-cv evaluate detection anno.json pred.json
|
|
131
|
+
dataflow-cv evaluate detection --verbose anno.json pred.json # per-class breakdown
|
|
132
|
+
dataflow-cv evaluate detection --prf1 anno.json pred.json # P/R/F1 only (skip mAP)
|
|
133
|
+
dataflow-cv evaluate detection --prf1 --prf1-iou 0.75 --prf1-method micro anno.json pred.json
|
|
177
134
|
|
|
178
|
-
#
|
|
179
|
-
dataflow-cv evaluate detection --verbose anno.json pred.json
|
|
180
|
-
|
|
181
|
-
# With P/R/F1 at IoU=0.5 (default: macro averaging)
|
|
182
|
-
dataflow-cv evaluate detection --prf1 --prf1-iou 0.5 anno.json pred.json
|
|
183
|
-
|
|
184
|
-
# With P/R/F1 using micro averaging
|
|
185
|
-
dataflow-cv evaluate detection --prf1 --prf1-method micro anno.json pred.json
|
|
186
|
-
|
|
187
|
-
# Instance segmentation evaluation (mask IoU)
|
|
135
|
+
# Instance segmentation (mask IoU)
|
|
188
136
|
dataflow-cv evaluate segmentation anno.json pred.json
|
|
137
|
+
dataflow-cv evaluate segmentation --verbose anno.json pred.json
|
|
189
138
|
|
|
190
139
|
# Save results as JSON
|
|
191
140
|
dataflow-cv evaluate detection --output results.json anno.json pred.json
|
|
192
141
|
```
|
|
193
142
|
|
|
194
|
-
#####
|
|
143
|
+
##### ③ Detection vs Segmentation
|
|
195
144
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
145
|
+
Two evaluation modes, distinguished by how overlap is measured:
|
|
146
|
+
|
|
147
|
+
- **Object Detection** — bounding box IoU. GT and DT require `bbox`; DT additionally requires `score`.
|
|
148
|
+
- **Instance Segmentation** — mask IoU. GT and DT require `bbox`, `segmentation` (polygon or RLE), and `area`; DT additionally requires `score`.
|
|
149
|
+
|
|
150
|
+
`yolo2coco` (label mode) and `yolo2coco --prediction` (prediction mode) automatically populate all required fields for both modes — no manual editing needed.
|
|
202
151
|
|
|
203
152
|
### 🐍 Python API
|
|
204
153
|
|
|
205
154
|
```python
|
|
155
|
+
from dataflow.util.logging import LogConfig
|
|
206
156
|
from dataflow.convert import YoloAndCocoConverter
|
|
207
157
|
from dataflow.visualize import YOLOVisualizer
|
|
208
158
|
from dataflow.evaluate import DetectionEvaluator, compute_pr_f1
|
|
209
159
|
|
|
210
160
|
# ── Convert ──────────────────────────────────────────
|
|
211
161
|
# YOLO labels → COCO (label mode)
|
|
212
|
-
|
|
162
|
+
log_cfg = LogConfig(name="convert", verbose=True)
|
|
163
|
+
converter = YoloAndCocoConverter(source_to_target=True, log_config=log_cfg, strict_mode=True)
|
|
213
164
|
result = converter.convert(
|
|
214
165
|
source_path="yolo_labels/", target_path="anno.json",
|
|
215
166
|
class_file="classes.txt", image_dir="images/",
|
|
@@ -226,12 +177,12 @@ result = converter.convert(
|
|
|
226
177
|
visualizer = YOLOVisualizer(
|
|
227
178
|
label_dir="yolo_labels/", image_dir="images/",
|
|
228
179
|
class_file="classes.txt", is_show=True, is_save=True,
|
|
229
|
-
output_dir="visualized/",
|
|
180
|
+
output_dir="visualized/", log_config=log_cfg,
|
|
230
181
|
)
|
|
231
182
|
result = visualizer.visualize()
|
|
232
183
|
|
|
233
184
|
# ── Evaluate ─────────────────────────────────────────
|
|
234
|
-
evaluator = DetectionEvaluator(verbose=True)
|
|
185
|
+
evaluator = DetectionEvaluator(log_config=LogConfig(name="eval", verbose=True))
|
|
235
186
|
result = evaluator.evaluate("anno.json", "pred.json")
|
|
236
187
|
print(f"AP: {result.metrics.ap:.3f}, AP50: {result.metrics.ap50:.3f}")
|
|
237
188
|
|
|
@@ -248,7 +199,7 @@ prf1 = compute_pr_f1("anno_segm.json", "pred_segm.json", iou_type="segm")
|
|
|
248
199
|
print(f"Segm F1: {prf1.overall.f1_score:.3f}")
|
|
249
200
|
```
|
|
250
201
|
|
|
251
|
-
> 📂 See the `samples/` directory for complete examples: `samples/visualize/` (YOLO, LabelMe, COCO
|
|
202
|
+
> 📂 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
203
|
|
|
253
204
|
---
|
|
254
205
|
|
|
@@ -264,15 +215,13 @@ print(f"Segm F1: {prf1.overall.f1_score:.3f}")
|
|
|
264
215
|
|
|
265
216
|
### 💡 Key Concepts
|
|
266
217
|
|
|
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()`.
|
|
218
|
+
- **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.
|
|
219
|
+
- **Strict Mode** (default): Validation errors raise exceptions immediately. Disable with `--no-strict` (CLI) or `strict_mode=False` (API) to skip invalid annotations and continue.
|
|
220
|
+
- **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.
|
|
221
|
+
- **Headless Support**: Use `--no-display` for servers/Docker — pair with `--save` to render visualization images without a GUI window.
|
|
222
|
+
- **Keyboard Shortcuts** (visualization): `q` / `ESC` to exit, `Enter` / `Space` to advance, any other key to continue.
|
|
223
|
+
- **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.
|
|
224
|
+
- **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
225
|
|
|
277
226
|
---
|
|
278
227
|
|
|
@@ -282,7 +231,7 @@ For detailed developer guidance including advanced test commands, debugging, and
|
|
|
282
231
|
|
|
283
232
|
### 🧪 Testing
|
|
284
233
|
|
|
285
|
-
**
|
|
234
|
+
**418 tests, 76% code coverage (3986 statements).**
|
|
286
235
|
|
|
287
236
|
```bash
|
|
288
237
|
pytest # All tests
|
|
@@ -301,7 +250,7 @@ pytest tests/evaluate/test_evaluator.py # Single module
|
|
|
301
250
|
| `dataflow/visualize/` | 81% | yolo_vis (100%), labelme_vis (100%), coco_vis (97%), base (74%) |
|
|
302
251
|
| `dataflow/evaluate/` | 87% | evaluator (100%), metrics (93%), result (99%), base (91%), utils (68%) |
|
|
303
252
|
| `dataflow/cli/` | 59% | main (96%), convert cmd (48%), evaluate cmd (24%), visualize cmd (84%), utils (86%) |
|
|
304
|
-
| `dataflow/util/` | 93% | logging (98%)
|
|
253
|
+
| `dataflow/util/` | 93% | logging (98%) |
|
|
305
254
|
|
|
306
255
|
</details>
|
|
307
256
|
|
|
@@ -332,12 +281,12 @@ pre-commit run --all-files # Manual run against all files
|
|
|
332
281
|
```
|
|
333
282
|
dataflow/
|
|
334
283
|
├── label/ # Annotation handlers + data models
|
|
335
|
-
├── convert/ # Format converters
|
|
336
|
-
├── visualize/ # OpenCV-based rendering
|
|
337
|
-
├── evaluate/ # pycocotools-based metrics
|
|
338
|
-
├── util/ #
|
|
284
|
+
├── convert/ # Format converters, RLE utility, log templates
|
|
285
|
+
├── visualize/ # OpenCV-based rendering, log templates
|
|
286
|
+
├── evaluate/ # pycocotools-based metrics, log templates
|
|
287
|
+
├── util/ # Unified logging (LogManager + format helpers)
|
|
339
288
|
└── cli/ # CLI entry point, commands, validation
|
|
340
|
-
tests/ # Unit & integration tests
|
|
289
|
+
tests/ # Unit & integration tests (418 tests, conftest fixtures)
|
|
341
290
|
samples/ # Python API usage examples
|
|
342
291
|
assets/ # Test data (det/seg by format)
|
|
343
292
|
specs/ # Canonical specifications (evaluate/ + formats/ + modules/)
|