ultralytics 8.0.92 updates and fixes (#2361)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Yonghye Kwon <developer.0hye@gmail.com>
Co-authored-by: introvin <vinod.4166@gmail.com>
Co-authored-by: marinmarcillat <58145636+marinmarcillat@users.noreply.github.com>
Co-authored-by: BIGBOSS-FOX <47949596+BIGBOSS-FOX@users.noreply.github.com>
This commit is contained in:
Glenn Jocher
2023-05-04 01:27:00 +02:00
committed by GitHub
parent 3fd317edfd
commit 0ebd3f2959
15 changed files with 82 additions and 35 deletions

View File

@ -1,6 +1,6 @@
# Ultralytics YOLO 🚀, AGPL-3.0 license
__version__ = '8.0.91'
__version__ = '8.0.92'
from ultralytics.hub import start
from ultralytics.vit.sam import SAM

View File

@ -47,7 +47,7 @@ def on_predict_postprocess_end(predictor):
tracks = predictor.trackers[i].update(det, im0s[i])
if len(tracks) == 0:
continue
idx = tracks[:, -1].tolist()
idx = tracks[:, -1].astype(int)
predictor.results[i] = predictor.results[i][idx]
predictor.results[i].update(boxes=torch.as_tensor(tracks[:, :-1]))

View File

@ -82,8 +82,8 @@ class SamAutomaticMaskGenerator:
memory.
"""
assert (points_per_side is None) != (point_grids is
None), 'Exactly one of points_per_side or point_grid must be provided.'
assert (points_per_side is None) != (point_grids is None), \
'Exactly one of points_per_side or point_grid must be provided.'
if points_per_side is not None:
self.point_grids = build_all_layer_point_grids(
points_per_side,

View File

@ -115,10 +115,8 @@ class BasePredictor:
im (torch.Tensor | List(np.ndarray)): (N, 3, h, w) for tensor, [(h, w, 3) x N] for list.
"""
if not isinstance(im, torch.Tensor):
auto = all(x.shape == im[0].shape for x in im) and self.model.pt
if not auto:
LOGGER.warning(
'WARNING ⚠️ Source shapes differ. For optimal performance supply similarly-shaped sources.')
same_shapes = all(x.shape == im[0].shape for x in im)
auto = same_shapes and self.model.pt
im = np.stack([LetterBox(self.imgsz, auto=auto, stride=self.model.stride)(image=x) for x in im])
im = im[..., ::-1].transpose((0, 3, 1, 2)) # BGR to RGB, BHWC to BCHW, (n, 3, h, w)
im = np.ascontiguousarray(im) # contiguous

View File

@ -259,13 +259,14 @@ def yaml_save(file='data.yaml', data=None):
# Create parent directories if they don't exist
file.parent.mkdir(parents=True, exist_ok=True)
# Convert Path objects to strings
for k, v in data.items():
if isinstance(v, Path):
dict[k] = str(v)
# Dump data to file in YAML format
with open(file, 'w') as f:
# Dump data to file in YAML format, converting Path objects to strings
yaml.safe_dump({k: str(v) if isinstance(v, Path) else v
for k, v in data.items()},
f,
sort_keys=False,
allow_unicode=True)
yaml.safe_dump(data, f, sort_keys=False, allow_unicode=True)
def yaml_load(file='data.yaml', append_filename=False):
@ -759,7 +760,7 @@ ENVIRONMENT = 'Colab' if is_colab() else 'Kaggle' if is_kaggle() else 'Jupyter'
TESTS_RUNNING = is_pytest_running() or is_github_actions_ci()
set_sentry()
# OpenCV Multilanguage-friendly functions ------------------------------------------------------------------------------------
# OpenCV Multilanguage-friendly functions ------------------------------------------------------------------------------
imshow_ = cv2.imshow # copy to avoid recursion errors

View File

@ -481,9 +481,6 @@ def feature_visualization(x, module_type, stage, n=32, save_dir=Path('runs/detec
stage (int): Module stage within the model.
n (int, optional): Maximum number of feature maps to plot. Defaults to 32.
save_dir (Path, optional): Directory to save results. Defaults to Path('runs/detect/exp').
Returns:
None: This function does not return any value; it saves the visualization to the specified directory.
"""
for m in ['Detect', 'Pose', 'Segment']:
if m in module_type:

View File

@ -212,7 +212,6 @@ class 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_bboxes /= stride_tensor
target_scores_sum = max(target_scores.sum(), 1)
# cls loss
@ -221,6 +220,7 @@ class Loss:
# bbox loss
if fg_mask.sum():
target_bboxes /= stride_tensor
loss[0], loss[2] = self.bbox_loss(pred_distri, pred_bboxes, anchor_points, target_bboxes, target_scores,
target_scores_sum, fg_mask)