`ultralytics 8.0.11` bug fixes and performance improvements (#495)

Co-authored-by: Laughing <61612323+Laughing-q@users.noreply.github.com>
Co-authored-by: Ayush Chaurasia <ayush.chaurarsia@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
single_channel
Glenn Jocher 2 years ago committed by GitHub
parent a86218b767
commit 6eec39162a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -14,7 +14,7 @@ Inference or prediction of a task returns a list of `Results` objects. Alternati
=== "Getting a Generator"
```python
inputs = [img, img] # list of np arrays
results = model(inputs, stream="True") # Generator of Results objects
results = model(inputs, stream=True) # Generator of Results objects
for result in results:
boxes = results.boxes # Boxes object for bbox outputs
masks = results.masks # Masks object for segmenation masks outputs

@ -1,6 +1,6 @@
# Ultralytics YOLO 🚀, GPL-3.0 license
__version__ = "8.0.9"
__version__ = "8.0.11"
from ultralytics.yolo.engine.model import YOLO
from ultralytics.yolo.utils import ops

@ -493,7 +493,7 @@ class LoadImagesAndLabels(Dataset):
cache, exists = np.load(cache_path, allow_pickle=True).item(), True # load dict
assert cache['version'] == self.cache_version # matches current version
assert cache['hash'] == get_hash(self.label_files + self.im_files) # identical hash
except Exception:
except (FileNotFoundError, AssertionError):
cache, exists = self.cache_labels(cache_path, prefix), False # run cache ops
# Display cache

@ -105,7 +105,7 @@ class YOLODataset(BaseDataset):
cache, exists = np.load(str(cache_path), allow_pickle=True).item(), True # load dict
assert cache["version"] == self.cache_version # matches current version
assert cache["hash"] == get_hash(self.label_files + self.im_files) # identical hash
except Exception:
except (FileNotFoundError, AssertionError):
cache, exists = self.cache_labels(cache_path), False # run cache ops
# Display cache

@ -95,6 +95,18 @@ class Results:
return s
def __getattr__(self, attr):
name = self.__class__.__name__
raise AttributeError(f"""
'{name}' object has no attribute '{attr}'. Valid '{name}' object attributes and properties are:
Attributes:
boxes (Boxes, optional): A Boxes object containing the detection bounding boxes.
masks (Masks, optional): A Masks object containing the detection masks.
probs (torch.Tensor, optional): A tensor containing the detection class probabilities.
orig_shape (tuple, optional): Original image size.
""")
class Boxes:
"""
@ -200,6 +212,25 @@ class Boxes:
boxes = self.boxes[idx]
return Boxes(boxes, self.orig_shape)
def __getattr__(self, attr):
name = self.__class__.__name__
raise AttributeError(f"""
'{name}' object has no attribute '{attr}'. Valid '{name}' object attributes and properties are:
Attributes:
boxes (torch.Tensor) or (numpy.ndarray): A tensor or numpy array containing the detection boxes,
with shape (num_boxes, 6).
orig_shape (torch.Tensor) or (numpy.ndarray): Original image size, in the format (height, width).
Properties:
xyxy (torch.Tensor) or (numpy.ndarray): The boxes in xyxy format.
conf (torch.Tensor) or (numpy.ndarray): The confidence values of the boxes.
cls (torch.Tensor) or (numpy.ndarray): The class values of the boxes.
xywh (torch.Tensor) or (numpy.ndarray): The boxes in xywh format.
xyxyn (torch.Tensor) or (numpy.ndarray): The boxes in xyxy format normalized by original image size.
xywhn (torch.Tensor) or (numpy.ndarray): The boxes in xywh format normalized by original image size.
""")
class Masks:
"""
@ -262,6 +293,19 @@ class Masks:
masks = self.masks[idx]
return Masks(masks, self.im_shape, self.orig_shape)
def __getattr__(self, attr):
name = self.__class__.__name__
raise AttributeError(f"""
'{name}' object has no attribute '{attr}'. Valid '{name}' object attributes and properties are:
Attributes:
masks (torch.Tensor): A tensor containing the detection masks, with shape (num_masks, height, width).
orig_shape (tuple): Original image size, in the format (height, width).
Properties:
segments (list): A list of segments which includes x,y,w,h,label,confidence, and mask of each detection masks.
""")
if __name__ == "__main__":
# test examples

@ -379,7 +379,7 @@ def set_sentry(dsn=None):
release=ultralytics.__version__,
send_default_pii=True,
environment='production', # 'dev' or 'production'
ignore_errors=[KeyboardInterrupt, torch.cuda.OutOfMemoryError])
ignore_errors=[KeyboardInterrupt])
def get_settings(file=USER_CONFIG_DIR / 'settings.yaml', version='0.0.1'):

@ -177,7 +177,7 @@ class Loss:
anchor_points * stride_tensor, gt_labels, gt_bboxes, mask_gt)
target_bboxes /= stride_tensor
target_scores_sum = target_scores.sum()
target_scores_sum = max(target_scores.sum(), 1)
# cls loss
# loss[1] = self.varifocal_loss(pred_scores, target_scores, target_labels) / target_scores_sum # VFL way

@ -99,7 +99,7 @@ class SegLoss(Loss):
pred_scores.detach().sigmoid(), (pred_bboxes.detach() * stride_tensor).type(gt_bboxes.dtype),
anchor_points * stride_tensor, gt_labels, gt_bboxes, mask_gt)
target_scores_sum = target_scores.sum()
target_scores_sum = max(target_scores.sum(), 1)
# cls loss
# loss[1] = self.varifocal_loss(pred_scores, target_scores, target_labels) / target_scores_sum # VFL way

Loading…
Cancel
Save