-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
41 lines (30 loc) · 1.02 KB
/
__init__.py
File metadata and controls
41 lines (30 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""
Sample Inspector Plugin - Python operators
"""
import fiftyone.operators as foo
import fiftyone.operators.types as types
class GetMaskTargets(foo.Operator):
@property
def config(self):
return foo.OperatorConfig(
name="get_mask_targets",
label="Get mask targets from dataset",
unlisted=True,
)
def resolve_input(self, ctx):
inputs = types.Object()
return types.Property(inputs)
def execute(self, ctx):
dataset = ctx.dataset
mask_targets = {}
default_mask_targets = {}
if hasattr(dataset, 'mask_targets') and dataset.mask_targets:
mask_targets = dataset.mask_targets
if hasattr(dataset, 'default_mask_targets') and dataset.default_mask_targets:
default_mask_targets = dataset.default_mask_targets
return {
"mask_targets": mask_targets,
"default_mask_targets": default_mask_targets,
}
def register(plugin):
plugin.register(GetMaskTargets)