You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add flexible group parameter with stem, sibling, and callable support (closes#39, #51, #41)
Fix group_by_prefix collision bug where startswith matching caused
image_130 to match image_1300. Replace with Path.stem-based grouping
in a new splitfolders/grouping.py module.
Add group= parameter to ratio(), fixed(), and kfold() supporting:
- group="stem": auto-discovers group size by filename stem
- group="sibling": splits parallel directories in lockstep
- group=callable: custom grouping function (enables manifest splits)
Add --group CLI argument, mutually exclusive with --group_prefix.
Update README with grouping documentation and examples.
Occasionally, you may have things that comprise more than a single file (e.g. picture (.png) + annotation (.txt)).
108
-
`splitfolders` lets you split files into equally-sized groups based on their prefix.
109
-
Set `group_prefix` to the length of the group (e.g. `2`).
110
-
But now _all_ files should be part of groups.
112
+
### Grouping files
111
113
112
-
Also, there might be some instances when you have multiple file formats in these folders. Provide one or multiple extension(s) to `formats` for splitting the files in a list (e.g. `formats = ['.jpeg','.png']`).
114
+
When your data has multiple files per sample (e.g. an image and its annotation), you need to keep them together during the split. There are several ways to do this.
115
+
116
+
#### Group by prefix (`group_prefix`)
117
+
118
+
The legacy approach. Set `group_prefix` to the number of files per group (e.g. `2` for image + annotation pairs). Files are grouped by their filename stem (the part before the extension). All stems must have exactly `group_prefix` files.
A simpler alternative to `group_prefix`. Automatically groups files that share the same stem and discovers the group size. No need to specify how many files per group — it just requires every stem to have the same count.
> **Note:**`group_prefix` and `group` are mutually exclusive — setting both raises a `ValueError`.
202
+
203
+
### File formats
204
+
205
+
There might be some instances when you have multiple file formats in these folders. Provide one or multiple extension(s) to `formats` for splitting only certain files (e.g. `formats=['.jpeg', '.png']`).
206
+
207
+
### Move options
113
208
114
209
Set
115
210
-`move=True` or `move='move'` if you want to move the files instead of copying.
0 commit comments