From 34dba17641946fb34ebae8a6d7a322131c543ea9 Mon Sep 17 00:00:00 2001 From: SkalskiP Date: Mon, 10 Apr 2023 12:00:00 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=96=A4=20Make=20Black=20happy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- supervision/detection/core.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/supervision/detection/core.py b/supervision/detection/core.py index c3288cdd..e9e5e689 100644 --- a/supervision/detection/core.py +++ b/supervision/detection/core.py @@ -242,25 +242,25 @@ class Detections: @classmethod def from_sam(cls, sam_result: List[dict]) -> Detections: """ - Creates a Detections instance from Segment Anything Model (SAM) by Meta AI. + Creates a Detections instance from Segment Anything Model (SAM) by Meta AI. - Args: - sam_result (List[dict]): The output Results instance from SAM + Args: + sam_result (List[dict]): The output Results instance from SAM - Returns: - Detections: A new Detections object. + Returns: + Detections: A new Detections object. - Example: - ```python - >>> from segment_anything import sam_model_registry, SamAutomaticMaskGenerator - >>> import supervision as sv + Example: + ```python + >>> from segment_anything import sam_model_registry, SamAutomaticMaskGenerator + >>> import supervision as sv - >>> sam = sam_model_registry[MODEL_TYPE](checkpoint=CHECKPOINT_PATH).to(device=DEVICE) - >>> mask_generator = SamAutomaticMaskGenerator(sam) - >>> sam_result = mask_generator.generate(IMAGE) - >>> detections = sv.Detections.from_sam(sam_result=sam_result) - ``` - """ + >>> sam = sam_model_registry[MODEL_TYPE](checkpoint=CHECKPOINT_PATH).to(device=DEVICE) + >>> mask_generator = SamAutomaticMaskGenerator(sam) + >>> sam_result = mask_generator.generate(IMAGE) + >>> detections = sv.Detections.from_sam(sam_result=sam_result) + ``` + """ sorted_generated_masks = sorted( sam_result, key=lambda x: x["area"], reverse=True )