hello.fiftyone.core module¶
- hello.fiftyone.core.add_sample_field(dataset, field_name, ftype)[source]¶
Adds a new sample field or embedded field to the dataset, if necessary.
- Parameters:
dataset – a
fiftyone.core.dataset.Datasetfield_name – the field name or embedded.field.name
ftype – the field type to create. Must be a subclass of
fiftyone.core.fields.Field
- hello.fiftyone.core.change_tag(dataset, files, data_path='data', add=None, rm=None)[source]¶
Change the tags of some samples in this dataset.
- Parameters:
dataset – a
fiftyone.core.dataset.Datasetfiles (list) – a list of archived dataset file
data_path (str, optional) – defaults to “data”
add (str, optional) – defaults to None
rm (str, optional) – defaults to None
- hello.fiftyone.core.clear_sample_field(dataset, field_name)[source]¶
Clears the values of the field from all samples in the dataset.
- Parameters:
dataset – a
fiftyone.core.dataset.Datasetfield_name – the field name or embedded.field.name
- hello.fiftyone.core.clone_sample_field(dataset, field_name, new_field_name)[source]¶
Clones the given sample field into a new field of the dataset.
- Parameters:
dataset – a
fiftyone.core.dataset.Datasetfield_name – the field name or embedded.field.name
new_field_name – the new field name or embedded.field.name
- hello.fiftyone.core.delete_sample_field(dataset, field_name, error_level=0)[source]¶
Deletes the field from all samples in the dataset.
- Parameters:
dataset – a
fiftyone.core.dataset.Datasetfield_name – the field name or embedded.field.name
error_level (int, optional) – the error level to use
- hello.fiftyone.core.filter_segmentation_samples(out_dir, data_root, classes, mask_targets, threshold=0.05, splits=['train', 'val'], img_dir='data', ann_dir='labels', img_suffix='.jpg', seg_map_suffix='.png')[source]¶
Filter samples, based on area of interest ratio.
>>> <data_root>/ >>> ├── objectInfo150.txt >>> ├── sceneCategories.txt >>> ├── train >>> │ ├── data >>> │ └── labels >>> └── val >>> ├── data >>> └── labels
- Parameters:
out_dir (str) – _description_
data_root (str) – _description_
classes (list[str]) – _description_
mask_targets (dict[int, str]) – _description_
threshold (float, optional) – _description_. Defaults to 0.05
splits (list, optional) – _description_. Defaults to [“train”, “val”]
img_dir (str, optional) – _description_. Defaults to “data”
ann_dir (str, optional) – _description_. Defaults to “labels”
img_suffix (str, optional) – _description_. Defaults to “.jpg”
seg_map_suffix (str, optional) – _description_. Defaults to “.png”
- Returns:
a
str
- hello.fiftyone.core.gen_detections_mapping(old_classes, new_classes)[source]¶
Generate detections mapping.
- Parameters:
old_classes (list) –
['c0', 'c1', 'c2', 'c3', 'c4', 'c5']new_classes (list) –
['c0', 'c1', 'c2', ['c3', 'c4', 'c5']]
- Returns:
a
dict
- hello.fiftyone.core.gen_segmentation_mapping(old_classes, new_classes)[source]¶
Generate segmentation mapping.
- Parameters:
old_classes (list) –
['c0', 'c1', 'c2', 'c3', 'c4', 'c5', 'be ignored']new_classes (list) –
['c0', 'c1', 'c2', ['c3', 'c4', 'c5'], 'be ignored']
- Returns:
a
dict
- hello.fiftyone.core.has_sample_field(dataset, field_name)[source]¶
Determines whether the collection has a sample field with the given name.
- Parameters:
dataset – a
fiftyone.core.dataset.Datasetfield_name – the field name
- Returns:
True/False
- hello.fiftyone.core.merge_datasets(dataset, others, in_field=None, out_field=None, **kwargs)[source]¶
Merges the given samples into this dataset.
- Parameters:
dataset – a
fiftyone.core.dataset.Datasetothers – a list of
fiftyone.core.dataset.Datasetin_field (str) – the name of the input label field
out_field (str) – the name of the output label field, which will be created if necessary
**kwargs – optional keyword arguments to pass to merge_samples() <https://voxel51.com/docs/fiftyone/api/fiftyone.core.dataset.html#fiftyone.core.dataset.Dataset.merge_samples>
- hello.fiftyone.core.merge_labels(dataset, in_field, out_field)[source]¶
Merges the labels from the given input field into the given output field of the collection.
If this collection is a dataset, the input field is deleted after the merge.
If this collection is a view, the input field will still exist on the underlying dataset but will only contain the labels not present in this view.
- Parameters:
dataset – a
fiftyone.core.dataset.Datasetin_field (str) – the name of the input label field
out_field (str) – the name of the output label field, which will be created if necessary
- hello.fiftyone.core.random_split(dataset, splits=None, seed=51)[source]¶
Adds the split tags to all samples in this dataset.
- Parameters:
dataset – a
fiftyone.core.dataset.Datasetsplits (dict, optional) – defaults to None
seed (int, optional) – defaults to 51
- Returns:
a
DatasetView
- hello.fiftyone.core.remap_detections_dataset(dataset, new_classes=None, field_name='ground_truth', background=None, least_one=False)[source]¶
Steps: map labels -> check dataset.classes -> filter valid samples
- Parameters:
dataset – a
fiftyone.core.dataset.Datasetnew_classes (None) – refer to
gen_label_mapping()field_name (str, optional) – defaults to “ground_truth”
background (str, optional) – defaults to None
- Returns:
a
fiftyone.core.dataset.Dataset
- hello.fiftyone.core.remap_segmentation_dataset(dataset, new_classes=None, field_name='ground_truth', ignore_index=255, least_one=False)[source]¶
Steps: map labels -> check dataset.mask_targets -> filter valid samples
- Parameters:
dataset – a
fiftyone.core.dataset.Datasetnew_classes (None) – refer to
gen_mask_mapping()field_name (str, optional) – defaults to “ground_truth”
ignore_index (int, optional) – defaults to 255
- Returns:
a
fiftyone.core.dataset.Dataset
- hello.fiftyone.core.rename_sample_field(dataset, field_name, new_field_name)[source]¶
Renames the sample field to the given new name.
- Parameters:
dataset – a
fiftyone.core.dataset.Datasetfield_name – the field name or embedded.field.name
new_field_name – the new field name or embedded.field.name
- hello.fiftyone.core.split_dataset(dataset, splits=None, limit=3000, seed=51, field_name='ground_truth', from_field=None)[source]¶
Adds the split tags to all samples in this dataset.
- Parameters:
dataset – a
fiftyone.core.dataset.Datasetsplits (dict, optional) – defaults to None
limit (int, optional) – defaults to 3000
seed (int, optional) – defaults to 51
field_name (str, optional) – defaults to “ground_truth”
from_field (str, optional) – defaults to None
- Returns:
a
DatasetView
- hello.fiftyone.core.tag_from(dataset, by_dir=None, by_json=None, by_dict=None, by_list=None, is_in=None)[source]¶
- hello.fiftyone.core.tag_from_text(dataset, text_file, tag_map='synsets.txt', remove_prefix=False)[source]¶
Tag dataset from a text file(cvat export: ImageNet 1.0).
Examples:
000471_0622023132018.jpg 0 000472_0622023132018.jpg 1 000473_0622023132019.jpg 1 000474_0622023132019.jpg 0 1 000475_0622023132019.jpg 0 000476_0622023132019.jpg 0