ultralytics 8.0.206__py3-none-any.whl → 8.0.207__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ultralytics might be problematic. Click here for more details.

ultralytics/__init__.py CHANGED
@@ -1,6 +1,6 @@
1
1
  # Ultralytics YOLO 🚀, AGPL-3.0 license
2
2
 
3
- __version__ = '8.0.206'
3
+ __version__ = '8.0.207'
4
4
 
5
5
  from ultralytics.models import RTDETR, SAM, YOLO
6
6
  from ultralytics.models.fastsam import FastSAM
@@ -69,7 +69,7 @@ from ultralytics.nn.modules import C2f, Detect, RTDETRDecoder
69
69
  from ultralytics.nn.tasks import DetectionModel, SegmentationModel
70
70
  from ultralytics.utils import (ARM64, DEFAULT_CFG, LINUX, LOGGER, MACOS, ROOT, WINDOWS, __version__, callbacks,
71
71
  colorstr, get_default_args, yaml_save)
72
- from ultralytics.utils.checks import check_imgsz, check_requirements, check_version
72
+ from ultralytics.utils.checks import check_imgsz, check_is_path_safe, check_requirements, check_version
73
73
  from ultralytics.utils.downloads import attempt_download_asset, get_github_assets
74
74
  from ultralytics.utils.files import file_size, spaces_in_path
75
75
  from ultralytics.utils.ops import Profile
@@ -450,12 +450,9 @@ class Exporter:
450
450
  f = Path(str(self.file).replace(self.file.suffix, f'_ncnn_model{os.sep}'))
451
451
  f_ts = self.file.with_suffix('.torchscript')
452
452
 
453
- pnnx_filename = 'pnnx.exe' if WINDOWS else 'pnnx'
454
- if Path(pnnx_filename).is_file():
455
- pnnx = pnnx_filename
456
- elif (ROOT / pnnx_filename).is_file():
457
- pnnx = ROOT / pnnx_filename
458
- else:
453
+ name = Path('pnnx.exe' if WINDOWS else 'pnnx') # PNNX filename
454
+ pnnx = name if name.is_file() else ROOT / name
455
+ if not pnnx.is_file():
459
456
  LOGGER.warning(
460
457
  f'{prefix} WARNING ⚠️ PNNX not found. Attempting to download binary file from '
461
458
  'https://github.com/pnnx/pnnx/.\nNote PNNX Binary file must be placed in current working directory '
@@ -465,12 +462,12 @@ class Exporter:
465
462
  asset = [x for x in assets if system in x][0] if assets else \
466
463
  f'https://github.com/pnnx/pnnx/releases/download/20230816/pnnx-20230816-{system}.zip' # fallback
467
464
  asset = attempt_download_asset(asset, repo='pnnx/pnnx', release='latest')
468
- unzip_dir = Path(asset).with_suffix('')
469
- pnnx = ROOT / pnnx_filename # new location
470
- (unzip_dir / pnnx_filename).rename(pnnx) # move binary to ROOT
471
- shutil.rmtree(unzip_dir) # delete unzip dir
472
- Path(asset).unlink() # delete zip
473
- pnnx.chmod(0o777) # set read, write, and execute permissions for everyone
465
+ if check_is_path_safe(Path.cwd(), asset): # avoid path traversal security vulnerability
466
+ unzip_dir = Path(asset).with_suffix('')
467
+ (unzip_dir / name).rename(pnnx) # move binary to ROOT
468
+ shutil.rmtree(unzip_dir) # delete unzip dir
469
+ Path(asset).unlink() # delete zip
470
+ pnnx.chmod(0o777) # set read, write, and execute permissions for everyone
474
471
 
475
472
  ncnn_args = [
476
473
  f'ncnnparam={f / "model.ncnn.param"}',
@@ -38,13 +38,13 @@ def on_predict_start(predictor, persist=False):
38
38
  predictor.trackers = trackers
39
39
 
40
40
 
41
- def on_predict_postprocess_end(predictor):
41
+ def on_predict_postprocess_end(predictor, persist=False):
42
42
  """Postprocess detected boxes and update with object tracking."""
43
43
  bs = predictor.dataset.bs
44
44
  path, im0s = predictor.batch[:2]
45
45
 
46
46
  for i in range(bs):
47
- if predictor.vid_path[i] != str(predictor.save_dir / Path(path[i]).name): # new video
47
+ if not persist and predictor.vid_path[i] != str(predictor.save_dir / Path(path[i]).name): # new video
48
48
  predictor.trackers[i].reset()
49
49
 
50
50
  det = predictor.results[i].boxes.cpu().numpy()
@@ -67,4 +67,4 @@ def register_tracker(model, persist):
67
67
  persist (bool): Whether to persist the trackers if they already exist.
68
68
  """
69
69
  model.add_callback('on_predict_start', partial(on_predict_start, persist=persist))
70
- model.add_callback('on_predict_postprocess_end', on_predict_postprocess_end)
70
+ model.add_callback('on_predict_postprocess_end', partial(on_predict_postprocess_end, persist=persist))
@@ -463,6 +463,23 @@ def check_yaml(file, suffix=('.yaml', '.yml'), hard=True):
463
463
  return check_file(file, suffix, hard=hard)
464
464
 
465
465
 
466
+ def check_is_path_safe(basedir, path):
467
+ """
468
+ Check if the resolved path is under the intended directory to prevent path traversal.
469
+
470
+ Args:
471
+ basedir (Path | str): The intended directory.
472
+ path (Path | str): The path to check.
473
+
474
+ Returns:
475
+ (bool): True if the path is safe, False otherwise.
476
+ """
477
+ base_dir_resolved = Path(basedir).resolve()
478
+ path_resolved = Path(path).resolve()
479
+
480
+ return path_resolved.is_file() and path_resolved.parts[:len(base_dir_resolved.parts)] == base_dir_resolved.parts
481
+
482
+
466
483
  def check_imshow(warn=False):
467
484
  """Check if environment supports image displays."""
468
485
  try:
@@ -159,7 +159,11 @@ def unzip_file(file, path=None, exclude=('.DS_Store', '__MACOSX'), exist_ok=Fals
159
159
  return path
160
160
 
161
161
  for f in TQDM(files, desc=f'Unzipping {file} to {Path(path).resolve()}...', unit='file', disable=not progress):
162
- zipObj.extract(f, path=extract_path)
162
+ # Ensure the file is within the extract_path to avoid path traversal security vulnerability
163
+ if '..' in Path(f).parts:
164
+ LOGGER.warning(f'Potentially insecure file path: {f}, skipping extraction.')
165
+ continue
166
+ zipObj.extract(f, extract_path)
163
167
 
164
168
  return path # return unzip dir
165
169
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ultralytics
3
- Version: 8.0.206
3
+ Version: 8.0.207
4
4
  Summary: Ultralytics YOLOv8 for SOTA object detection, multi-object tracking, instance segmentation, pose estimation and image classification.
5
5
  Home-page: https://github.com/ultralytics/ultralytics
6
6
  Author: Ultralytics
@@ -1,4 +1,4 @@
1
- ultralytics/__init__.py,sha256=biOjbAEKQxgwlt21rhdmPEFrPXGW-DED8kSR7V_vrwQ,463
1
+ ultralytics/__init__.py,sha256=IHTkAvMFdc8fykdZi4by2TW-zMnNVMgbOHmsRVbTb64,463
2
2
  ultralytics/assets/bus.jpg,sha256=wCAZxJecGR63Od3ZRERe9Aja1Weayrb9Ug751DS_vGM,137419
3
3
  ultralytics/assets/zidane.jpg,sha256=Ftc4aeMmen1O0A3o6GCDO9FlfBslLpTAw0gnetx7bts,50427
4
4
  ultralytics/cfg/__init__.py,sha256=0rNpfVEF_zlbp7vjteMEtawvyQJ_X-CXgZI5xCyE4QQ,19672
@@ -50,7 +50,7 @@ ultralytics/data/dataset.py,sha256=IZyVml86cLF2t8Y8rToEN-H-OSdt5QQgXAFHo6YAJ_U,1
50
50
  ultralytics/data/loaders.py,sha256=wcxTmUXo-MLzHDgiCPqIz1a5Ab8zxDRCbqTlk4hqDLc,22093
51
51
  ultralytics/data/utils.py,sha256=MaTz8IkSrts2RVK3GLS3OHvVCAZmavxmOWKvUgy9tBQ,29632
52
52
  ultralytics/engine/__init__.py,sha256=mHtJuK4hwF8cuV-VHDc7tp6u6D1gHz2Z7JI8grmQDTs,42
53
- ultralytics/engine/exporter.py,sha256=h8p8jOt3_QDI86qA1Neer50W3yWSxgn5nTmZB2SmO8I,50142
53
+ ultralytics/engine/exporter.py,sha256=uts1Y_IwgL7VkGB034dGVqaA2ceTs4XUlJXK7O23wVc,50142
54
54
  ultralytics/engine/model.py,sha256=z-K-T1gp4hZbb1Z7MiOiOXYIFZxWeGhiwZMJjNvBbsc,19208
55
55
  ultralytics/engine/predictor.py,sha256=onTJdx0dNaHfKIWidLbC4A4o8wMcISOVJxd6_xhe4XI,16672
56
56
  ultralytics/engine/results.py,sha256=b98uVX6QHpQjgMxbWiGOwqDBgbfY0AtY1v5DU3-hVBM,23454
@@ -122,7 +122,7 @@ ultralytics/trackers/__init__.py,sha256=dR9unDaRBd6MgMnTKxqJZ0KsJ8BeFGg-LTYQvC7B
122
122
  ultralytics/trackers/basetrack.py,sha256=Jh-1Q418_4CQfhgTjmGt3bQIVQdN5XJ2AiQx2dsPJuI,1609
123
123
  ultralytics/trackers/bot_sort.py,sha256=orTkrMj2yHfEQVKaQVWbguTx98S2gvLnaOB0D2JN1Gc,8602
124
124
  ultralytics/trackers/byte_tracker.py,sha256=acUkcJTjbjPShyAb59kj_avX0G0KmdBfpYH9maRSOiw,18381
125
- ultralytics/trackers/track.py,sha256=vjsOKdEDHlLSbRSUj_G9AfnLKnuI1F3zzyFw9tR3xq4,2494
125
+ ultralytics/trackers/track.py,sha256=VU2vguyPKAPuaBTNlLa8Soc-2XbR_7IltZfLySe_irw,2551
126
126
  ultralytics/trackers/utils/__init__.py,sha256=mHtJuK4hwF8cuV-VHDc7tp6u6D1gHz2Z7JI8grmQDTs,42
127
127
  ultralytics/trackers/utils/gmc.py,sha256=H9Td7oLj-RKRsVNUETsMqcedJENV-jG03cCmwK-Tpo4,12366
128
128
  ultralytics/trackers/utils/kalman_filter.py,sha256=PM3I6DkBlS-cDm3kc7L5XD3XSbcGajgRxiqrvUJAIBY,14850
@@ -130,9 +130,9 @@ ultralytics/trackers/utils/matching.py,sha256=U8tfb8tfOYs_QtHQ-rGT4ZhthUcSAYh6X_
130
130
  ultralytics/utils/__init__.py,sha256=tIeKKWxmSBl6PRpAH2fnCSluXXa7AvEtbbl_WEOjSA0,33649
131
131
  ultralytics/utils/autobatch.py,sha256=mZjJerTi6WTzGq1_0JiU8XNHi70b1psCOAE-feZROgs,3862
132
132
  ultralytics/utils/benchmarks.py,sha256=ct6g9UyfHPi6a7_EuppbTrVeu_ePiCLF7Kib8RZKRgw,18217
133
- ultralytics/utils/checks.py,sha256=AzfiUf9y_RIAlBq8RnQhDehFKyBt0nJsq-LnMAxedHM,26278
133
+ ultralytics/utils/checks.py,sha256=tt-gsMIC0Vpo3TaB8-O83tqe6Q5CWPBXPFjEVwxB0RM,26816
134
134
  ultralytics/utils/dist.py,sha256=egR2Z6Xlg75v72hddTut0q0-BIYvF-YCn_HE7PByuK8,2396
135
- ultralytics/utils/downloads.py,sha256=vkLARW1qNqWWdpdl7ep_97_ISBd6Rab_VgxOTNhq-04,17943
135
+ ultralytics/utils/downloads.py,sha256=mrU3KI7oKheRMsWqjQbv-X79Ov4vr7k_H5P3L-mw_IE,18198
136
136
  ultralytics/utils/errors.py,sha256=wcNM8Yc0ln4X868kUM6pIsjKT_W67Kez4Vm72Xe-tYo,816
137
137
  ultralytics/utils/files.py,sha256=6XTXdBqhz5xpSUYzdicedbiPyV82xwpNsZX5D2_oh9k,5280
138
138
  ultralytics/utils/instance.py,sha256=0I1sYrARGrwHr2CtUcT8_D5jteZ4xhi5NsbV-XTaldI,15936
@@ -156,9 +156,9 @@ ultralytics/utils/callbacks/neptune.py,sha256=qIN0gJipB1f3Di7bw0Rb28jLYoCzJSWSqF
156
156
  ultralytics/utils/callbacks/raytune.py,sha256=PGZvW_haVq8Cqha3GgvL7iBMAaxfn8_3u_IIdYCNMPo,608
157
157
  ultralytics/utils/callbacks/tensorboard.py,sha256=AL8geYjG2NBBn4U1iHbmwF1rHDsNhVBeAmXo1tSLVgM,2830
158
158
  ultralytics/utils/callbacks/wb.py,sha256=x_j4ZH4Klp0_Ld13f0UezFluUTS5Ovfgk9hcjwqeruU,6762
159
- ultralytics-8.0.206.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
160
- ultralytics-8.0.206.dist-info/METADATA,sha256=iQRpIntbOXrIsDTWyTLzF9D-A2FaCaYA0s7DjBr5U4g,31381
161
- ultralytics-8.0.206.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
162
- ultralytics-8.0.206.dist-info/entry_points.txt,sha256=YM_wiKyTe9yRrsEfqvYolNO5ngwfoL4-NwgKzc8_7sI,93
163
- ultralytics-8.0.206.dist-info/top_level.txt,sha256=iXnUQZuWnkCwh3InMTwthfgww_zJjOjq1Cg9CoWen_0,762
164
- ultralytics-8.0.206.dist-info/RECORD,,
159
+ ultralytics-8.0.207.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
160
+ ultralytics-8.0.207.dist-info/METADATA,sha256=mtDGleHWG9622HQHPAe5y65Csa04QzIMA907jtOOvI8,31381
161
+ ultralytics-8.0.207.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
162
+ ultralytics-8.0.207.dist-info/entry_points.txt,sha256=YM_wiKyTe9yRrsEfqvYolNO5ngwfoL4-NwgKzc8_7sI,93
163
+ ultralytics-8.0.207.dist-info/top_level.txt,sha256=iXnUQZuWnkCwh3InMTwthfgww_zJjOjq1Cg9CoWen_0,762
164
+ ultralytics-8.0.207.dist-info/RECORD,,