segment-toolkit 1.0.0__tar.gz → 1.0.1__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.
- {segment_toolkit-1.0.0 → segment_toolkit-1.0.1}/PKG-INFO +34 -27
- {segment_toolkit-1.0.0 → segment_toolkit-1.0.1}/README.md +25 -25
- {segment_toolkit-1.0.0 → segment_toolkit-1.0.1}/segment_toolkit/__init__.py +1 -1
- segment_toolkit-1.0.1/segment_toolkit/__main__.py +17 -0
- {segment_toolkit-1.0.0 → segment_toolkit-1.0.1}/segment_toolkit.egg-info/PKG-INFO +34 -27
- {segment_toolkit-1.0.0 → segment_toolkit-1.0.1}/segment_toolkit.egg-info/SOURCES.txt +1 -0
- {segment_toolkit-1.0.0 → segment_toolkit-1.0.1}/setup.py +8 -2
- {segment_toolkit-1.0.0 → segment_toolkit-1.0.1}/segment_toolkit/cli.py +0 -0
- {segment_toolkit-1.0.0 → segment_toolkit-1.0.1}/segment_toolkit/helpers.py +0 -0
- {segment_toolkit-1.0.0 → segment_toolkit-1.0.1}/segment_toolkit/source.py +0 -0
- {segment_toolkit-1.0.0 → segment_toolkit-1.0.1}/segment_toolkit.egg-info/dependency_links.txt +0 -0
- {segment_toolkit-1.0.0 → segment_toolkit-1.0.1}/segment_toolkit.egg-info/entry_points.txt +0 -0
- {segment_toolkit-1.0.0 → segment_toolkit-1.0.1}/segment_toolkit.egg-info/requires.txt +0 -0
- {segment_toolkit-1.0.0 → segment_toolkit-1.0.1}/segment_toolkit.egg-info/top_level.txt +0 -0
- {segment_toolkit-1.0.0 → segment_toolkit-1.0.1}/setup.cfg +0 -0
- {segment_toolkit-1.0.0 → segment_toolkit-1.0.1}/tests/test_converter.py +0 -0
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: segment_toolkit
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.1
|
|
4
4
|
Summary: A Python toolkit to convert between binary segmentation masks and YOLO labels
|
|
5
|
-
|
|
5
|
+
Home-page: https://github.com/zkzkGamal/LabelFile-for-yoloModel
|
|
6
|
+
Author: Zakria Gamal
|
|
7
|
+
Author-email: zekogml11@gmail.com
|
|
8
|
+
Project-URL: Source Code, https://github.com/zkzkGamal/LabelFile-for-yoloModel
|
|
9
|
+
Project-URL: Bug Tracker, https://github.com/zkzkGamal/LabelFile-for-yoloModel/issues
|
|
6
10
|
Requires-Python: >=3.6
|
|
7
11
|
Description-Content-Type: text/markdown
|
|
8
12
|
Requires-Dist: numpy
|
|
@@ -11,33 +15,36 @@ Requires-Dist: pillow
|
|
|
11
15
|
Requires-Dist: pandas
|
|
12
16
|
Requires-Dist: matplotlib
|
|
13
17
|
Dynamic: author
|
|
18
|
+
Dynamic: author-email
|
|
14
19
|
Dynamic: description
|
|
15
20
|
Dynamic: description-content-type
|
|
21
|
+
Dynamic: home-page
|
|
22
|
+
Dynamic: project-url
|
|
16
23
|
Dynamic: requires-dist
|
|
17
24
|
Dynamic: requires-python
|
|
18
25
|
Dynamic: summary
|
|
19
26
|
|
|
20
|
-
# Segment Toolkit
|
|
27
|
+
# Segment Toolkit
|
|
21
28
|
|
|
22
|
-
A modern, robust, and premium Python package designed to bridge the gap between pixel-level
|
|
29
|
+
A modern, robust, and premium Python package designed to bridge the gap between pixel-level binary segmentation masks and YOLO bounding box labels. It provides a bidirectional pipeline with exception handling, extensive logging, a command-line interface (CLI), and a Python API.
|
|
23
30
|
|
|
24
31
|
---
|
|
25
32
|
|
|
26
|
-
##
|
|
33
|
+
## Features
|
|
27
34
|
|
|
28
35
|
- **Bidirectional Conversion**:
|
|
29
36
|
- **Forward Pipeline**: Convert binary masks to YOLO format labels (supports standard axis-aligned or advanced minimum area rotated bounding boxes).
|
|
30
37
|
- **Reverse Pipeline**: Reconstruct binary masks from YOLO labels.
|
|
31
|
-
- **Automatic Dependency Installer**: Missing required packages (
|
|
38
|
+
- **Automatic Dependency Installer**: Missing required packages (numpy, opencv-python, pillow, pandas, matplotlib) are automatically detected and installed via pip upon package import or script execution.
|
|
32
39
|
- **Robust Exception Handling**: Try-catch blocks wrapped around file I/O, contour finding, and resizing to prevent application crashes on corrupted or missing files.
|
|
33
|
-
- **Dynamic Dataset Matching**: Read classification mappings (in
|
|
34
|
-
- **YOLO Dataset Splitting**: Automatically shuffles and partitions images
|
|
40
|
+
- **Dynamic Dataset Matching**: Read classification mappings (in CSV or JSON format) to automatically assign multi-class IDs matching standard dataset schemas (like the ISIC dataset).
|
|
41
|
+
- **YOLO Dataset Splitting**: Automatically shuffles and partitions images and labels into training and testing sets with customizable split ratios, creating standard data.yaml configs.
|
|
35
42
|
- **Overlay Visualizer**: Overlay bounding boxes and class indicators directly onto source images for annotation inspection.
|
|
36
|
-
- **Dual Interface**: Use as a command-line application (
|
|
43
|
+
- **Dual Interface**: Use as a command-line application (segment-toolkit) or import as a Python library (import segment_toolkit).
|
|
37
44
|
|
|
38
45
|
---
|
|
39
46
|
|
|
40
|
-
##
|
|
47
|
+
## Installation
|
|
41
48
|
|
|
42
49
|
To install the toolkit locally in editable mode (missing dependencies will install automatically):
|
|
43
50
|
|
|
@@ -55,11 +62,11 @@ pip install .
|
|
|
55
62
|
|
|
56
63
|
---
|
|
57
64
|
|
|
58
|
-
##
|
|
65
|
+
## Usage
|
|
59
66
|
|
|
60
67
|
### 1. Command Line Interface (CLI)
|
|
61
68
|
|
|
62
|
-
The package installs a console script called
|
|
69
|
+
The package installs a console script called segment-toolkit.
|
|
63
70
|
|
|
64
71
|
#### Convert Masks to YOLO Labels
|
|
65
72
|
- **Single File Conversion**:
|
|
@@ -81,8 +88,8 @@ The package installs a console script called `segment-toolkit`.
|
|
|
81
88
|
```
|
|
82
89
|
|
|
83
90
|
- **Options**:
|
|
84
|
-
- `--rotated`: Use rotated minimum area rectangles (
|
|
85
|
-
- `--resize WIDTH HEIGHT`: Set target size for image and mask resizing (default:
|
|
91
|
+
- `--rotated`: Use rotated minimum area rectangles (cv2.minAreaRect) instead of standard axis-aligned rectangles.
|
|
92
|
+
- `--resize WIDTH HEIGHT`: Set target size for image and mask resizing (default: 640 640).
|
|
86
93
|
|
|
87
94
|
#### Convert YOLO Labels to Masks
|
|
88
95
|
- **Single File Conversion**:
|
|
@@ -109,7 +116,7 @@ segment-toolkit visualize \
|
|
|
109
116
|
```
|
|
110
117
|
|
|
111
118
|
#### Split Dataset
|
|
112
|
-
Organize folders into YOLO-compliant structure (
|
|
119
|
+
Organize folders into YOLO-compliant structure (dataset/train and dataset/test splits) and output data.yaml:
|
|
113
120
|
```bash
|
|
114
121
|
segment-toolkit split \
|
|
115
122
|
--images images/ \
|
|
@@ -121,13 +128,13 @@ segment-toolkit split \
|
|
|
121
128
|
|
|
122
129
|
---
|
|
123
130
|
|
|
124
|
-
|
|
131
|
+
## Ground Truth Formats
|
|
125
132
|
|
|
126
|
-
The
|
|
133
|
+
The --ground-truth parameter in batch conversion supports both CSV and JSON formats.
|
|
127
134
|
|
|
128
135
|
#### CSV Format
|
|
129
|
-
Assumes the first column contains the image identifier/filename, and the subsequent columns represent binary indicator classes (where
|
|
130
|
-
Example
|
|
136
|
+
Assumes the first column contains the image identifier/filename, and the subsequent columns represent binary indicator classes (where 1 indicates class presence).
|
|
137
|
+
Example GroundTruth.csv:
|
|
131
138
|
```csv
|
|
132
139
|
image,MEL,NV,BCC,AKIEC,BKL,DF,VASC
|
|
133
140
|
ISIC_0024306,0,1,0,0,0,0,0
|
|
@@ -164,11 +171,11 @@ Supports three distinct schemas:
|
|
|
164
171
|
]
|
|
165
172
|
```
|
|
166
173
|
|
|
167
|
-
*Note: Class name strings (like
|
|
174
|
+
*Note: Class name strings (like "MEL", "NV") are automatically mapped to standard ISIC IDs (AKIEC=0, BCC=1, BKL=2, DF=3, MEL=4, NV=5, VASC=6). Custom column names default to index-based IDs.*
|
|
168
175
|
|
|
169
176
|
---
|
|
170
177
|
|
|
171
|
-
|
|
178
|
+
## Python API
|
|
172
179
|
|
|
173
180
|
Import classes directly into your code to programmatically build custom pipelines:
|
|
174
181
|
|
|
@@ -195,23 +202,23 @@ yolo_conv.convert_dataset(
|
|
|
195
202
|
|
|
196
203
|
---
|
|
197
204
|
|
|
198
|
-
##
|
|
205
|
+
## Technical Details
|
|
199
206
|
|
|
200
207
|
### Coordinate Conversion Math
|
|
201
208
|
|
|
202
209
|
#### Bounding Box Center Calculation (Pixel Space)
|
|
203
|
-
For standard bounding boxes, the pixel coordinates from
|
|
210
|
+
For standard bounding boxes, the pixel coordinates from boundingRect are (xmin, ymin, w_pixel, h_pixel).
|
|
204
211
|
$$\text{Center } X \quad x_{center} = x_{min} + \frac{w_{pixel}}{2.0}$$
|
|
205
212
|
$$\text{Center } Y \quad y_{center} = y_{min} + \frac{h_{pixel}}{2.0}$$
|
|
206
213
|
|
|
207
214
|
#### Coordinate Normalization (YOLO Format)
|
|
208
|
-
All coordinates are normalized to the range
|
|
215
|
+
All coordinates are normalized to the range [0.0, 1.0]:
|
|
209
216
|
$$x_{norm} = \frac{x_{center}}{img\_width}, \quad y_{norm} = \frac{y_{center}}{img\_height}$$
|
|
210
217
|
$$w_{norm} = \frac{w_{pixel}}{img\_width}, \quad h_{norm} = \frac{h_{pixel}}{img\_height}$$
|
|
211
218
|
|
|
212
219
|
---
|
|
213
220
|
|
|
214
|
-
##
|
|
221
|
+
## Author
|
|
215
222
|
**Zakria Gamal**
|
|
216
|
-
- Computer Vision
|
|
217
|
-
-
|
|
223
|
+
- Computer Vision and AI Engineer
|
|
224
|
+
- LinkedIn: [Zakria Gamal](https://www.linkedin.com/in/zkaria-gamal-82b486267/)
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
# Segment Toolkit
|
|
1
|
+
# Segment Toolkit
|
|
2
2
|
|
|
3
|
-
A modern, robust, and premium Python package designed to bridge the gap between pixel-level
|
|
3
|
+
A modern, robust, and premium Python package designed to bridge the gap between pixel-level binary segmentation masks and YOLO bounding box labels. It provides a bidirectional pipeline with exception handling, extensive logging, a command-line interface (CLI), and a Python API.
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Features
|
|
8
8
|
|
|
9
9
|
- **Bidirectional Conversion**:
|
|
10
10
|
- **Forward Pipeline**: Convert binary masks to YOLO format labels (supports standard axis-aligned or advanced minimum area rotated bounding boxes).
|
|
11
11
|
- **Reverse Pipeline**: Reconstruct binary masks from YOLO labels.
|
|
12
|
-
- **Automatic Dependency Installer**: Missing required packages (
|
|
12
|
+
- **Automatic Dependency Installer**: Missing required packages (numpy, opencv-python, pillow, pandas, matplotlib) are automatically detected and installed via pip upon package import or script execution.
|
|
13
13
|
- **Robust Exception Handling**: Try-catch blocks wrapped around file I/O, contour finding, and resizing to prevent application crashes on corrupted or missing files.
|
|
14
|
-
- **Dynamic Dataset Matching**: Read classification mappings (in
|
|
15
|
-
- **YOLO Dataset Splitting**: Automatically shuffles and partitions images
|
|
14
|
+
- **Dynamic Dataset Matching**: Read classification mappings (in CSV or JSON format) to automatically assign multi-class IDs matching standard dataset schemas (like the ISIC dataset).
|
|
15
|
+
- **YOLO Dataset Splitting**: Automatically shuffles and partitions images and labels into training and testing sets with customizable split ratios, creating standard data.yaml configs.
|
|
16
16
|
- **Overlay Visualizer**: Overlay bounding boxes and class indicators directly onto source images for annotation inspection.
|
|
17
|
-
- **Dual Interface**: Use as a command-line application (
|
|
17
|
+
- **Dual Interface**: Use as a command-line application (segment-toolkit) or import as a Python library (import segment_toolkit).
|
|
18
18
|
|
|
19
19
|
---
|
|
20
20
|
|
|
21
|
-
##
|
|
21
|
+
## Installation
|
|
22
22
|
|
|
23
23
|
To install the toolkit locally in editable mode (missing dependencies will install automatically):
|
|
24
24
|
|
|
@@ -36,11 +36,11 @@ pip install .
|
|
|
36
36
|
|
|
37
37
|
---
|
|
38
38
|
|
|
39
|
-
##
|
|
39
|
+
## Usage
|
|
40
40
|
|
|
41
41
|
### 1. Command Line Interface (CLI)
|
|
42
42
|
|
|
43
|
-
The package installs a console script called
|
|
43
|
+
The package installs a console script called segment-toolkit.
|
|
44
44
|
|
|
45
45
|
#### Convert Masks to YOLO Labels
|
|
46
46
|
- **Single File Conversion**:
|
|
@@ -62,8 +62,8 @@ The package installs a console script called `segment-toolkit`.
|
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
- **Options**:
|
|
65
|
-
- `--rotated`: Use rotated minimum area rectangles (
|
|
66
|
-
- `--resize WIDTH HEIGHT`: Set target size for image and mask resizing (default:
|
|
65
|
+
- `--rotated`: Use rotated minimum area rectangles (cv2.minAreaRect) instead of standard axis-aligned rectangles.
|
|
66
|
+
- `--resize WIDTH HEIGHT`: Set target size for image and mask resizing (default: 640 640).
|
|
67
67
|
|
|
68
68
|
#### Convert YOLO Labels to Masks
|
|
69
69
|
- **Single File Conversion**:
|
|
@@ -90,7 +90,7 @@ segment-toolkit visualize \
|
|
|
90
90
|
```
|
|
91
91
|
|
|
92
92
|
#### Split Dataset
|
|
93
|
-
Organize folders into YOLO-compliant structure (
|
|
93
|
+
Organize folders into YOLO-compliant structure (dataset/train and dataset/test splits) and output data.yaml:
|
|
94
94
|
```bash
|
|
95
95
|
segment-toolkit split \
|
|
96
96
|
--images images/ \
|
|
@@ -102,13 +102,13 @@ segment-toolkit split \
|
|
|
102
102
|
|
|
103
103
|
---
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
## Ground Truth Formats
|
|
106
106
|
|
|
107
|
-
The
|
|
107
|
+
The --ground-truth parameter in batch conversion supports both CSV and JSON formats.
|
|
108
108
|
|
|
109
109
|
#### CSV Format
|
|
110
|
-
Assumes the first column contains the image identifier/filename, and the subsequent columns represent binary indicator classes (where
|
|
111
|
-
Example
|
|
110
|
+
Assumes the first column contains the image identifier/filename, and the subsequent columns represent binary indicator classes (where 1 indicates class presence).
|
|
111
|
+
Example GroundTruth.csv:
|
|
112
112
|
```csv
|
|
113
113
|
image,MEL,NV,BCC,AKIEC,BKL,DF,VASC
|
|
114
114
|
ISIC_0024306,0,1,0,0,0,0,0
|
|
@@ -145,11 +145,11 @@ Supports three distinct schemas:
|
|
|
145
145
|
]
|
|
146
146
|
```
|
|
147
147
|
|
|
148
|
-
*Note: Class name strings (like
|
|
148
|
+
*Note: Class name strings (like "MEL", "NV") are automatically mapped to standard ISIC IDs (AKIEC=0, BCC=1, BKL=2, DF=3, MEL=4, NV=5, VASC=6). Custom column names default to index-based IDs.*
|
|
149
149
|
|
|
150
150
|
---
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
## Python API
|
|
153
153
|
|
|
154
154
|
Import classes directly into your code to programmatically build custom pipelines:
|
|
155
155
|
|
|
@@ -176,23 +176,23 @@ yolo_conv.convert_dataset(
|
|
|
176
176
|
|
|
177
177
|
---
|
|
178
178
|
|
|
179
|
-
##
|
|
179
|
+
## Technical Details
|
|
180
180
|
|
|
181
181
|
### Coordinate Conversion Math
|
|
182
182
|
|
|
183
183
|
#### Bounding Box Center Calculation (Pixel Space)
|
|
184
|
-
For standard bounding boxes, the pixel coordinates from
|
|
184
|
+
For standard bounding boxes, the pixel coordinates from boundingRect are (xmin, ymin, w_pixel, h_pixel).
|
|
185
185
|
$$\text{Center } X \quad x_{center} = x_{min} + \frac{w_{pixel}}{2.0}$$
|
|
186
186
|
$$\text{Center } Y \quad y_{center} = y_{min} + \frac{h_{pixel}}{2.0}$$
|
|
187
187
|
|
|
188
188
|
#### Coordinate Normalization (YOLO Format)
|
|
189
|
-
All coordinates are normalized to the range
|
|
189
|
+
All coordinates are normalized to the range [0.0, 1.0]:
|
|
190
190
|
$$x_{norm} = \frac{x_{center}}{img\_width}, \quad y_{norm} = \frac{y_{center}}{img\_height}$$
|
|
191
191
|
$$w_{norm} = \frac{w_{pixel}}{img\_width}, \quad h_{norm} = \frac{h_{pixel}}{img\_height}$$
|
|
192
192
|
|
|
193
193
|
---
|
|
194
194
|
|
|
195
|
-
##
|
|
195
|
+
## Author
|
|
196
196
|
**Zakria Gamal**
|
|
197
|
-
- Computer Vision
|
|
198
|
-
-
|
|
197
|
+
- Computer Vision and AI Engineer
|
|
198
|
+
- LinkedIn: [Zakria Gamal](https://www.linkedin.com/in/zkaria-gamal-82b486267/)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Main execution entry point for segment_toolkit.
|
|
3
|
+
Enables running the package directly via `python3 -m segment_toolkit` or `python3 segment_toolkit`.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import sys
|
|
7
|
+
import os
|
|
8
|
+
|
|
9
|
+
# Add the parent folder of segment_toolkit to sys.path to resolve absolute imports
|
|
10
|
+
parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
11
|
+
if parent_dir not in sys.path:
|
|
12
|
+
sys.path.insert(0, parent_dir)
|
|
13
|
+
|
|
14
|
+
from segment_toolkit.cli import main
|
|
15
|
+
|
|
16
|
+
if __name__ == "__main__":
|
|
17
|
+
sys.exit(main())
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: segment_toolkit
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.1
|
|
4
4
|
Summary: A Python toolkit to convert between binary segmentation masks and YOLO labels
|
|
5
|
-
|
|
5
|
+
Home-page: https://github.com/zkzkGamal/LabelFile-for-yoloModel
|
|
6
|
+
Author: Zakria Gamal
|
|
7
|
+
Author-email: zekogml11@gmail.com
|
|
8
|
+
Project-URL: Source Code, https://github.com/zkzkGamal/LabelFile-for-yoloModel
|
|
9
|
+
Project-URL: Bug Tracker, https://github.com/zkzkGamal/LabelFile-for-yoloModel/issues
|
|
6
10
|
Requires-Python: >=3.6
|
|
7
11
|
Description-Content-Type: text/markdown
|
|
8
12
|
Requires-Dist: numpy
|
|
@@ -11,33 +15,36 @@ Requires-Dist: pillow
|
|
|
11
15
|
Requires-Dist: pandas
|
|
12
16
|
Requires-Dist: matplotlib
|
|
13
17
|
Dynamic: author
|
|
18
|
+
Dynamic: author-email
|
|
14
19
|
Dynamic: description
|
|
15
20
|
Dynamic: description-content-type
|
|
21
|
+
Dynamic: home-page
|
|
22
|
+
Dynamic: project-url
|
|
16
23
|
Dynamic: requires-dist
|
|
17
24
|
Dynamic: requires-python
|
|
18
25
|
Dynamic: summary
|
|
19
26
|
|
|
20
|
-
# Segment Toolkit
|
|
27
|
+
# Segment Toolkit
|
|
21
28
|
|
|
22
|
-
A modern, robust, and premium Python package designed to bridge the gap between pixel-level
|
|
29
|
+
A modern, robust, and premium Python package designed to bridge the gap between pixel-level binary segmentation masks and YOLO bounding box labels. It provides a bidirectional pipeline with exception handling, extensive logging, a command-line interface (CLI), and a Python API.
|
|
23
30
|
|
|
24
31
|
---
|
|
25
32
|
|
|
26
|
-
##
|
|
33
|
+
## Features
|
|
27
34
|
|
|
28
35
|
- **Bidirectional Conversion**:
|
|
29
36
|
- **Forward Pipeline**: Convert binary masks to YOLO format labels (supports standard axis-aligned or advanced minimum area rotated bounding boxes).
|
|
30
37
|
- **Reverse Pipeline**: Reconstruct binary masks from YOLO labels.
|
|
31
|
-
- **Automatic Dependency Installer**: Missing required packages (
|
|
38
|
+
- **Automatic Dependency Installer**: Missing required packages (numpy, opencv-python, pillow, pandas, matplotlib) are automatically detected and installed via pip upon package import or script execution.
|
|
32
39
|
- **Robust Exception Handling**: Try-catch blocks wrapped around file I/O, contour finding, and resizing to prevent application crashes on corrupted or missing files.
|
|
33
|
-
- **Dynamic Dataset Matching**: Read classification mappings (in
|
|
34
|
-
- **YOLO Dataset Splitting**: Automatically shuffles and partitions images
|
|
40
|
+
- **Dynamic Dataset Matching**: Read classification mappings (in CSV or JSON format) to automatically assign multi-class IDs matching standard dataset schemas (like the ISIC dataset).
|
|
41
|
+
- **YOLO Dataset Splitting**: Automatically shuffles and partitions images and labels into training and testing sets with customizable split ratios, creating standard data.yaml configs.
|
|
35
42
|
- **Overlay Visualizer**: Overlay bounding boxes and class indicators directly onto source images for annotation inspection.
|
|
36
|
-
- **Dual Interface**: Use as a command-line application (
|
|
43
|
+
- **Dual Interface**: Use as a command-line application (segment-toolkit) or import as a Python library (import segment_toolkit).
|
|
37
44
|
|
|
38
45
|
---
|
|
39
46
|
|
|
40
|
-
##
|
|
47
|
+
## Installation
|
|
41
48
|
|
|
42
49
|
To install the toolkit locally in editable mode (missing dependencies will install automatically):
|
|
43
50
|
|
|
@@ -55,11 +62,11 @@ pip install .
|
|
|
55
62
|
|
|
56
63
|
---
|
|
57
64
|
|
|
58
|
-
##
|
|
65
|
+
## Usage
|
|
59
66
|
|
|
60
67
|
### 1. Command Line Interface (CLI)
|
|
61
68
|
|
|
62
|
-
The package installs a console script called
|
|
69
|
+
The package installs a console script called segment-toolkit.
|
|
63
70
|
|
|
64
71
|
#### Convert Masks to YOLO Labels
|
|
65
72
|
- **Single File Conversion**:
|
|
@@ -81,8 +88,8 @@ The package installs a console script called `segment-toolkit`.
|
|
|
81
88
|
```
|
|
82
89
|
|
|
83
90
|
- **Options**:
|
|
84
|
-
- `--rotated`: Use rotated minimum area rectangles (
|
|
85
|
-
- `--resize WIDTH HEIGHT`: Set target size for image and mask resizing (default:
|
|
91
|
+
- `--rotated`: Use rotated minimum area rectangles (cv2.minAreaRect) instead of standard axis-aligned rectangles.
|
|
92
|
+
- `--resize WIDTH HEIGHT`: Set target size for image and mask resizing (default: 640 640).
|
|
86
93
|
|
|
87
94
|
#### Convert YOLO Labels to Masks
|
|
88
95
|
- **Single File Conversion**:
|
|
@@ -109,7 +116,7 @@ segment-toolkit visualize \
|
|
|
109
116
|
```
|
|
110
117
|
|
|
111
118
|
#### Split Dataset
|
|
112
|
-
Organize folders into YOLO-compliant structure (
|
|
119
|
+
Organize folders into YOLO-compliant structure (dataset/train and dataset/test splits) and output data.yaml:
|
|
113
120
|
```bash
|
|
114
121
|
segment-toolkit split \
|
|
115
122
|
--images images/ \
|
|
@@ -121,13 +128,13 @@ segment-toolkit split \
|
|
|
121
128
|
|
|
122
129
|
---
|
|
123
130
|
|
|
124
|
-
|
|
131
|
+
## Ground Truth Formats
|
|
125
132
|
|
|
126
|
-
The
|
|
133
|
+
The --ground-truth parameter in batch conversion supports both CSV and JSON formats.
|
|
127
134
|
|
|
128
135
|
#### CSV Format
|
|
129
|
-
Assumes the first column contains the image identifier/filename, and the subsequent columns represent binary indicator classes (where
|
|
130
|
-
Example
|
|
136
|
+
Assumes the first column contains the image identifier/filename, and the subsequent columns represent binary indicator classes (where 1 indicates class presence).
|
|
137
|
+
Example GroundTruth.csv:
|
|
131
138
|
```csv
|
|
132
139
|
image,MEL,NV,BCC,AKIEC,BKL,DF,VASC
|
|
133
140
|
ISIC_0024306,0,1,0,0,0,0,0
|
|
@@ -164,11 +171,11 @@ Supports three distinct schemas:
|
|
|
164
171
|
]
|
|
165
172
|
```
|
|
166
173
|
|
|
167
|
-
*Note: Class name strings (like
|
|
174
|
+
*Note: Class name strings (like "MEL", "NV") are automatically mapped to standard ISIC IDs (AKIEC=0, BCC=1, BKL=2, DF=3, MEL=4, NV=5, VASC=6). Custom column names default to index-based IDs.*
|
|
168
175
|
|
|
169
176
|
---
|
|
170
177
|
|
|
171
|
-
|
|
178
|
+
## Python API
|
|
172
179
|
|
|
173
180
|
Import classes directly into your code to programmatically build custom pipelines:
|
|
174
181
|
|
|
@@ -195,23 +202,23 @@ yolo_conv.convert_dataset(
|
|
|
195
202
|
|
|
196
203
|
---
|
|
197
204
|
|
|
198
|
-
##
|
|
205
|
+
## Technical Details
|
|
199
206
|
|
|
200
207
|
### Coordinate Conversion Math
|
|
201
208
|
|
|
202
209
|
#### Bounding Box Center Calculation (Pixel Space)
|
|
203
|
-
For standard bounding boxes, the pixel coordinates from
|
|
210
|
+
For standard bounding boxes, the pixel coordinates from boundingRect are (xmin, ymin, w_pixel, h_pixel).
|
|
204
211
|
$$\text{Center } X \quad x_{center} = x_{min} + \frac{w_{pixel}}{2.0}$$
|
|
205
212
|
$$\text{Center } Y \quad y_{center} = y_{min} + \frac{h_{pixel}}{2.0}$$
|
|
206
213
|
|
|
207
214
|
#### Coordinate Normalization (YOLO Format)
|
|
208
|
-
All coordinates are normalized to the range
|
|
215
|
+
All coordinates are normalized to the range [0.0, 1.0]:
|
|
209
216
|
$$x_{norm} = \frac{x_{center}}{img\_width}, \quad y_{norm} = \frac{y_{center}}{img\_height}$$
|
|
210
217
|
$$w_{norm} = \frac{w_{pixel}}{img\_width}, \quad h_{norm} = \frac{h_{pixel}}{img\_height}$$
|
|
211
218
|
|
|
212
219
|
---
|
|
213
220
|
|
|
214
|
-
##
|
|
221
|
+
## Author
|
|
215
222
|
**Zakria Gamal**
|
|
216
|
-
- Computer Vision
|
|
217
|
-
-
|
|
223
|
+
- Computer Vision and AI Engineer
|
|
224
|
+
- LinkedIn: [Zakria Gamal](https://www.linkedin.com/in/zkaria-gamal-82b486267/)
|
|
@@ -10,11 +10,17 @@ except FileNotFoundError:
|
|
|
10
10
|
|
|
11
11
|
setup(
|
|
12
12
|
name="segment_toolkit",
|
|
13
|
-
version="1.0.
|
|
13
|
+
version="1.0.1",
|
|
14
14
|
description="A Python toolkit to convert between binary segmentation masks and YOLO labels",
|
|
15
15
|
long_description=long_description,
|
|
16
16
|
long_description_content_type="text/markdown",
|
|
17
|
-
author="
|
|
17
|
+
author="Zakria Gamal",
|
|
18
|
+
author_email="zekogml11@gmail.com",
|
|
19
|
+
url="https://github.com/zkzkGamal/LabelFile-for-yoloModel",
|
|
20
|
+
project_urls={
|
|
21
|
+
"Source Code": "https://github.com/zkzkGamal/LabelFile-for-yoloModel",
|
|
22
|
+
"Bug Tracker": "https://github.com/zkzkGamal/LabelFile-for-yoloModel/issues",
|
|
23
|
+
},
|
|
18
24
|
packages=find_packages(),
|
|
19
25
|
install_requires=[
|
|
20
26
|
"numpy",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{segment_toolkit-1.0.0 → segment_toolkit-1.0.1}/segment_toolkit.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|