labelr 0.4.0__py3-none-any.whl → 0.4.1__py3-none-any.whl
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.
- labelr/apps/datasets.py +6 -6
- labelr/export.py +40 -3
- {labelr-0.4.0.dist-info → labelr-0.4.1.dist-info}/METADATA +1 -1
- {labelr-0.4.0.dist-info → labelr-0.4.1.dist-info}/RECORD +8 -8
- {labelr-0.4.0.dist-info → labelr-0.4.1.dist-info}/WHEEL +0 -0
- {labelr-0.4.0.dist-info → labelr-0.4.1.dist-info}/entry_points.txt +0 -0
- {labelr-0.4.0.dist-info → labelr-0.4.1.dist-info}/licenses/LICENSE +0 -0
- {labelr-0.4.0.dist-info → labelr-0.4.1.dist-info}/top_level.txt +0 -0
labelr/apps/datasets.py
CHANGED
|
@@ -211,9 +211,9 @@ def export(
|
|
|
211
211
|
from label_studio_sdk.client import LabelStudio
|
|
212
212
|
|
|
213
213
|
from labelr.export import (
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
214
|
+
export_from_hf_to_ultralytics_object_detection,
|
|
215
|
+
export_from_ls_to_hf_object_detection,
|
|
216
|
+
export_from_ls_to_ultralytics_object_detection,
|
|
217
217
|
)
|
|
218
218
|
|
|
219
219
|
if (to == ExportDestination.hf or from_ == ExportSource.hf) and repo_id is None:
|
|
@@ -254,7 +254,7 @@ def export(
|
|
|
254
254
|
ls = LabelStudio(base_url=label_studio_url, api_key=api_key)
|
|
255
255
|
if to == ExportDestination.hf:
|
|
256
256
|
repo_id = typing.cast(str, repo_id)
|
|
257
|
-
|
|
257
|
+
export_from_ls_to_hf_object_detection(
|
|
258
258
|
ls,
|
|
259
259
|
repo_id=repo_id,
|
|
260
260
|
label_names=typing.cast(list[str], label_names_list),
|
|
@@ -263,7 +263,7 @@ def export(
|
|
|
263
263
|
use_aws_cache=use_aws_cache,
|
|
264
264
|
)
|
|
265
265
|
elif to == ExportDestination.ultralytics:
|
|
266
|
-
|
|
266
|
+
export_from_ls_to_ultralytics_object_detection(
|
|
267
267
|
ls,
|
|
268
268
|
typing.cast(Path, output_dir),
|
|
269
269
|
typing.cast(list[str], label_names_list),
|
|
@@ -280,7 +280,7 @@ def export(
|
|
|
280
280
|
"Only object detection task is currently supported with HF source"
|
|
281
281
|
)
|
|
282
282
|
if to == ExportDestination.ultralytics:
|
|
283
|
-
|
|
283
|
+
export_from_hf_to_ultralytics_object_detection(
|
|
284
284
|
typing.cast(str, repo_id),
|
|
285
285
|
typing.cast(Path, output_dir),
|
|
286
286
|
download_images=download_images,
|
labelr/export.py
CHANGED
|
@@ -29,7 +29,7 @@ def _pickle_sample_generator(dir: Path):
|
|
|
29
29
|
yield pickle.load(f)
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
def
|
|
32
|
+
def export_from_ls_to_hf_object_detection(
|
|
33
33
|
ls: LabelStudio,
|
|
34
34
|
repo_id: str,
|
|
35
35
|
label_names: list[str],
|
|
@@ -73,7 +73,7 @@ def export_from_ls_to_hf(
|
|
|
73
73
|
hf_ds.push_to_hub(repo_id, split=split)
|
|
74
74
|
|
|
75
75
|
|
|
76
|
-
def
|
|
76
|
+
def export_from_ls_to_ultralytics_object_detection(
|
|
77
77
|
ls: LabelStudio,
|
|
78
78
|
output_dir: Path,
|
|
79
79
|
label_names: list[str],
|
|
@@ -206,7 +206,7 @@ def export_from_ls_to_ultralytics(
|
|
|
206
206
|
f.write(f" {i}: {label_name}\n")
|
|
207
207
|
|
|
208
208
|
|
|
209
|
-
def
|
|
209
|
+
def export_from_hf_to_ultralytics_object_detection(
|
|
210
210
|
repo_id: str,
|
|
211
211
|
output_dir: Path,
|
|
212
212
|
download_images: bool = True,
|
|
@@ -309,6 +309,43 @@ def export_from_ultralytics_to_hf(
|
|
|
309
309
|
"Only classification task is currently supported for Ultralytics to HF export"
|
|
310
310
|
)
|
|
311
311
|
|
|
312
|
+
if task_type == TaskType.classification:
|
|
313
|
+
export_from_ultralytics_to_hf_classification(
|
|
314
|
+
dataset_dir=dataset_dir,
|
|
315
|
+
repo_id=repo_id,
|
|
316
|
+
label_names=label_names,
|
|
317
|
+
merge_labels=merge_labels,
|
|
318
|
+
is_openfoodfacts_dataset=is_openfoodfacts_dataset,
|
|
319
|
+
openfoodfacts_flavor=openfoodfacts_flavor,
|
|
320
|
+
)
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
def export_from_ultralytics_to_hf_classification(
|
|
324
|
+
dataset_dir: Path,
|
|
325
|
+
repo_id: str,
|
|
326
|
+
label_names: list[str],
|
|
327
|
+
merge_labels: bool = False,
|
|
328
|
+
is_openfoodfacts_dataset: bool = False,
|
|
329
|
+
openfoodfacts_flavor: Flavor = Flavor.off,
|
|
330
|
+
) -> None:
|
|
331
|
+
"""Export an Ultralytics classification dataset to a Hugging Face dataset.
|
|
332
|
+
|
|
333
|
+
The Ultralytics dataset directory should contain 'train', 'val' and/or
|
|
334
|
+
'test' subdirectories, each containing subdirectories for each label.
|
|
335
|
+
|
|
336
|
+
Args:
|
|
337
|
+
dataset_dir (Path): Path to the Ultralytics dataset directory.
|
|
338
|
+
repo_id (str): Hugging Face repository ID to push the dataset to.
|
|
339
|
+
label_names (list[str]): List of label names.
|
|
340
|
+
merge_labels (bool): Whether to merge all labels into a single label
|
|
341
|
+
named 'object'.
|
|
342
|
+
is_openfoodfacts_dataset (bool): Whether the dataset is from
|
|
343
|
+
Open Food Facts. If True, the `off_image_id` and `image_url` will
|
|
344
|
+
be generated automatically. `off_image_id` is extracted from the
|
|
345
|
+
image filename.
|
|
346
|
+
openfoodfacts_flavor (Flavor): Flavor of Open Food Facts dataset. This
|
|
347
|
+
is ignored if `is_openfoodfacts_dataset` is False.
|
|
348
|
+
"""
|
|
312
349
|
logger.info("Repo ID: %s, dataset_dir: %s", repo_id, dataset_dir)
|
|
313
350
|
|
|
314
351
|
if not any((dataset_dir / split).is_dir() for split in ["train", "val", "test"]):
|
|
@@ -3,18 +3,18 @@ labelr/__main__.py,sha256=G4e95-IfhI-lOmkOBP6kQ8wl1x_Fl7dZlLOYr90K83c,66
|
|
|
3
3
|
labelr/annotate.py,sha256=3fJ9FYbcozcOoKuhNtzPHV8sSnp-45FsNnMc8UeBHGU,3503
|
|
4
4
|
labelr/check.py,sha256=3wK6mE0UsKvoBNm0_lyWhCMq7gxkv5r50pvO70damXY,2476
|
|
5
5
|
labelr/config.py,sha256=3RXF_NdkSuHvfVMGMlYmjlw45fU77zQkLX7gmZq7NxM,64
|
|
6
|
-
labelr/export.py,sha256=
|
|
6
|
+
labelr/export.py,sha256=VC2noLPZLzVb_pTT4j1UovKQSuYELHptCEFaxkwMp5w,16048
|
|
7
7
|
labelr/main.py,sha256=gQ8I287mpLy3HIUWqZUyoLAfPwkphwOIzut7hEbH8tY,2135
|
|
8
8
|
labelr/project_config.py,sha256=CIHEcgSOfXb53naHWEBkTDm2V9m3abAu8C54VSzHjAs,1260
|
|
9
9
|
labelr/sample.py,sha256=unu9AQ64FhKPgssuL7gb3qyMd1EQJvMOfqvjdefmWOU,7807
|
|
10
10
|
labelr/types.py,sha256=8CHfLyifF_N94OYDhG-7IcWboOh9o0Z_0LBtQapT8TQ,313
|
|
11
11
|
labelr/apps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
-
labelr/apps/datasets.py,sha256=
|
|
12
|
+
labelr/apps/datasets.py,sha256=twwH8wzbUauDWVZFObOvk0gsohAeYm0usHCigng_ucM,11262
|
|
13
13
|
labelr/apps/projects.py,sha256=HpgqIaPrUQzIR7eOLn4EBbEzXRi7hoWStT4jLMQPcBg,15153
|
|
14
14
|
labelr/apps/users.py,sha256=twQSlpHxE0hrYkgrJpEFbK8lYfWnpJr8vyfLHLtdAUU,909
|
|
15
|
-
labelr-0.4.
|
|
16
|
-
labelr-0.4.
|
|
17
|
-
labelr-0.4.
|
|
18
|
-
labelr-0.4.
|
|
19
|
-
labelr-0.4.
|
|
20
|
-
labelr-0.4.
|
|
15
|
+
labelr-0.4.1.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
|
|
16
|
+
labelr-0.4.1.dist-info/METADATA,sha256=CnB85fC0St9pnFqZ2pEMnpnRr4Ilsb-2E5-v0FQaqKA,6583
|
|
17
|
+
labelr-0.4.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
18
|
+
labelr-0.4.1.dist-info/entry_points.txt,sha256=OACukVeR_2z54i8yQuWqqk_jdEHlyTwmTFOFBmxPp1k,43
|
|
19
|
+
labelr-0.4.1.dist-info/top_level.txt,sha256=bjZo50aGZhXIcZYpYOX4sdAQcamxh8nwfEh7A9RD_Ag,7
|
|
20
|
+
labelr-0.4.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|