ultralytics 8.3.6__py3-none-any.whl → 8.3.7__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.3.6"
3
+ __version__ = "8.3.7"
4
4
 
5
5
  import os
6
6
 
@@ -1,13 +1,18 @@
1
1
  # Ultralytics YOLO 🚀, AGPL-3.0 license
2
2
 
3
3
  import json
4
+ import random
5
+ import shutil
4
6
  from collections import defaultdict
7
+ from concurrent.futures import ThreadPoolExecutor, as_completed
5
8
  from pathlib import Path
6
9
 
7
10
  import cv2
8
11
  import numpy as np
12
+ from PIL import Image
9
13
 
10
- from ultralytics.utils import LOGGER, TQDM
14
+ from ultralytics.utils import DATASETS_DIR, LOGGER, NUM_THREADS, TQDM
15
+ from ultralytics.utils.downloads import download
11
16
  from ultralytics.utils.files import increment_path
12
17
 
13
18
 
@@ -588,15 +593,13 @@ def yolo_bbox2segment(im_dir, save_dir=None, sam_model="sam_b.pt"):
588
593
 
589
594
  - im_dir
590
595
  ├─ 001.jpg
591
- ├─ ..
596
+ ├─ ...
592
597
  └─ NNN.jpg
593
598
  - labels
594
599
  ├─ 001.txt
595
- ├─ ..
600
+ ├─ ...
596
601
  └─ NNN.txt
597
602
  """
598
- from tqdm import tqdm
599
-
600
603
  from ultralytics import SAM
601
604
  from ultralytics.data import YOLODataset
602
605
  from ultralytics.utils import LOGGER
@@ -610,7 +613,7 @@ def yolo_bbox2segment(im_dir, save_dir=None, sam_model="sam_b.pt"):
610
613
 
611
614
  LOGGER.info("Detection labels detected, generating segment labels by SAM model!")
612
615
  sam_model = SAM(sam_model)
613
- for label in tqdm(dataset.labels, total=len(dataset.labels), desc="Generating segment labels"):
616
+ for label in TQDM(dataset.labels, total=len(dataset.labels), desc="Generating segment labels"):
614
617
  h, w = label["shape"]
615
618
  boxes = label["bboxes"]
616
619
  if len(boxes) == 0: # skip empty labels
@@ -635,3 +638,58 @@ def yolo_bbox2segment(im_dir, save_dir=None, sam_model="sam_b.pt"):
635
638
  with open(txt_file, "a") as f:
636
639
  f.writelines(text + "\n" for text in texts)
637
640
  LOGGER.info(f"Generated segment labels saved in {save_dir}")
641
+
642
+
643
+ def create_synthetic_coco_dataset():
644
+ """
645
+ Creates a synthetic COCO dataset with random images and existing labels.
646
+
647
+ This function downloads COCO labels, creates synthetic images for train2017 and val2017 subsets, and organizes
648
+ them in the COCO dataset structure. It uses multithreading to generate images efficiently.
649
+
650
+ Examples:
651
+ >>> create_synthetic_coco_dataset()
652
+
653
+ Notes:
654
+ - Requires internet connection to download label files.
655
+ - Generates random RGB images of varying sizes (480x480 to 640x640 pixels).
656
+ - Existing test2017 directory is removed as it's not needed.
657
+ - If label directories don't exist, image creation for that subset is skipped.
658
+ """
659
+
660
+ def create_synthetic_image(image_file):
661
+ """Generates synthetic images with random sizes and colors for dataset augmentation or testing purposes."""
662
+ if not image_file.exists():
663
+ size = (random.randint(480, 640), random.randint(480, 640))
664
+ Image.new(
665
+ "RGB",
666
+ size=size,
667
+ color=(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)),
668
+ ).save(image_file)
669
+
670
+ # Download labels
671
+ dir = DATASETS_DIR / "coco"
672
+ url = "https://github.com/ultralytics/assets/releases/download/v0.0.0/"
673
+ label_zip = "coco2017labels-segments.zip"
674
+ download([url + label_zip], dir=dir.parent)
675
+
676
+ # Create synthetic images
677
+ shutil.rmtree(dir / "labels" / "test2017", ignore_errors=True) # Remove test2017 directory as not needed
678
+ with ThreadPoolExecutor(max_workers=NUM_THREADS) as executor:
679
+ for subset in ["train2017", "val2017"]:
680
+ subset_dir = dir / "images" / subset
681
+ subset_dir.mkdir(parents=True, exist_ok=True)
682
+
683
+ label_dir = dir / "labels" / subset
684
+ if label_dir.exists():
685
+ label_files = list(label_dir.glob("*.txt"))
686
+ image_files = [subset_dir / f"{label_file.stem}.jpg" for label_file in label_files]
687
+
688
+ # Submit all tasks
689
+ futures = [executor.submit(create_synthetic_image, image_file) for image_file in image_files]
690
+ for _ in TQDM(as_completed(futures), total=len(futures), desc=f"Generating images for {subset}"):
691
+ pass # The actual work is done in the background
692
+ else:
693
+ print(f"Warning: Label directory {label_dir} does not exist. Skipping image creation for {subset}.")
694
+
695
+ print("Synthetic COCO dataset created successfully.")
@@ -39,24 +39,11 @@ def init_explorer_form(data=None, model=None):
39
39
  else:
40
40
  ds = [data]
41
41
 
42
+ prefixes = ["yolov8", "yolo11"]
43
+ sizes = ["n", "s", "m", "l", "x"]
44
+ tasks = ["", "-seg", "-pose"]
42
45
  if model is None:
43
- models = [
44
- "yolov8n.pt",
45
- "yolov8s.pt",
46
- "yolov8m.pt",
47
- "yolov8l.pt",
48
- "yolov8x.pt",
49
- "yolov8n-seg.pt",
50
- "yolov8s-seg.pt",
51
- "yolov8m-seg.pt",
52
- "yolov8l-seg.pt",
53
- "yolov8x-seg.pt",
54
- "yolov8n-pose.pt",
55
- "yolov8s-pose.pt",
56
- "yolov8m-pose.pt",
57
- "yolov8l-pose.pt",
58
- "yolov8x-pose.pt",
59
- ]
46
+ models = [f"{p}{s}{t}" for p in prefixes for s in sizes for t in tasks]
60
47
  else:
61
48
  models = [model]
62
49
 
@@ -544,6 +544,8 @@ class Model(nn.Module):
544
544
 
545
545
  if not self.predictor:
546
546
  self.predictor = predictor or self._smart_load("predictor")(overrides=args, _callbacks=self.callbacks)
547
+ if predictor:
548
+ self.predictor.args = get_cfg(self.predictor.args, args)
547
549
  self.predictor.setup_model(model=self.model, verbose=is_cli)
548
550
  else: # only update args if predictor is already setup
549
551
  self.predictor.args = get_cfg(self.predictor.args, args)
@@ -69,7 +69,7 @@ def autobatch(model, imgsz=640, fraction=0.60, batch_size=DEFAULT_CFG.batch):
69
69
  batch_sizes = [1, 2, 4, 8, 16]
70
70
  try:
71
71
  img = [torch.empty(b, 3, imgsz, imgsz) for b in batch_sizes]
72
- results = profile(img, model, n=3, device=device)
72
+ results = profile(img, model, n=1, device=device)
73
73
 
74
74
  # Fit a solution
75
75
  y = [x[2] for x in results if x] # memory [2]
@@ -89,3 +89,5 @@ def autobatch(model, imgsz=640, fraction=0.60, batch_size=DEFAULT_CFG.batch):
89
89
  except Exception as e:
90
90
  LOGGER.warning(f"{prefix}WARNING ⚠️ error detected: {e}, using default batch-size {batch_size}.")
91
91
  return batch_size
92
+ finally:
93
+ torch.cuda.empty_cache()
@@ -643,7 +643,8 @@ def profile(input, ops, n=10, device=None):
643
643
  f"{'Params':>12s}{'GFLOPs':>12s}{'GPU_mem (GB)':>14s}{'forward (ms)':>14s}{'backward (ms)':>14s}"
644
644
  f"{'input':>24s}{'output':>24s}"
645
645
  )
646
-
646
+ gc.collect() # attempt to free unused memory
647
+ torch.cuda.empty_cache()
647
648
  for x in input if isinstance(input, list) else [input]:
648
649
  x = x.to(device)
649
650
  x.requires_grad = True
@@ -677,8 +678,9 @@ def profile(input, ops, n=10, device=None):
677
678
  except Exception as e:
678
679
  LOGGER.info(e)
679
680
  results.append(None)
680
- gc.collect() # attempt to free unused memory
681
- torch.cuda.empty_cache()
681
+ finally:
682
+ gc.collect() # attempt to free unused memory
683
+ torch.cuda.empty_cache()
682
684
  return results
683
685
 
684
686
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ultralytics
3
- Version: 8.3.6
3
+ Version: 8.3.7
4
4
  Summary: Ultralytics YOLO for SOTA object detection, multi-object tracking, instance segmentation, pose estimation and image classification.
5
5
  Author-email: Glenn Jocher <glenn.jocher@ultralytics.com>, Jing Qiu <jing.qiu@ultralytics.com>
6
6
  Maintainer-email: Ultralytics <hello@ultralytics.com>
@@ -8,7 +8,7 @@ tests/test_exports.py,sha256=fpTKEVBUGLF3WiZPNKRs-IEcIY4cfxgvgKjUNfodjww,8042
8
8
  tests/test_integrations.py,sha256=f5-QCUk1SU_-qn4mBCZwS3GN3tXEBIIXo4z2EhExbHw,6126
9
9
  tests/test_python.py,sha256=I1RRdCwLdrc3jX06huVxct8HX8ccQOmQgVpuEflRl0U,23560
10
10
  tests/test_solutions.py,sha256=GYOjUXor2pHGPFwvZrmqrxNjs9wYz4r3_XWt8DMAVaM,3132
11
- ultralytics/__init__.py,sha256=WlkyTS3L-3ozTAF5fT2vLMSf4tQNvOaCxGsICIQf7mA,693
11
+ ultralytics/__init__.py,sha256=JGCg6lJcabOg0oS20n6yzYPiDSaT51M3woQo45mHgbM,693
12
12
  ultralytics/assets/bus.jpg,sha256=wCAZxJecGR63Od3ZRERe9Aja1Weayrb9Ug751DS_vGM,137419
13
13
  ultralytics/assets/zidane.jpg,sha256=Ftc4aeMmen1O0A3o6GCDO9FlfBslLpTAw0gnetx7bts,50427
14
14
  ultralytics/cfg/__init__.py,sha256=62PSSAa0W4-gAEcRNKoKbcxUWBeFNs0ss2O4XJQhOPY,33145
@@ -94,7 +94,7 @@ ultralytics/data/annotator.py,sha256=PniOxH2MScWKp539vuufk69uG1JsltDB5OMCUhxn2QY
94
94
  ultralytics/data/augment.py,sha256=YCLrwx1mRGeidggo_7GeINay8KdxACqREHJofZeaTHA,120430
95
95
  ultralytics/data/base.py,sha256=ZCIhAyFfxXVp5fVnYD8mwbksNALJTayBKIR5FKGV7ZM,15168
96
96
  ultralytics/data/build.py,sha256=AfMmz0sHIYmwry_90tEJFRk_kz0S3SolScVXqYHiT08,7261
97
- ultralytics/data/converter.py,sha256=DjJ0atku2aKW0iS1PZPNX8V6WTrZ-CHZT6hopE1HSjI,21385
97
+ ultralytics/data/converter.py,sha256=7GH5HeSY_OafcornXg5m_5ioU_mtbYopsJV6F4PZTOY,24092
98
98
  ultralytics/data/dataset.py,sha256=IS07ulk7rXPZ-SW_rjYF9mS-TxPXOY9bbo5jqfcwPqM,22874
99
99
  ultralytics/data/loaders.py,sha256=JF2Z_ESK6RweavOuYWejYSGJwmqINb5hNwwCb3AAf0M,24094
100
100
  ultralytics/data/split_dota.py,sha256=yOtypHoY5HvIVBKZgFXdfj2tuCLLEBnMwNfAeG94Eik,10680
@@ -103,10 +103,10 @@ ultralytics/data/explorer/__init__.py,sha256=-Y3m1ZedepOQUv_KW82zaGxvU_PSHcuwUTF
103
103
  ultralytics/data/explorer/explorer.py,sha256=JWmLHHhp68h2q3vx4poBou5RYoAX3R89yihR50YLDb0,18881
104
104
  ultralytics/data/explorer/utils.py,sha256=EvvukQiQUTBrsZznmMnyEX2EqTuwZo_Geyc8yfi8NIA,7085
105
105
  ultralytics/data/explorer/gui/__init__.py,sha256=mHtJuK4hwF8cuV-VHDc7tp6u6D1gHz2Z7JI8grmQDTs,42
106
- ultralytics/data/explorer/gui/dash.py,sha256=vZ476NaUH4FKU08rAJ1K9WNyKtg0soMyJJxqg176yWc,10498
106
+ ultralytics/data/explorer/gui/dash.py,sha256=6XOZy9NrkPEXREJPbi0EBkGgu78TAdHpdhSB2HuBOAo,10222
107
107
  ultralytics/engine/__init__.py,sha256=mHtJuK4hwF8cuV-VHDc7tp6u6D1gHz2Z7JI8grmQDTs,42
108
108
  ultralytics/engine/exporter.py,sha256=DeHW_T_Zd3A21BLQYV1-FnS5EcmepMOy9nrussYNieU,57505
109
- ultralytics/engine/model.py,sha256=TDuy9JzzyvOaq5aKVljL_MFRKBDMCFwaLo3JD_d45CU,51462
109
+ ultralytics/engine/model.py,sha256=ijssmZVX9K1y6t2qUgRjQB8ZfZmIatU2_-KFPoyUJ3M,51561
110
110
  ultralytics/engine/predictor.py,sha256=MgMWHUJdRcVCaVmOyvdy2Gjk_EyRHv-ar0SSGxQe8F4,17471
111
111
  ultralytics/engine/results.py,sha256=8RJlN8J-_9w-mrDZm9wC-DZJTPBS7v1c_r_R173QyRM,75043
112
112
  ultralytics/engine/trainer.py,sha256=ZCEXUPbJG_8Hzn2mLergk3WV-41ei0LT84Tspk0le30,37147
@@ -205,7 +205,7 @@ ultralytics/trackers/utils/gmc.py,sha256=VcURuY041qGCeWUGMxHZBr10T16LtcMqyv7AmTf
205
205
  ultralytics/trackers/utils/kalman_filter.py,sha256=cH9zD3fwkuezP97H9mw8cSBN7a8hHKx_Sx1j7t3oYGs,21349
206
206
  ultralytics/trackers/utils/matching.py,sha256=3Ie1WNNRZ4_q3365F03XD7Nr9juZB_08mw4yUKC3w74,7162
207
207
  ultralytics/utils/__init__.py,sha256=XAfItx7avPCi7fpT7rRyQQqgjh2OwoSEkvkp01BbtYc,48760
208
- ultralytics/utils/autobatch.py,sha256=AXboYfNSnTGsYj5FmgGYPQd0crfkeleyms6QXQfZGQ4,4194
208
+ ultralytics/utils/autobatch.py,sha256=XbTgvnO9z27ePUDEoIMVc9XOoktPPLOFDoDxF9w3YxU,4240
209
209
  ultralytics/utils/benchmarks.py,sha256=8FYp5WPzcxcDaeg8ol2sgzRBHVGYatEO7f3MrmPF6nI,25097
210
210
  ultralytics/utils/checks.py,sha256=7peQ6Ra7mgcu5Xt1XbYiMEJkO-8aYPHco7CBVRQ_oR4,29559
211
211
  ultralytics/utils/dist.py,sha256=NDFga-uKxkBX2zLxFHSene_cCiGQJoyOeCXcN9JIOIk,2358
@@ -219,7 +219,7 @@ ultralytics/utils/ops.py,sha256=dsXNdyrYx_p6io6zezig9p84dxS7U-10vceHNVu2IL0,3288
219
219
  ultralytics/utils/patches.py,sha256=J-iOwIRbfUs-inBZerhnXby5tUKjYcOIyvhLTS352JE,3270
220
220
  ultralytics/utils/plotting.py,sha256=UQMgubdCKkIcKLLIXkE6uM9dhL7NlFRka6xXgfCMFn8,61153
221
221
  ultralytics/utils/tal.py,sha256=ECsu95xEqOItmxMDN4YTD3FsUiIsQNWy0pZC3TfvFfk,16877
222
- ultralytics/utils/torch_utils.py,sha256=Dji6ELzywm4yq1D4AbUhOsanmoo9-pwxx5GBlYdIgqU,29956
222
+ ultralytics/utils/torch_utils.py,sha256=Xksge9bLYEo4DMsZtMIQQc5BOw2Py4xyZMUbCXGCKQo,30063
223
223
  ultralytics/utils/triton.py,sha256=gg1finxno_tY2Ge9PMhmu7PI9wvoFZoiicdT4Bhqv3w,3936
224
224
  ultralytics/utils/tuner.py,sha256=AtEtK6pOt9xVTyx864OpNRVxNdAxz5aKHzveiXwkD1A,6250
225
225
  ultralytics/utils/callbacks/__init__.py,sha256=YrWqC3BVVaTLob4iCPR6I36mUxIUOpPJW7B_LjT78Qw,214
@@ -233,9 +233,9 @@ ultralytics/utils/callbacks/neptune.py,sha256=5Z3ua5YBTUS56FH8VQKQG1aaIo9fH8GEyz
233
233
  ultralytics/utils/callbacks/raytune.py,sha256=ODVYzy-CoM4Uge0zjkh3Hnh9nF2M0vhDrSenXnvcizw,705
234
234
  ultralytics/utils/callbacks/tensorboard.py,sha256=0kn4IR10no99UCIheojWRujgybmUHSx5fPI6Vsq6l_g,4135
235
235
  ultralytics/utils/callbacks/wb.py,sha256=9-fjQIdLjr3b73DTE3rHO171KvbH1VweJ-bmbv-rqTw,6747
236
- ultralytics-8.3.6.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
237
- ultralytics-8.3.6.dist-info/METADATA,sha256=8c1KpR7WhT8HlvpimiFOS4G3vd8KtQ8YxBUHYnQ_dDc,34699
238
- ultralytics-8.3.6.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
239
- ultralytics-8.3.6.dist-info/entry_points.txt,sha256=YM_wiKyTe9yRrsEfqvYolNO5ngwfoL4-NwgKzc8_7sI,93
240
- ultralytics-8.3.6.dist-info/top_level.txt,sha256=XP49TwiMw4QGsvTLSYiJhz1xF_k7ev5mQ8jJXaXi45Q,12
241
- ultralytics-8.3.6.dist-info/RECORD,,
236
+ ultralytics-8.3.7.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
237
+ ultralytics-8.3.7.dist-info/METADATA,sha256=c7wEDYkKofh_A-k4ToAXV_yhJnpbHsmiDPEATsSyz_w,34699
238
+ ultralytics-8.3.7.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
239
+ ultralytics-8.3.7.dist-info/entry_points.txt,sha256=YM_wiKyTe9yRrsEfqvYolNO5ngwfoL4-NwgKzc8_7sI,93
240
+ ultralytics-8.3.7.dist-info/top_level.txt,sha256=XP49TwiMw4QGsvTLSYiJhz1xF_k7ev5mQ8jJXaXi45Q,12
241
+ ultralytics-8.3.7.dist-info/RECORD,,