pixano.datasets.builders.folders.base
FolderBaseBuilder(media_dir, library_dir, info, dataset_path, dataset_item=None, use_image_name_as_id=False)
Bases: DatasetBuilder
This is a class for building datasets based on a folder structure.
The folder structure should be as follows
- source_dir/{split}/{item}.{ext}
- source_dir/{split}/metadata.jsonl
The metadata file should be a jsonl file with the following format:
[
{
"item": "item1",
"metadata1": "value1",
"metadata2": "value2",
...
"entities": {
"attr1": [val1, val2, ...],
"attr2": [val1, val2, ...],
...
}
},
{
"item": "item2",
"metadata1": "value1",
"metadata2": "value2",
...
"entities": {
"attr1": [val1, val2, ...],
"attr2": [val1, val2, ...],
...
}
},
...
]
Note
Only one view is supported in folder builders. If you give a list of images, it will be put in a mosaic.
Attributes:
Name | Type | Description |
---|---|---|
source_dir |
The source directory for the dataset. |
|
view_name |
The name of the view schema. |
|
view_schema |
The schema of the view. |
|
entity_name |
The name of the entities schema. |
|
entity_schema |
The schema of the entities. |
|
METADATA_FILENAME |
str
|
The metadata filename. |
EXTENSIONS |
list[str]
|
The list of supported extensions. |
WORKSPACE_TYPE |
The workspace type of the dataset. Subclass should override this attribute if workspace is known. |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
media_dir
|
Path | str
|
The global media directory. |
required |
library_dir
|
Path | str
|
The global directory for Pixano datasets library. |
required |
dataset_item
|
type[DatasetItem] | None
|
The dataset item schema. |
None
|
info
|
DatasetInfo
|
User informations (name, description, ...) for the dataset. |
required |
dataset_path
|
Path | str
|
Path to dataset, relative to media_dir. |
required |
use_image_name_as_id
|
bool
|
If True, use image base name as image id. Images MUST have unique base names. When no metadata file exists, also use it as item id, else, use 'item_#' This allows to reuse image embeddings after dataset overwrite. |
False
|
Source code in pixano/datasets/builders/folders/base.py
generate_data()
Generate data from the source directory.
Returns:
Type | Description |
---|---|
Iterator[dict[str, BaseSchema | list[BaseSchema]]]
|
An iterator over the data following the dataset schemas. |
Source code in pixano/datasets/builders/folders/base.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
|