Skip to content

Commit

Permalink
Fix indent
Browse files Browse the repository at this point in the history
  • Loading branch information
stellasphere committed Dec 2, 2024
1 parent d798a65 commit 4c92c2d
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions supervision/detection/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,11 @@ def from_ultralytics(cls, ultralytics_results) -> Detections:
xyxy=ultralytics_results.obb.xyxy.cpu().numpy(),
confidence=ultralytics_results.obb.conf.cpu().numpy(),
class_id=class_id,
tracker_id=ultralytics_results.obb.id.int().cpu().numpy()
if ultralytics_results.obb.id is not None
else None,
tracker_id=(
ultralytics_results.obb.id.int().cpu().numpy()
if ultralytics_results.obb.id is not None
else None
),
data={
ORIENTED_BOX_COORDINATES: oriented_box_coordinates,
CLASS_NAME_DATA_FIELD: class_names,
Expand All @@ -293,9 +295,11 @@ def from_ultralytics(cls, ultralytics_results) -> Detections:
confidence=ultralytics_results.boxes.conf.cpu().numpy(),
class_id=class_id,
mask=extract_ultralytics_masks(ultralytics_results),
tracker_id=ultralytics_results.boxes.id.int().cpu().numpy()
if ultralytics_results.boxes.id is not None
else None,
tracker_id=(
ultralytics_results.boxes.id.int().cpu().numpy()
if ultralytics_results.boxes.id is not None
else None
),
data={CLASS_NAME_DATA_FIELD: class_names},
)

Expand Down Expand Up @@ -447,9 +451,11 @@ def from_mmdetection(cls, mmdet_results) -> Detections:
xyxy=mmdet_results.pred_instances.bboxes.cpu().numpy(),
confidence=mmdet_results.pred_instances.scores.cpu().numpy(),
class_id=mmdet_results.pred_instances.labels.cpu().numpy().astype(int),
mask=mmdet_results.pred_instances.masks.cpu().numpy()
if "masks" in mmdet_results.pred_instances
else None,
mask=(
mmdet_results.pred_instances.masks.cpu().numpy()
if "masks" in mmdet_results.pred_instances
else None
),
)

@classmethod
Expand Down Expand Up @@ -567,9 +573,11 @@ class IDs, and confidences of the predictions.
return cls(
xyxy=detectron2_results["instances"].pred_boxes.tensor.cpu().numpy(),
confidence=detectron2_results["instances"].scores.cpu().numpy(),
mask=detectron2_results["instances"].pred_masks.cpu().numpy()
if hasattr(detectron2_results["instances"], "pred_masks")
else None,
mask=(
detectron2_results["instances"].pred_masks.cpu().numpy()
if hasattr(detectron2_results["instances"], "pred_masks")
else None
),
class_id=detectron2_results["instances"]
.pred_classes.cpu()
.numpy()
Expand Down Expand Up @@ -1392,7 +1400,7 @@ def with_nmm(

return Detections.merge(result)

@classmethod
@classmethod
def from_gcp_vision(cls, gcp_results, size) -> Detections:
"""
Creates a Detections instance from the
Expand Down

0 comments on commit 4c92c2d

Please sign in to comment.