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.
Files changed (55) hide show
  1. {dataflow_cv-1.3.0/dataflow_cv.egg-info → dataflow_cv-1.5.0}/PKG-INFO +62 -117
  2. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/README.md +60 -111
  3. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/__init__.py +1 -1
  4. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/cli/commands/convert.py +68 -68
  5. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/cli/commands/evaluate.py +88 -92
  6. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/cli/commands/utils.py +10 -21
  7. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/cli/commands/visualize.py +50 -71
  8. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/cli/main.py +8 -7
  9. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/convert/base.py +25 -31
  10. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/convert/coco_and_labelme.py +5 -6
  11. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/convert/labelme_and_yolo.py +5 -6
  12. dataflow_cv-1.5.0/dataflow/convert/log_templates.py +93 -0
  13. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/convert/yolo_and_coco.py +3 -3
  14. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/evaluate/base.py +26 -38
  15. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/evaluate/evaluator.py +10 -28
  16. dataflow_cv-1.5.0/dataflow/evaluate/log_templates.py +208 -0
  17. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/evaluate/metrics.py +9 -4
  18. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/evaluate/result.py +1 -1
  19. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/evaluate/utils.py +14 -126
  20. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/label/base.py +3 -3
  21. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/label/coco_handler.py +0 -2
  22. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/label/labelme_handler.py +4 -10
  23. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/label/yolo_handler.py +9 -28
  24. dataflow_cv-1.5.0/dataflow/util/__init__.py +14 -0
  25. dataflow_cv-1.5.0/dataflow/util/logging.py +319 -0
  26. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/visualize/base.py +63 -81
  27. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/visualize/coco_visualizer.py +14 -9
  28. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/visualize/labelme_visualizer.py +10 -4
  29. dataflow_cv-1.5.0/dataflow/visualize/log_templates.py +100 -0
  30. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/visualize/utils.py +0 -30
  31. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/visualize/yolo_visualizer.py +14 -9
  32. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0/dataflow_cv.egg-info}/PKG-INFO +62 -117
  33. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow_cv.egg-info/SOURCES.txt +4 -2
  34. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow_cv.egg-info/requires.txt +0 -5
  35. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/pyproject.toml +2 -11
  36. dataflow_cv-1.3.0/dataflow/util/__init__.py +0 -10
  37. dataflow_cv-1.3.0/dataflow/util/file_util.py +0 -128
  38. dataflow_cv-1.3.0/dataflow/util/logging_util.py +0 -338
  39. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/LICENSE +0 -0
  40. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/cli/__init__.py +0 -0
  41. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/cli/commands/__init__.py +0 -0
  42. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/cli/exceptions.py +0 -0
  43. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/convert/__init__.py +0 -0
  44. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/convert/rle_converter.py +0 -0
  45. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/convert/utils.py +0 -0
  46. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/evaluate/__init__.py +0 -0
  47. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/label/__init__.py +0 -0
  48. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/label/models.py +0 -0
  49. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/label/utils.py +0 -0
  50. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow/visualize/__init__.py +0 -0
  51. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow_cv.egg-info/dependency_links.txt +0 -0
  52. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow_cv.egg-info/entry_points.txt +0 -0
  53. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow_cv.egg-info/not-zip-safe +0 -0
  54. {dataflow_cv-1.3.0 → dataflow_cv-1.5.0}/dataflow_cv.egg-info/top_level.txt +0 -0
  55. {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.0
3
+ Version: 1.5.0
4
4
  Summary: A computer vision dataset processing library
5
- Author-email: DataFlow-CV Team <example@example.com>
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 for seamless format conversion, visualization, and evaluation between YOLO, LabelMe, and COCO annotation formats. Designed for researchers and developers working with multi-format annotation pipelines.
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
- | 🔄 **Format Conversion** | Convert between YOLO, LabelMe, and COCO in any direction — 6 conversion paths, plus prediction file support (outputs standard list-format COCO predictions) |
77
- | 🎯 **Detection & Segmentation** | Handle both object detection (bbox) and instance segmentation (polygon/RLE) annotations |
78
- | 🎨 **Visualization** | Render annotations with OpenCV — color-coded classes, semi-transparent masks, display & save modes |
79
- | 📊 **Evaluation** | COCO-standard 12-metric output (mAP, AP50, AP75, AR) via pycocotools, with per-class breakdowns and macro/micro P/R/F1 |
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
- ### From Source
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
- #### 📊 Evaluation
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
- Evaluate object detection and instance segmentation model outputs using COCO-standard metrics. Two COCO-format JSON files are required:
144
+ #### 📊 Evaluation
176
145
 
177
- | File | Role | Format | Source |
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
- ##### Preparing Evaluation Data
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
- If your annotations and predictions are in YOLO format, convert them to COCO JSON first:
153
+ ##### Prepare Data
185
154
 
186
155
  ```bash
187
- # Step 1: YOLO ground truth labels → COCO GT (anno.json)
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
- # Step 2: YOLO predictions → COCO DT (pred.json)
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
- > ⚠️ **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.
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
- ##### CLI Commands
165
+ ##### Run Evaluation
216
166
 
217
167
  ```bash
218
- # Object detection evaluation (bbox IoU)
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
- # Verbose per-class breakdown
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
- ##### End-to-End Workflow
182
+ ##### Detection vs Segmentation
238
183
 
239
- ```bash
240
- # Complete pipeline: YOLO → COCO → Evaluation
241
- dataflow-cv convert yolo2coco images/ yolo_labels/ classes.txt anno.json
242
- dataflow-cv convert yolo2coco --prediction images/ yolo_preds/ classes.txt pred.json
243
- dataflow-cv evaluate detection --verbose --prf1 anno.json pred.json
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
- converter = YoloAndCocoConverter(source_to_target=True, verbose=True, strict_mode=True)
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/", verbose=True, strict_mode=True,
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 demos), `samples/convert/` (conversion examples).
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**: Coordinates stored in each format's native representation — YOLO normalized [0,1] center-based, LabelMe/COCO absolute pixels top-left. Check `DatasetAnnotations.format` to determine semantics.
311
- - **Explicit Coordinate Transforms**: Converters handle all coordinate transformations between formats no hidden normalization.
312
- - **Strict Mode**: Validation errors raise exceptions by default. Disable with `--no-strict` (CLI) or `strict_mode=False` (API).
313
- - **Verbose Logging**: Detailed debug logs saved to files when `--verbose` is used. The CLI prints the log file path after each operation.
314
- - **Headless Support**: Use `--no-display` for servers/Docker; pair with `--save` to output visualization images without a window.
315
- - **Keyboard Shortcuts**: During visualization`q`/`ESC` to exit, `Enter`/`Space` to advance, any other key to continue.
316
- - **Color Management**: Each class ID gets a unique color from an HSV-based palette (up to 1000 classes) for consistent visualization.
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
- **405 tests, 76% code coverage (3986 statements).**
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%), file_util (84%) |
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 + RLE utility
379
- ├── visualize/ # OpenCV-based rendering
380
- ├── evaluate/ # pycocotools-based metrics
381
- ├── util/ # Logging & file utilities
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 for seamless format conversion, visualization, and evaluation between YOLO, LabelMe, and COCO annotation formats. Designed for researchers and developers working with multi-format annotation pipelines.
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
- | 🔄 **Format Conversion** | Convert between YOLO, LabelMe, and COCO in any direction — 6 conversion paths, plus prediction file support (outputs standard list-format COCO predictions) |
34
- | 🎯 **Detection & Segmentation** | Handle both object detection (bbox) and instance segmentation (polygon/RLE) annotations |
35
- | 🎨 **Visualization** | Render annotations with OpenCV — color-coded classes, semi-transparent masks, display & save modes |
36
- | 📊 **Evaluation** | COCO-standard 12-metric output (mAP, AP50, AP75, AR) via pycocotools, with per-class breakdowns and macro/micro P/R/F1 |
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
- ### From Source
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
- #### 📊 Evaluation
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
- Evaluate object detection and instance segmentation model outputs using COCO-standard metrics. Two COCO-format JSON files are required:
105
+ #### 📊 Evaluation
133
106
 
134
- | File | Role | Format | Source |
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
- ##### Preparing Evaluation Data
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
- If your annotations and predictions are in YOLO format, convert them to COCO JSON first:
114
+ ##### Prepare Data
142
115
 
143
116
  ```bash
144
- # Step 1: YOLO ground truth labels → COCO GT (anno.json)
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
- # Step 2: YOLO predictions → COCO DT (pred.json)
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
- > ⚠️ **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.
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
- ##### CLI Commands
126
+ ##### Run Evaluation
173
127
 
174
128
  ```bash
175
- # Object detection evaluation (bbox IoU)
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
- # Verbose per-class breakdown
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
- ##### End-to-End Workflow
143
+ ##### Detection vs Segmentation
195
144
 
196
- ```bash
197
- # Complete pipeline: YOLO → COCO → Evaluation
198
- dataflow-cv convert yolo2coco images/ yolo_labels/ classes.txt anno.json
199
- dataflow-cv convert yolo2coco --prediction images/ yolo_preds/ classes.txt pred.json
200
- dataflow-cv evaluate detection --verbose --prf1 anno.json pred.json
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
- converter = YoloAndCocoConverter(source_to_target=True, verbose=True, strict_mode=True)
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/", verbose=True, strict_mode=True,
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 demos), `samples/convert/` (conversion examples).
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**: Coordinates stored in each format's native representation — YOLO normalized [0,1] center-based, LabelMe/COCO absolute pixels top-left. Check `DatasetAnnotations.format` to determine semantics.
268
- - **Explicit Coordinate Transforms**: Converters handle all coordinate transformations between formats no hidden normalization.
269
- - **Strict Mode**: Validation errors raise exceptions by default. Disable with `--no-strict` (CLI) or `strict_mode=False` (API).
270
- - **Verbose Logging**: Detailed debug logs saved to files when `--verbose` is used. The CLI prints the log file path after each operation.
271
- - **Headless Support**: Use `--no-display` for servers/Docker; pair with `--save` to output visualization images without a window.
272
- - **Keyboard Shortcuts**: During visualization`q`/`ESC` to exit, `Enter`/`Space` to advance, any other key to continue.
273
- - **Color Management**: Each class ID gets a unique color from an HSV-based palette (up to 1000 classes) for consistent visualization.
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
- **405 tests, 76% code coverage (3986 statements).**
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%), file_util (84%) |
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 + RLE utility
336
- ├── visualize/ # OpenCV-based rendering
337
- ├── evaluate/ # pycocotools-based metrics
338
- ├── util/ # Logging & file utilities
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/)
@@ -1,4 +1,4 @@
1
1
  """DataFlow-CV: A computer vision dataset processing library."""
2
2
 
3
- __version__ = "1.3.0"
3
+ __version__ = "1.5.0"
4
4
  __author__ = "DataFlow-CV Team"