Skip to content

Commit ef5331f

Browse files
authored
Initial doc updates for category (#156)
1 parent 2eb3aaf commit ef5331f

File tree

4 files changed

+53
-11
lines changed

4 files changed

+53
-11
lines changed

nucleus/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"BoxAnnotation",
1010
"BoxPrediction",
1111
"CameraParams",
12-
# "CategoryAnnotation", # coming soon!
13-
# "CategoryPrediction", # coming soon!
12+
"CategoryAnnotation",
13+
"CategoryPrediction",
1414
"CuboidAnnotation",
1515
"CuboidPrediction",
1616
"Dataset",

nucleus/annotation.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,19 @@ class AnnotationTypes(Enum):
465465

466466
@dataclass
467467
class CategoryAnnotation(Annotation):
468-
"""This class is not yet supported: Categorization support coming soon!"""
468+
"""A category annotation.
469+
470+
Parameters:
471+
label (str): The label for this annotation (e.g. car, pedestrian, bicycle).
472+
taxonomy_name (str): The name of the taxonomy this annotation conforms to.
473+
reference_id (str): The reference ID of the image you wish to apply this annotation to.
474+
metadata (Optional[Dict]): Arbitrary key/value dictionary of info to attach to this annotation.
475+
Strings, floats and ints are supported best by querying and insights
476+
features within Nucleus. For more details see our metadata guide.
477+
478+
.. todo::
479+
Insert link to metadata guide
480+
"""
469481

470482
label: str
471483
taxonomy_name: str
@@ -497,7 +509,7 @@ def to_payload(self) -> dict:
497509

498510
@dataclass
499511
class MultiCategoryAnnotation(Annotation):
500-
"""This class is not yet supported: Categorization support coming soon!"""
512+
"""This class is not yet supported: MultiCategory annotation support coming soon!"""
501513

502514
labels: List[str]
503515
taxonomy_name: str

nucleus/dataset.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -481,12 +481,25 @@ def add_taxonomy(
481481
taxonomy_type: str,
482482
labels: List[str],
483483
):
484-
"""
485-
Creates a new taxonomy.
486-
Returns a response with dataset_id, taxonomy_name and type for the new taxonomy.
487-
:param taxonomy_name: name of the taxonomy
488-
:param type: type of the taxonomy
489-
:param labels: list of possible labels for the taxonomy
484+
"""Creates a new taxonomy.
485+
::
486+
487+
import nucleus
488+
client = nucleus.NucleusClient("YOUR_SCALE_API_KEY")
489+
dataset = client.get_dataset("ds_bw6de8s84pe0vbn6p5zg")
490+
491+
dataset.add_taxonomy(taxonomy_name="clothing_type", type="category", labels=["shirt", "trousers", "dress"])
492+
493+
Args:
494+
taxonomy_name:
495+
The name of the taxonomy. Taxonomy names must be unique within a dataset.
496+
taxonomy_type:
497+
The type of this taxonomy as a string literal. Currently, the only supported taxonomy type is "category".
498+
labels:
499+
The list of possible labels for the taxonomy.
500+
501+
Returns:
502+
Returns a response with dataset_id, taxonomy_name and type for the new taxonomy.
490503
"""
491504
return self._client.make_request(
492505
construct_taxonomy_payload(taxonomy_name, taxonomy_type, labels),

nucleus/prediction.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,24 @@ def from_json(cls, payload: dict):
249249

250250

251251
class CategoryPrediction(CategoryAnnotation):
252-
"""This class is not yet supported: Categorization support coming soon!"""
252+
"""A prediction of a category.
253+
254+
Parameters:
255+
label: The label for this annotation (e.g. car, pedestrian, bicycle).
256+
taxonomy_name: The name of the taxonomy this annotation conforms to.
257+
reference_id: The reference ID of the image you wish to apply this annotation to.
258+
confidence: 0-1 indicating the confidence of the prediction.
259+
class_pdf: An optional complete class probability distribution on this
260+
prediction. Each value should be between 0 and 1 (inclusive), and sum up to
261+
1 as a complete distribution. This can be useful for computing entropy to
262+
surface places where the model is most uncertain.
263+
metadata: Arbitrary key/value dictionary of info to attach to this annotation.
264+
Strings, floats and ints are supported best by querying and insights
265+
features within Nucleus. For more details see our metadata guide.
266+
267+
.. todo::
268+
Insert link to metadata guide
269+
"""
253270

254271
def __init__(
255272
self,

0 commit comments

Comments
 (0)