@@ -460,93 +460,6 @@ def populate_dataset(
460
460
dataset_items , batch_size = batch_size , update = update
461
461
)
462
462
463
- def annotate_dataset (
464
- self ,
465
- dataset_id : str ,
466
- annotations : Sequence [
467
- Union [
468
- BoxAnnotation ,
469
- PolygonAnnotation ,
470
- CuboidAnnotation ,
471
- CategoryAnnotation ,
472
- MultiCategoryAnnotation ,
473
- SegmentationAnnotation ,
474
- ]
475
- ],
476
- update : bool ,
477
- batch_size : int = 5000 ,
478
- ) -> Dict [str , object ]:
479
- # TODO: deprecate in favor of Dataset.annotate invocation
480
-
481
- # Split payload into segmentations and Box/Polygon
482
- segmentations = [
483
- ann
484
- for ann in annotations
485
- if isinstance (ann , SegmentationAnnotation )
486
- ]
487
- other_annotations = [
488
- ann
489
- for ann in annotations
490
- if not isinstance (ann , SegmentationAnnotation )
491
- ]
492
-
493
- batches = [
494
- other_annotations [i : i + batch_size ]
495
- for i in range (0 , len (other_annotations ), batch_size )
496
- ]
497
-
498
- semseg_batches = [
499
- segmentations [i : i + batch_size ]
500
- for i in range (0 , len (segmentations ), batch_size )
501
- ]
502
-
503
- agg_response = {
504
- DATASET_ID_KEY : dataset_id ,
505
- ANNOTATIONS_PROCESSED_KEY : 0 ,
506
- ANNOTATIONS_IGNORED_KEY : 0 ,
507
- ERRORS_KEY : [],
508
- }
509
-
510
- total_batches = len (batches ) + len (semseg_batches )
511
-
512
- tqdm_batches = self .tqdm_bar (batches )
513
-
514
- with self .tqdm_bar (total = total_batches ) as pbar :
515
- for batch in tqdm_batches :
516
- payload = construct_annotation_payload (batch , update )
517
- response = self .make_request (
518
- payload , f"dataset/{ dataset_id } /annotate"
519
- )
520
- pbar .update (1 )
521
- if STATUS_CODE_KEY in response :
522
- agg_response [ERRORS_KEY ] = response
523
- else :
524
- agg_response [ANNOTATIONS_PROCESSED_KEY ] += response [
525
- ANNOTATIONS_PROCESSED_KEY
526
- ]
527
- agg_response [ANNOTATIONS_IGNORED_KEY ] += response [
528
- ANNOTATIONS_IGNORED_KEY
529
- ]
530
- agg_response [ERRORS_KEY ] += response [ERRORS_KEY ]
531
-
532
- for s_batch in semseg_batches :
533
- payload = construct_segmentation_payload (s_batch , update )
534
- response = self .make_request (
535
- payload , f"dataset/{ dataset_id } /annotate_segmentation"
536
- )
537
- pbar .update (1 )
538
- if STATUS_CODE_KEY in response :
539
- agg_response [ERRORS_KEY ] = response
540
- else :
541
- agg_response [ANNOTATIONS_PROCESSED_KEY ] += response [
542
- ANNOTATIONS_PROCESSED_KEY
543
- ]
544
- agg_response [ANNOTATIONS_IGNORED_KEY ] += response [
545
- ANNOTATIONS_IGNORED_KEY
546
- ]
547
-
548
- return agg_response
549
-
550
463
@deprecated (msg = "Use Dataset.ingest_tasks instead" )
551
464
def ingest_tasks (self , dataset_id : str , payload : dict ):
552
465
dataset = self .get_dataset (dataset_id )
@@ -599,93 +512,6 @@ def create_model_run(self, dataset_id: str, payload: dict) -> ModelRun:
599
512
response [MODEL_RUN_ID_KEY ], dataset_id = dataset_id , client = self
600
513
)
601
514
602
- @deprecated ("Use Dataset.upload_predictions instead." )
603
- def predict (
604
- self ,
605
- annotations : List [
606
- Union [
607
- BoxPrediction ,
608
- PolygonPrediction ,
609
- CuboidPrediction ,
610
- SegmentationPrediction ,
611
- CategoryPrediction ,
612
- ]
613
- ],
614
- model_run_id : Optional [str ] = None ,
615
- model_id : Optional [str ] = None ,
616
- dataset_id : Optional [str ] = None ,
617
- update : bool = False ,
618
- batch_size : int = 5000 ,
619
- ):
620
- if model_run_id is not None :
621
- assert model_id is None and dataset_id is None
622
- endpoint = f"modelRun/{ model_run_id } /predict"
623
- else :
624
- assert (
625
- model_id is not None and dataset_id is not None
626
- ), "Model ID and dataset ID are required if not using model run id."
627
- endpoint = (
628
- f"dataset/{ dataset_id } /model/{ model_id } /uploadPredictions"
629
- )
630
- segmentations = [
631
- ann
632
- for ann in annotations
633
- if isinstance (ann , SegmentationPrediction )
634
- ]
635
-
636
- other_predictions = [
637
- ann
638
- for ann in annotations
639
- if not isinstance (ann , SegmentationPrediction )
640
- ]
641
-
642
- s_batches = [
643
- segmentations [i : i + batch_size ]
644
- for i in range (0 , len (segmentations ), batch_size )
645
- ]
646
-
647
- batches = [
648
- other_predictions [i : i + batch_size ]
649
- for i in range (0 , len (other_predictions ), batch_size )
650
- ]
651
-
652
- errors = []
653
- predictions_processed = 0
654
- predictions_ignored = 0
655
-
656
- tqdm_batches = self .tqdm_bar (batches )
657
-
658
- for batch in tqdm_batches :
659
- batch_payload = construct_box_predictions_payload (
660
- batch ,
661
- update ,
662
- )
663
- response = self .make_request (batch_payload , endpoint )
664
- if STATUS_CODE_KEY in response :
665
- errors .append (response )
666
- else :
667
- predictions_processed += response [PREDICTIONS_PROCESSED_KEY ]
668
- predictions_ignored += response [PREDICTIONS_IGNORED_KEY ]
669
- if ERRORS_KEY in response :
670
- errors += response [ERRORS_KEY ]
671
-
672
- for s_batch in s_batches :
673
- payload = construct_segmentation_payload (s_batch , update )
674
- response = self .make_request (payload , endpoint )
675
- # pbar.update(1)
676
- if STATUS_CODE_KEY in response :
677
- errors .append (response )
678
- else :
679
- predictions_processed += response [PREDICTIONS_PROCESSED_KEY ]
680
- predictions_ignored += response [PREDICTIONS_IGNORED_KEY ]
681
-
682
- return {
683
- MODEL_RUN_ID_KEY : model_run_id ,
684
- PREDICTIONS_PROCESSED_KEY : predictions_processed ,
685
- PREDICTIONS_IGNORED_KEY : predictions_ignored ,
686
- ERRORS_KEY : errors ,
687
- }
688
-
689
515
@deprecated (
690
516
"Model runs have been deprecated and will be removed. Use a Model instead."
691
517
)
0 commit comments