@@ -84,9 +84,6 @@ def filter_processed_images(
8484 task_logger .debug (f"Image { image } needs processing: has no existing detections from pipeline's detector" )
8585 # If there are no existing detections from this pipeline, send the image
8686 yield image
87- elif existing_detections .null_detections ().exists (): # type: ignore
88- task_logger .debug (f"Image { image } has a null detection from pipeline { pipeline } , skipping! " )
89- continue
9087 elif existing_detections .filter (classifications__isnull = True ).exists ():
9188 # Check if there are detections with no classifications
9289 task_logger .debug (
@@ -409,17 +406,13 @@ def get_or_create_detection(
409406
410407 :return: A tuple of the Detection object and a boolean indicating whether it was created
411408 """
412- if detection_resp .bbox is not None :
413- serialized_bbox = list (detection_resp .bbox .dict ().values ())
414- else :
415- serialized_bbox = None
409+ serialized_bbox = list (detection_resp .bbox .dict ().values ())
416410 detection_repr = f"Detection { detection_resp .source_image_id } { serialized_bbox } "
417411
418412 assert str (detection_resp .source_image_id ) == str (
419413 source_image .pk
420414 ), f"Detection belongs to a different source image: { detection_repr } "
421415
422- # When reprocessing, we don't care which detection algorithm created the existing detection
423416 existing_detection = Detection .objects .filter (
424417 source_image = source_image ,
425418 bbox = serialized_bbox ,
@@ -492,7 +485,6 @@ def create_detections(
492485
493486 existing_detections : list [Detection ] = []
494487 new_detections : list [Detection ] = []
495-
496488 for detection_resp in detections :
497489 source_image = source_image_map .get (detection_resp .source_image_id )
498490 if not source_image :
@@ -818,37 +810,6 @@ class PipelineSaveResults:
818810 total_time : float
819811
820812
821- def create_null_detections_for_undetected_images (
822- results : PipelineResultsResponse ,
823- detection_algorithm : Algorithm ,
824- logger : logging .Logger = logger ,
825- ) -> list [DetectionResponse ]:
826- """
827- Create null DetectionResponse objects (empty bbox) for images that have no detections.
828-
829- :param results: The PipelineResultsResponse from the processing service
830- :param algorithms_known: Dictionary of algorithms keyed by algorithm key
831-
832- :return: List of DetectionResponse objects with null bbox
833- """
834- source_images_with_detections = {detection .source_image_id for detection in results .detections }
835- null_detections_to_add = []
836- detection_algorithm_reference = AlgorithmReference (name = detection_algorithm .name , key = detection_algorithm .key )
837-
838- for source_img in results .source_images :
839- if source_img .id not in source_images_with_detections :
840- null_detections_to_add .append (
841- DetectionResponse (
842- source_image_id = source_img .id ,
843- bbox = None ,
844- algorithm = detection_algorithm_reference ,
845- timestamp = now (),
846- )
847- )
848-
849- return null_detections_to_add
850-
851-
852813@celery_app .task (soft_time_limit = 60 * 4 , time_limit = 60 * 5 )
853814def save_results (
854815 results : PipelineResultsResponse | None = None ,
@@ -896,13 +857,6 @@ def save_results(
896857 )
897858
898859 algorithms_known : dict [str , Algorithm ] = {algo .key : algo for algo in pipeline .algorithms .all ()}
899- try :
900- detection_algorithm = pipeline .algorithms .get (task_type__in = Algorithm .detection_task_types )
901- except Algorithm .DoesNotExist :
902- raise ValueError ("Pipeline does not have a detection algorithm" )
903- except Algorithm .MultipleObjectsReturned :
904- raise NotImplementedError ("Multiple detection algorithms per pipeline are not supported" )
905-
906860 job_logger .info (f"Algorithms registered for pipeline: \n { ', ' .join (algorithms_known .keys ())} " )
907861
908862 if results .algorithms :
@@ -912,15 +866,6 @@ def save_results(
912866 "Algorithms and category maps must be registered before processing, using /info endpoint."
913867 )
914868
915- # Ensure all images have detections
916- # if not, add a NULL detection (empty bbox) to the results
917- null_detections = create_null_detections_for_undetected_images (
918- results = results ,
919- detection_algorithm = detection_algorithm ,
920- logger = job_logger ,
921- )
922- results .detections = results .detections + null_detections
923-
924869 detections = create_detections (
925870 detections = results .detections ,
926871 algorithms_known = algorithms_known ,
0 commit comments