Skip to content

Commit 7d971b7

Browse files
author
Ubuntu
committed
Docstrings for dataset item class
1 parent ff86d06 commit 7d971b7

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

nucleus/dataset_item.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@
3131

3232
@dataclass
3333
class Quaternion:
34+
"""Quaternion objects are used to represent rotation.
35+
We use the Hamilton quaternion convention, where i^2 = j^2 = k^2 = ijk = -1, i.e. the right-handed convention.
36+
The quaternion represented by the tuple (x, y, z, w) is equal to w + x*i + y*j + z*k
37+
38+
Attributes:
39+
x: x value
40+
y: y value
41+
x: z value
42+
w: w value
43+
"""
44+
3445
x: float
3546
y: float
3647
z: float
@@ -53,6 +64,20 @@ def to_payload(self) -> dict:
5364

5465
@dataclass
5566
class CameraParams:
67+
"""CameraParams objects represent the camera position/heading used to record the image.
68+
69+
Attributes:
70+
position: Vector3 World-normalized position of the camera
71+
heading: Vector <x, y, z, w> indicating the quaternion of the camera direction;
72+
note that the z-axis of the camera frame represents the camera's optical axis.
73+
See `Heading Examples<https://docs.scale.com/reference/data-types-and-the-frame-objects#heading-examples>`_
74+
for examples.
75+
fx: focal length in x direction (in pixels)
76+
fy: focal length in y direction (in pixels)
77+
cx: principal point x value
78+
cy: principal point y value
79+
"""
80+
5681
position: Point3D
5782
heading: Quaternion
5883
fx: float
@@ -89,6 +114,56 @@ class DatasetItemType(Enum):
89114

90115
@dataclass # pylint: disable=R0902
91116
class DatasetItem: # pylint: disable=R0902
117+
"""A dataset item is either a single image or pointcloud plus its associated metadata.
118+
119+
Note: for 3D data, please include a :class:`.CameraParams` object under a key named
120+
"camera_params" within the metadata dictionary. This will allow for projecting
121+
3D annotations to any image within a scene.
122+
123+
124+
Attributes:
125+
image_location: (required if pointcloud_location not present) The location
126+
containing the image for the given row of data. This can be a local path, or a remote URL.
127+
Remote formats supported include any URL (http:// or https://) or URIs for AWS S3, Azure, or GCS,
128+
(i.e. s3://, gcs://)
129+
reference_id: (required) A user-specified identifier to reference the item.
130+
metadata: Extra information about the particular dataset item. ints, floats,
131+
string values will be made searchable in the query bar by the key in this dict
132+
For example, {"animal": "dog"} will become searchable via
133+
metadata.animal = "dog"
134+
135+
Categorical data can be passed as a string and will be treated categorically
136+
by Nucleus if there are less than 250 unique values in the dataset. This means
137+
histograms of values in the "Insights" section and autocomplete
138+
within the query bar.
139+
140+
Numerical metadata will generate histograms in the "Insights" section, allow
141+
for sorting the results of any query, and can be used with the modulo operator
142+
For example: metadata.frame_number % 5 = 0
143+
144+
All other types of metadata will be visible from the dataset item detail view.
145+
146+
It is important that string and numerical metadata fields are consistent - if
147+
a metadata field has a string value, then all metadata fields with the same
148+
key should also have string values, and vice versa for numerical metadata.
149+
If conflicting types are found, Nucleus will return an error during upload!
150+
151+
The recommended way of adding or updating existing metadata is to re-run the
152+
ingestion (dataset.append) with update=True, which will replace any existing
153+
metadata with whatever your new ingestion run uses. This will delete any
154+
metadata keys that are not present in the new ingestion run. We have a cache
155+
based on image_location that will skip the need for a re-upload of the images,
156+
so your second ingestion will be faster than your first.
157+
pointcloud_location: (required if image_location not passed) The remote URL
158+
containing the pointcloud JSON. Remote formats supported include any URL
159+
(http:// or https://) or URIs for AWS S3, Azure, or GCS, (i.e. s3://, gcs://)
160+
upload_to_scale: Set this to false in order to use `privacy mode<https://dashboard.scale.com/nucleus/docs/api#privacy-mode>`_.
161+
Briefly speaking, setting this to flase means the actual data within the item
162+
(i.e. the image or pointcloud) will not be uploaded to scale meaning that
163+
you can send in links that are only accessible to certain users, and not to
164+
Scale.
165+
"""
166+
92167
image_location: Optional[str] = None
93168
reference_id: Optional[str] = None
94169
metadata: Optional[dict] = None

0 commit comments

Comments
 (0)