Skip to content

Commit

Permalink
ultralytics.py
Browse files Browse the repository at this point in the history
  • Loading branch information
zhugelaozei authored Dec 26, 2024
1 parent f5fec83 commit 42fd93b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions sahi/models/ultralytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ def perform_inference(self, image: np.ndarray):

if self.image_size is not None:
kwargs = {"imgsz": self.image_size, **kwargs}
if type(image) is list:

prediction_result = self.model(image[:, :, ::-1], **kwargs) # YOLOv8 expects numpy arrays to have BGR

prediction_result = self.model(image, **kwargs) # YOLOv8 expects numpy arrays to have BGR
else :
prediction_result = self.model(image[:, :, ::-1], **kwargs)
if self.has_mask:
if not prediction_result[0].masks:
prediction_result[0].masks = Masks(
Expand Down Expand Up @@ -109,7 +111,10 @@ def perform_inference(self, image: np.ndarray):
prediction_result = [result.boxes.data for result in prediction_result]

self._original_predictions = prediction_result
self._original_shape = image.shape
if type(image) == list:
self._original_shape = image[0].shape
else:
self._original_shape = image.shape

@property
def category_names(self):
Expand Down

0 comments on commit 42fd93b

Please sign in to comment.