Skip to content

Commit

Permalink
Run pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
dimidagd committed Apr 4, 2024
1 parent b8f884a commit e22ce44
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions fiftyone/utils/ultralytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def _to_instances(result, confidence_thresh=None):
return fol.Detections(detections=detections)


def obb_to_polylines(results, confidence_thresh=None,filled=False):
def obb_to_polylines(results, confidence_thresh=None, filled=False):
"""Converts ``ultralytics.YOLO`` instance segmentations to FiftyOne format.
Args:
Expand All @@ -186,9 +186,7 @@ def obb_to_polylines(results, confidence_thresh=None,filled=False):
results = [results]

batch = [
_obb_to_polylines(
r, filled, confidence_thresh=confidence_thresh
)
_obb_to_polylines(r, filled, confidence_thresh=confidence_thresh)
for r in results
]

Expand All @@ -198,7 +196,7 @@ def obb_to_polylines(results, confidence_thresh=None,filled=False):
return batch


def _obb_to_polylines(result,filled, confidence_thresh=None):
def _obb_to_polylines(result, filled, confidence_thresh=None):
if result.obb is None:
return None
classes = np.rint(result.obb.cls.detach().cpu().numpy()).astype(int)
Expand All @@ -223,6 +221,7 @@ def _obb_to_polylines(result,filled, confidence_thresh=None):
polylines.append(polyline)
return fol.Polylines(polylines=polylines)


def to_polylines(results, confidence_thresh=None, tolerance=2, filled=True):
"""Converts ``ultralytics.YOLO`` instance segmentations to FiftyOne format.
Expand Down Expand Up @@ -441,6 +440,7 @@ def predict_all(self, args):
class FiftyOneYOLOOBBConfig(FiftyOneYOLOModelConfig):
pass


class FiftyOneYOLOOBBModel(FiftyOneYOLOModel):
"""FiftyOne wrapper around an Ultralytics YOLO OBB detection model.
Expand All @@ -457,7 +457,6 @@ def predict_all(self, args):
return self._format_predictions(predictions)



class FiftyOneYOLOSegmentationModelConfig(FiftyOneYOLOModelConfig):
pass

Expand Down Expand Up @@ -502,10 +501,12 @@ def _convert_yolo_detection_model(model):
config = FiftyOneYOLODetectionModelConfig({"model": model})
return FiftyOneYOLODetectionModel(config)


def _convert_yolo_obb_model(model):
config = FiftyOneYOLOOBBConfig({"model": model})
return FiftyOneYOLOOBBModel(config)


def _convert_yolo_segmentation_model(model):
config = FiftyOneYOLOSegmentationModelConfig({"model": model})
return FiftyOneYOLOSegmentationModel(config)
Expand Down

0 comments on commit e22ce44

Please sign in to comment.