ultralytics 8.1.19 PNNX aarch64 linux fix (#8480)

Co-authored-by: Burhan <62214284+Burhan-Q@users.noreply.github.com>
Co-authored-by: Kayzwer <68285002+Kayzwer@users.noreply.github.com>
This commit is contained in:
Glenn Jocher 2024-02-27 00:02:29 +01:00 committed by GitHub
parent 70f533fd47
commit f8e681c2be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 14 additions and 9 deletions

View File

@ -1,6 +1,6 @@
# Ultralytics YOLO 🚀, AGPL-3.0 license # Ultralytics YOLO 🚀, AGPL-3.0 license
__version__ = "8.1.18" __version__ = "8.1.19"
from ultralytics.data.explorer.explorer import Explorer from ultralytics.data.explorer.explorer import Explorer
from ultralytics.models import RTDETR, SAM, YOLO, YOLOWorld from ultralytics.models import RTDETR, SAM, YOLO, YOLOWorld

View File

@ -365,6 +365,9 @@ def check_cls_dataset(dataset, split=""):
# Download (optional if dataset=https://file.zip is passed directly) # Download (optional if dataset=https://file.zip is passed directly)
if str(dataset).startswith(("http:/", "https:/")): if str(dataset).startswith(("http:/", "https:/")):
dataset = safe_download(dataset, dir=DATASETS_DIR, unzip=True, delete=False) dataset = safe_download(dataset, dir=DATASETS_DIR, unzip=True, delete=False)
elif Path(dataset).suffix in (".zip", ".tar", ".gz"):
file = check_file(dataset)
dataset = safe_download(file, dir=DATASETS_DIR, unzip=True, delete=False)
dataset = Path(dataset) dataset = Path(dataset)
data_dir = (dataset if dataset.is_dir() else (DATASETS_DIR / dataset)).resolve() data_dir = (dataset if dataset.is_dir() else (DATASETS_DIR / dataset)).resolve()

View File

@ -514,12 +514,12 @@ class Exporter:
"https://github.com/pnnx/pnnx/.\nNote PNNX Binary file must be placed in current working directory " "https://github.com/pnnx/pnnx/.\nNote PNNX Binary file must be placed in current working directory "
f"or in {ROOT}. See PNNX repo for full installation instructions." f"or in {ROOT}. See PNNX repo for full installation instructions."
) )
system = ["macos"] if MACOS else ["windows"] if WINDOWS else ["ubuntu", "linux"] # operating system system = "macos" if MACOS else "windows" if WINDOWS else "linux-aarch64" if ARM64 else "linux"
try: try:
_, assets = get_github_assets(repo="pnnx/pnnx", retry=True) _, assets = get_github_assets(repo="pnnx/pnnx", retry=True)
url = [x for x in assets if any(s in x for s in system)][0] url = [x for x in assets if f"{system}.zip" in x][0]
except Exception as e: except Exception as e:
url = f"https://github.com/pnnx/pnnx/releases/download/20231127/pnnx-20231127-{system[0]}.zip" url = f"https://github.com/pnnx/pnnx/releases/download/20240226/pnnx-20240226-{system}.zip"
LOGGER.warning(f"{prefix} WARNING ⚠️ PNNX GitHub assets not found: {e}, using default {url}") LOGGER.warning(f"{prefix} WARNING ⚠️ PNNX GitHub assets not found: {e}, using default {url}")
asset = attempt_download_asset(url, repo="pnnx/pnnx", release="latest") asset = attempt_download_asset(url, repo="pnnx/pnnx", release="latest")
if check_is_path_safe(Path.cwd(), asset): # avoid path traversal security vulnerability if check_is_path_safe(Path.cwd(), asset): # avoid path traversal security vulnerability

View File

@ -638,7 +638,7 @@ def crop_mask(masks, boxes):
Returns: Returns:
(torch.Tensor): The masks are being cropped to the bounding box. (torch.Tensor): The masks are being cropped to the bounding box.
""" """
n, h, w = masks.shape _, h, w = masks.shape
x1, y1, x2, y2 = torch.chunk(boxes[:, :, None], 4, 1) # x1 shape(n,1,1) x1, y1, x2, y2 = torch.chunk(boxes[:, :, None], 4, 1) # x1 shape(n,1,1)
r = torch.arange(w, device=masks.device, dtype=x1.dtype)[None, None, :] # rows shape(1,1,w) r = torch.arange(w, device=masks.device, dtype=x1.dtype)[None, None, :] # rows shape(1,1,w)
c = torch.arange(h, device=masks.device, dtype=x1.dtype)[None, :, None] # cols shape(1,h,1) c = torch.arange(h, device=masks.device, dtype=x1.dtype)[None, :, None] # cols shape(1,h,1)
@ -686,12 +686,14 @@ def process_mask(protos, masks_in, bboxes, shape, upsample=False):
c, mh, mw = protos.shape # CHW c, mh, mw = protos.shape # CHW
ih, iw = shape ih, iw = shape
masks = (masks_in @ protos.float().view(c, -1)).sigmoid().view(-1, mh, mw) # CHW masks = (masks_in @ protos.float().view(c, -1)).sigmoid().view(-1, mh, mw) # CHW
width_ratio = mw / iw
height_ratio = mh / ih
downsampled_bboxes = bboxes.clone() downsampled_bboxes = bboxes.clone()
downsampled_bboxes[:, 0] *= mw / iw downsampled_bboxes[:, 0] *= width_ratio
downsampled_bboxes[:, 2] *= mw / iw downsampled_bboxes[:, 2] *= width_ratio
downsampled_bboxes[:, 3] *= mh / ih downsampled_bboxes[:, 3] *= height_ratio
downsampled_bboxes[:, 1] *= mh / ih downsampled_bboxes[:, 1] *= height_ratio
masks = crop_mask(masks, downsampled_bboxes) # CHW masks = crop_mask(masks, downsampled_bboxes) # CHW
if upsample: if upsample: