Skip to content

Commit

Permalink
Merge branch 'multiclass_label_support' of github.com:groundlight/pyt…
Browse files Browse the repository at this point in the history
…hon-sdk into multiclass_label_support
  • Loading branch information
brandon-groundlight committed Dec 4, 2024
2 parents 24a0c4a + 4097ec9 commit 862b652
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/groundlight/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,10 @@ def _wait_for_result(
return image_query

def add_label(
self, image_query: Union[ImageQuery, str], label: Union[Label, int, str], rois: Union[List[ROI], str, None] = None
self,
image_query: Union[ImageQuery, str],
label: Union[Label, int, str],
rois: Union[List[ROI], str, None] = None,
):
"""
Provide a new label (annotation) for an image query. This is used to provide ground-truth labels
Expand Down
6 changes: 1 addition & 5 deletions src/groundlight/experimental_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,18 @@
from groundlight_openapi_client.api.image_queries_api import ImageQueriesApi
from groundlight_openapi_client.api.notes_api import NotesApi
from groundlight_openapi_client.model.action_request import ActionRequest
from groundlight_openapi_client.model.b_box_geometry_request import BBoxGeometryRequest
from groundlight_openapi_client.model.channel_enum import ChannelEnum
from groundlight_openapi_client.model.condition_request import ConditionRequest
from groundlight_openapi_client.model.count_mode_configuration import CountModeConfiguration
from groundlight_openapi_client.model.detector_group_request import DetectorGroupRequest
from groundlight_openapi_client.model.escalation_type_enum import EscalationTypeEnum
from groundlight_openapi_client.model.label_value_request import LabelValueRequest
from groundlight_openapi_client.model.multi_class_mode_configuration import MultiClassModeConfiguration
from groundlight_openapi_client.model.patched_detector_request import PatchedDetectorRequest
from groundlight_openapi_client.model.roi_request import ROIRequest
from groundlight_openapi_client.model.rule_request import RuleRequest
from groundlight_openapi_client.model.status_enum import StatusEnum
from groundlight_openapi_client.model.verb_enum import VerbEnum
from model import ROI, BBoxGeometry, Detector, DetectorGroup, ImageQuery, ModeEnum, PaginatedRuleList, Rule
from model import ROI, BBoxGeometry, Detector, DetectorGroup, ModeEnum, PaginatedRuleList, Rule

from groundlight.binary_labels import Label
from groundlight.images import parse_supported_image_types
from groundlight.optional_imports import Image, np

Expand Down
4 changes: 3 additions & 1 deletion test/unit/test_labels.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from datetime import datetime

import pytest
from groundlight import ExperimentalApi, ApiException
from groundlight import ApiException, ExperimentalApi


def test_binary_labels(gl_experimental: ExperimentalApi):
Expand All @@ -20,6 +20,7 @@ def test_binary_labels(gl_experimental: ExperimentalApi):
with pytest.raises(ApiException) as _:
gl_experimental.add_label(iq1, "MAYBE")


def test_counting_labels(gl_experimental: ExperimentalApi):
name = f"Test binary labels{datetime.utcnow()}"
det = gl_experimental.create_counting_detector(name, "test_query")
Expand All @@ -35,6 +36,7 @@ def test_counting_labels(gl_experimental: ExperimentalApi):
with pytest.raises(ApiException) as _:
gl_experimental.add_label(iq1, -999)


def test_multiclass_labels(gl_experimental: ExperimentalApi):
name = f"Test binary labels{datetime.utcnow()}"
det = gl_experimental.create_multiclass_detector(name, "test_query", class_names=["apple", "banana", "cherry"])
Expand Down

0 comments on commit 862b652

Please sign in to comment.