dataflow-cv 0.2.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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 zjykzj
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,202 @@
1
+ Metadata-Version: 2.4
2
+ Name: dataflow-cv
3
+ Version: 0.2.0
4
+ Summary: A data processing library for computer vision datasets
5
+ Home-page: https://github.com/zjykzj/DataFlow-CV
6
+ Author: DataFlow Team
7
+ License: MIT
8
+ Keywords: computer-vision,dataset,conversion,visualization,coco,yolo,labelme
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Operating System :: POSIX :: Linux
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
+ Classifier: Topic :: Scientific/Engineering :: Image Processing
21
+ Requires-Python: >=3.8
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: numpy>=2.0.0
25
+ Requires-Dist: opencv-python>=4.8.0
26
+ Requires-Dist: Pillow>=10.0.0
27
+ Requires-Dist: click>=8.1.0
28
+ Dynamic: home-page
29
+ Dynamic: license-file
30
+ Dynamic: requires-python
31
+
32
+ # DataFlow-CV
33
+
34
+ > **Where Vibe Coding meets CV data.** 🌊
35
+ > Convert & visualize datasets. Built with the flow of Claude Code.
36
+
37
+ ![Python Version](https://img.shields.io/badge/python-3.8%20|%203.9%20|%203.10%20|%203.11%20|%203.12-blue)
38
+ ![License](https://img.shields.io/badge/license-MIT-green)
39
+ ![Version](https://img.shields.io/badge/version-0.2.0-orange)
40
+ ![Development Status](https://img.shields.io/badge/status-alpha-yellow)
41
+
42
+ A data processing library for computer vision datasets, focusing on format conversion and visualization between LabelMe, COCO, and YOLO formats. Provides both a CLI and Python API.
43
+
44
+ ## Table of Contents
45
+
46
+ - [DataFlow-CV](#dataflow-cv)
47
+ - [Table of Contents](#table-of-contents)
48
+ - [Project Structure](#project-structure)
49
+ - [Requirements](#requirements)
50
+ - [License](#license)
51
+
52
+ ## Project Structure
53
+
54
+ ```
55
+ dataflow/
56
+ ├── __init__.py # Package exports and convenience functions
57
+ ├── cli.py # Command-line interface
58
+ ├── config.py # Configuration management
59
+ ├── convert/ # Format conversion module
60
+ │ ├── __init__.py
61
+ │ ├── base.py # Converter base class
62
+ │ ├── coco_to_yolo.py # COCO to YOLO converter
63
+ │ └── yolo_to_coco.py # YOLO to COCO converter
64
+ tests/
65
+ ├── __init__.py
66
+ ├── convert/ # Conversion tests
67
+ │ ├── __init__.py
68
+ │ ├── test_coco_to_yolo.py
69
+ │ └── test_yolo_to_coco.py
70
+ ├── run_tests.py # Test runner
71
+ samples/
72
+ ├── __init__.py
73
+ ├── cli/ # CLI usage examples
74
+ │ ├── __init__.py
75
+ │ └── convert/
76
+ │ ├── cli_coco_to_yolo.py
77
+ │ └── cli_yolo_to_coco.py
78
+ └── api/ # Python API examples
79
+ ├── __init__.py
80
+ └── convert/
81
+ ├── api_coco_to_yolo.py
82
+ └── api_yolo_to_coco.py
83
+ ```
84
+
85
+ ## Requirements
86
+
87
+ ### Core Dependencies
88
+ - Python 3.8 or higher
89
+ - Linux environment (POSIX compatible, assumes POSIX paths)
90
+ - `click` >= 8.1.0 – CLI framework
91
+ - `numpy` >= 2.0.0 – numerical operations
92
+ - `opencv-python` >= 4.8.0 – image processing (optional, used for some image operations)
93
+ - `Pillow` >= 10.0.0 – image reading (optional, used for reading image dimensions)
94
+
95
+ ## Quick Start
96
+
97
+ ### Installation
98
+
99
+ ```bash
100
+ # Install
101
+ pip install .
102
+ ```
103
+
104
+ ### Command Line Usage
105
+
106
+ Global options: `--verbose` (`-v`) for progress output, `--overwrite` to replace existing files.
107
+
108
+ ```bash
109
+ # COCO to YOLO conversion
110
+ dataflow convert coco2yolo annotations.json output_dir/
111
+
112
+ # YOLO to COCO conversion
113
+ dataflow convert yolo2coco images/ labels/ classes.names output.json
114
+
115
+ # Show configuration
116
+ dataflow config
117
+
118
+ # Get help
119
+ dataflow --help
120
+ dataflow convert coco2yolo --help
121
+ ```
122
+
123
+ See the [CLI Reference](#cli-reference) below for detailed usage.
124
+
125
+ ### Python API Usage
126
+
127
+ ```python
128
+ import dataflow
129
+
130
+ # COCO to YOLO
131
+ result = dataflow.coco_to_yolo("annotations.json", "output_dir")
132
+ print(f"Processed {result['images_processed']} images")
133
+
134
+ # YOLO to COCO
135
+ result = dataflow.yolo_to_coco("images/", "labels/", "classes.names", "output.json")
136
+ print(f"Generated {result['annotations_processed']} annotations")
137
+ ```
138
+
139
+ ### CLI Reference
140
+
141
+ The CLI follows a hierarchical structure: `dataflow <main‑task> <sub‑task> [arguments]`. Global options can be placed before the main task.
142
+
143
+ #### Global Options
144
+ - `--verbose`, `-v`: Enable verbose output (progress information)
145
+ - `--overwrite`: Overwrite existing files
146
+
147
+ #### Conversion Commands
148
+
149
+ **COCO to YOLO**
150
+ ```bash
151
+ dataflow convert coco2yolo COCO_JSON_PATH OUTPUT_DIR [--segmentation]
152
+ ```
153
+ - `COCO_JSON_PATH`: Path to COCO JSON annotation file
154
+ - `OUTPUT_DIR`: Directory where `labels/` and `class.names` will be created
155
+ - `--segmentation`, `-s`: Handle segmentation annotations (polygon format)
156
+
157
+ **YOLO to COCO**
158
+ ```bash
159
+ dataflow convert yolo2coco IMAGE_DIR YOLO_LABELS_DIR YOLO_CLASS_PATH COCO_JSON_PATH
160
+ ```
161
+ - `IMAGE_DIR`: Directory containing image files
162
+ - `YOLO_LABELS_DIR`: Directory containing YOLO label files (`.txt`)
163
+ - `YOLO_CLASS_PATH`: Path to YOLO class names file (e.g., `class.names`)
164
+ - `COCO_JSON_PATH`: Path to save COCO JSON file
165
+
166
+ #### Configuration Command
167
+ ```bash
168
+ dataflow config
169
+ ```
170
+ Shows the current configuration (file extensions, default values, CLI context).
171
+
172
+ #### Getting Help
173
+ ```bash
174
+ dataflow --help
175
+ dataflow convert --help
176
+ dataflow convert coco2yolo --help
177
+ dataflow convert yolo2coco --help
178
+ ```
179
+
180
+ ### Running Tests
181
+
182
+ ```bash
183
+ # Run all tests
184
+ python tests/run_tests.py
185
+
186
+ # Run specific test
187
+ python tests/run_tests.py --test TestCocoToYoloConverter
188
+
189
+ # With verbose output
190
+ python tests/run_tests.py -v
191
+ ```
192
+
193
+ ### Examples
194
+
195
+ Check the `samples/` directory for detailed usage examples:
196
+
197
+ - `samples/cli/convert/` - CLI usage examples
198
+ - `samples/api/convert/` - Python API examples
199
+
200
+ ## License
201
+
202
+ [MIT License](LICENSE) © 2026 zjykzj
@@ -0,0 +1,171 @@
1
+ # DataFlow-CV
2
+
3
+ > **Where Vibe Coding meets CV data.** 🌊
4
+ > Convert & visualize datasets. Built with the flow of Claude Code.
5
+
6
+ ![Python Version](https://img.shields.io/badge/python-3.8%20|%203.9%20|%203.10%20|%203.11%20|%203.12-blue)
7
+ ![License](https://img.shields.io/badge/license-MIT-green)
8
+ ![Version](https://img.shields.io/badge/version-0.2.0-orange)
9
+ ![Development Status](https://img.shields.io/badge/status-alpha-yellow)
10
+
11
+ A data processing library for computer vision datasets, focusing on format conversion and visualization between LabelMe, COCO, and YOLO formats. Provides both a CLI and Python API.
12
+
13
+ ## Table of Contents
14
+
15
+ - [DataFlow-CV](#dataflow-cv)
16
+ - [Table of Contents](#table-of-contents)
17
+ - [Project Structure](#project-structure)
18
+ - [Requirements](#requirements)
19
+ - [License](#license)
20
+
21
+ ## Project Structure
22
+
23
+ ```
24
+ dataflow/
25
+ ├── __init__.py # Package exports and convenience functions
26
+ ├── cli.py # Command-line interface
27
+ ├── config.py # Configuration management
28
+ ├── convert/ # Format conversion module
29
+ │ ├── __init__.py
30
+ │ ├── base.py # Converter base class
31
+ │ ├── coco_to_yolo.py # COCO to YOLO converter
32
+ │ └── yolo_to_coco.py # YOLO to COCO converter
33
+ tests/
34
+ ├── __init__.py
35
+ ├── convert/ # Conversion tests
36
+ │ ├── __init__.py
37
+ │ ├── test_coco_to_yolo.py
38
+ │ └── test_yolo_to_coco.py
39
+ ├── run_tests.py # Test runner
40
+ samples/
41
+ ├── __init__.py
42
+ ├── cli/ # CLI usage examples
43
+ │ ├── __init__.py
44
+ │ └── convert/
45
+ │ ├── cli_coco_to_yolo.py
46
+ │ └── cli_yolo_to_coco.py
47
+ └── api/ # Python API examples
48
+ ├── __init__.py
49
+ └── convert/
50
+ ├── api_coco_to_yolo.py
51
+ └── api_yolo_to_coco.py
52
+ ```
53
+
54
+ ## Requirements
55
+
56
+ ### Core Dependencies
57
+ - Python 3.8 or higher
58
+ - Linux environment (POSIX compatible, assumes POSIX paths)
59
+ - `click` >= 8.1.0 – CLI framework
60
+ - `numpy` >= 2.0.0 – numerical operations
61
+ - `opencv-python` >= 4.8.0 – image processing (optional, used for some image operations)
62
+ - `Pillow` >= 10.0.0 – image reading (optional, used for reading image dimensions)
63
+
64
+ ## Quick Start
65
+
66
+ ### Installation
67
+
68
+ ```bash
69
+ # Install
70
+ pip install .
71
+ ```
72
+
73
+ ### Command Line Usage
74
+
75
+ Global options: `--verbose` (`-v`) for progress output, `--overwrite` to replace existing files.
76
+
77
+ ```bash
78
+ # COCO to YOLO conversion
79
+ dataflow convert coco2yolo annotations.json output_dir/
80
+
81
+ # YOLO to COCO conversion
82
+ dataflow convert yolo2coco images/ labels/ classes.names output.json
83
+
84
+ # Show configuration
85
+ dataflow config
86
+
87
+ # Get help
88
+ dataflow --help
89
+ dataflow convert coco2yolo --help
90
+ ```
91
+
92
+ See the [CLI Reference](#cli-reference) below for detailed usage.
93
+
94
+ ### Python API Usage
95
+
96
+ ```python
97
+ import dataflow
98
+
99
+ # COCO to YOLO
100
+ result = dataflow.coco_to_yolo("annotations.json", "output_dir")
101
+ print(f"Processed {result['images_processed']} images")
102
+
103
+ # YOLO to COCO
104
+ result = dataflow.yolo_to_coco("images/", "labels/", "classes.names", "output.json")
105
+ print(f"Generated {result['annotations_processed']} annotations")
106
+ ```
107
+
108
+ ### CLI Reference
109
+
110
+ The CLI follows a hierarchical structure: `dataflow <main‑task> <sub‑task> [arguments]`. Global options can be placed before the main task.
111
+
112
+ #### Global Options
113
+ - `--verbose`, `-v`: Enable verbose output (progress information)
114
+ - `--overwrite`: Overwrite existing files
115
+
116
+ #### Conversion Commands
117
+
118
+ **COCO to YOLO**
119
+ ```bash
120
+ dataflow convert coco2yolo COCO_JSON_PATH OUTPUT_DIR [--segmentation]
121
+ ```
122
+ - `COCO_JSON_PATH`: Path to COCO JSON annotation file
123
+ - `OUTPUT_DIR`: Directory where `labels/` and `class.names` will be created
124
+ - `--segmentation`, `-s`: Handle segmentation annotations (polygon format)
125
+
126
+ **YOLO to COCO**
127
+ ```bash
128
+ dataflow convert yolo2coco IMAGE_DIR YOLO_LABELS_DIR YOLO_CLASS_PATH COCO_JSON_PATH
129
+ ```
130
+ - `IMAGE_DIR`: Directory containing image files
131
+ - `YOLO_LABELS_DIR`: Directory containing YOLO label files (`.txt`)
132
+ - `YOLO_CLASS_PATH`: Path to YOLO class names file (e.g., `class.names`)
133
+ - `COCO_JSON_PATH`: Path to save COCO JSON file
134
+
135
+ #### Configuration Command
136
+ ```bash
137
+ dataflow config
138
+ ```
139
+ Shows the current configuration (file extensions, default values, CLI context).
140
+
141
+ #### Getting Help
142
+ ```bash
143
+ dataflow --help
144
+ dataflow convert --help
145
+ dataflow convert coco2yolo --help
146
+ dataflow convert yolo2coco --help
147
+ ```
148
+
149
+ ### Running Tests
150
+
151
+ ```bash
152
+ # Run all tests
153
+ python tests/run_tests.py
154
+
155
+ # Run specific test
156
+ python tests/run_tests.py --test TestCocoToYoloConverter
157
+
158
+ # With verbose output
159
+ python tests/run_tests.py -v
160
+ ```
161
+
162
+ ### Examples
163
+
164
+ Check the `samples/` directory for detailed usage examples:
165
+
166
+ - `samples/cli/convert/` - CLI usage examples
167
+ - `samples/api/convert/` - Python API examples
168
+
169
+ ## License
170
+
171
+ [MIT License](LICENSE) © 2026 zjykzj
@@ -0,0 +1,150 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ """
4
+ @Time : 2026/3/8 20:41
5
+ @File : __init__.py
6
+ @Author : zj
7
+ @Description: DataFlow-CV: A data processing library for computer vision datasets
8
+ """
9
+
10
+ __version__ = "0.2.0"
11
+ __author__ = "DataFlow Team"
12
+ __description__ = "A data processing library for computer vision datasets"
13
+
14
+ # Configuration
15
+ from .config import Config
16
+
17
+ # Converters
18
+ from .convert.coco_to_yolo import CocoToYoloConverter
19
+ from .convert.yolo_to_coco import YoloToCocoConverter
20
+
21
+ # Visualizers
22
+ from .visualize.yolo import YoloVisualizer
23
+ from .visualize.coco import CocoVisualizer
24
+
25
+ # Base classes
26
+ from .convert.base import BaseConverter
27
+
28
+ # CLI
29
+ from .cli import cli, main
30
+
31
+ # Convenience functions for common conversions
32
+ def coco_to_yolo(coco_json_path: str, output_dir: str, **kwargs):
33
+ """
34
+ Convert COCO JSON to YOLO format.
35
+
36
+ Args:
37
+ coco_json_path: Path to COCO JSON file
38
+ output_dir: Output directory where labels/ and class.names will be created
39
+ **kwargs: Additional options passed to CocoToYoloConverter.convert()
40
+
41
+ Returns:
42
+ Dictionary with conversion statistics
43
+ """
44
+ converter = CocoToYoloConverter()
45
+ return converter.convert(coco_json_path, output_dir, **kwargs)
46
+
47
+
48
+ def yolo_to_coco(
49
+ image_dir: str,
50
+ yolo_labels_dir: str,
51
+ yolo_class_path: str,
52
+ coco_json_path: str,
53
+ **kwargs
54
+ ):
55
+ """
56
+ Convert YOLO format to COCO JSON.
57
+
58
+ Args:
59
+ image_dir: Directory containing image files
60
+ yolo_labels_dir: Directory containing YOLO label files
61
+ yolo_class_path: Path to YOLO class names file
62
+ coco_json_path: Path to save COCO JSON file
63
+ **kwargs: Additional options passed to YoloToCocoConverter.convert()
64
+
65
+ Returns:
66
+ Dictionary with conversion statistics
67
+ """
68
+ converter = YoloToCocoConverter()
69
+ return converter.convert(
70
+ image_dir, yolo_labels_dir, yolo_class_path, coco_json_path, **kwargs
71
+ )
72
+
73
+
74
+ # Convenience functions for visualization
75
+ def visualize_yolo(
76
+ image_dir: str,
77
+ label_dir: str,
78
+ class_path: str,
79
+ save_dir: str = None,
80
+ **kwargs
81
+ ):
82
+ """
83
+ Visualize YOLO format annotations.
84
+
85
+ Args:
86
+ image_dir: Directory containing image files
87
+ label_dir: Directory containing YOLO label files
88
+ class_path: Path to class names file (e.g., class.names)
89
+ save_dir: Directory to save visualized images (optional)
90
+ **kwargs: Additional options passed to YoloVisualizer.visualize()
91
+
92
+ Returns:
93
+ Dictionary with visualization statistics
94
+ """
95
+ visualizer = YoloVisualizer(**kwargs)
96
+ return visualizer.visualize(image_dir, label_dir, class_path, save_dir)
97
+
98
+
99
+ def visualize_coco(
100
+ image_dir: str,
101
+ annotation_json: str,
102
+ save_dir: str = None,
103
+ **kwargs
104
+ ):
105
+ """
106
+ Visualize COCO format annotations.
107
+
108
+ Args:
109
+ image_dir: Directory containing image files
110
+ annotation_json: Path to COCO JSON annotation file
111
+ save_dir: Directory to save visualized images (optional)
112
+ **kwargs: Additional options passed to CocoVisualizer.visualize()
113
+
114
+ Returns:
115
+ Dictionary with visualization statistics
116
+ """
117
+ visualizer = CocoVisualizer(**kwargs)
118
+ return visualizer.visualize(image_dir, annotation_json, save_dir)
119
+
120
+
121
+ __all__ = [
122
+ # Configuration
123
+ "Config",
124
+
125
+ # Converters
126
+ "CocoToYoloConverter",
127
+ "YoloToCocoConverter",
128
+
129
+ # Visualizers
130
+ "YoloVisualizer",
131
+ "CocoVisualizer",
132
+
133
+ # Base classes
134
+ "BaseConverter",
135
+
136
+ # CLI
137
+ "cli",
138
+ "main",
139
+
140
+ # Convenience functions
141
+ "coco_to_yolo",
142
+ "yolo_to_coco",
143
+ "visualize_yolo",
144
+ "visualize_coco",
145
+
146
+ # Metadata
147
+ "__version__",
148
+ "__author__",
149
+ "__description__",
150
+ ]