@@ -383,7 +383,7 @@ def create(self,
383383
384384 annotations = [annotation_dto ] if isinstance (annotation_dto , CreateAnnotationDto ) else annotation_dto
385385 annotations = [ann .to_dict () if isinstance (ann , CreateAnnotationDto ) else ann for ann in annotations ]
386- resource_id = resource . id if isinstance (resource , Resource ) else resource
386+ resource_id = self . _entid (resource )
387387 respdata = self ._make_request ('POST' ,
388388 f'{ self .endpoint_base } /{ resource_id } /annotations' ,
389389 json = annotations ).json ()
@@ -786,6 +786,37 @@ def _numpy_to_bytesio_png(seg_imgs: np.ndarray) -> Generator[BinaryIO, None, Non
786786 img_bytes .seek (0 )
787787 yield img_bytes
788788
789+ def create_image_classification (self ,
790+ resource : str | Resource ,
791+ identifier : str ,
792+ value : str ,
793+ imported_from : str | None = None ,
794+ model_id : str | None = None ,
795+ ) -> str :
796+ """
797+ Create an image-level classification annotation.
798+
799+ Args:
800+ resource: The resource unique id or Resource instance.
801+ identifier: The annotation identifier/label.
802+ value: The classification value.
803+ imported_from: The imported from source value.
804+ model_id: The model unique id.
805+
806+ Returns:
807+ The id of the created annotation.
808+ """
809+ annotation_dto = CreateAnnotationDto (
810+ type = AnnotationType .CATEGORY ,
811+ identifier = identifier ,
812+ scope = 'image' ,
813+ value = value ,
814+ imported_from = imported_from ,
815+ model_id = model_id
816+ )
817+
818+ return self .create (resource , annotation_dto )
819+
789820 def add_line_annotation (self ,
790821 point1 : tuple [int , int ] | tuple [float , float , float ],
791822 point2 : tuple [int , int ] | tuple [float , float , float ],
0 commit comments