ultralytics 8.3.204__py3-none-any.whl → 8.3.206__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.
- tests/test_exports.py +5 -2
- ultralytics/__init__.py +6 -1
- ultralytics/engine/exporter.py +26 -7
- ultralytics/engine/model.py +1 -1
- ultralytics/nn/autobackend.py +7 -3
- ultralytics/utils/plotting.py +21 -1
- {ultralytics-8.3.204.dist-info → ultralytics-8.3.206.dist-info}/METADATA +1 -1
- {ultralytics-8.3.204.dist-info → ultralytics-8.3.206.dist-info}/RECORD +12 -12
- {ultralytics-8.3.204.dist-info → ultralytics-8.3.206.dist-info}/WHEEL +0 -0
- {ultralytics-8.3.204.dist-info → ultralytics-8.3.206.dist-info}/entry_points.txt +0 -0
- {ultralytics-8.3.204.dist-info → ultralytics-8.3.206.dist-info}/licenses/LICENSE +0 -0
- {ultralytics-8.3.204.dist-info → ultralytics-8.3.206.dist-info}/top_level.txt +0 -0
tests/test_exports.py
CHANGED
@@ -124,9 +124,12 @@ def test_export_torchscript_matrix(task, dynamic, int8, half, batch, nms):
|
|
124
124
|
[ # generate all combinations except for exclusion cases
|
125
125
|
(task, dynamic, int8, half, nms, batch)
|
126
126
|
for task, dynamic, int8, half, nms, batch in product(
|
127
|
-
TASKS, [False], [True, False], [True, False], [True, False], [1]
|
127
|
+
TASKS, [True, False], [True, False], [True, False], [True, False], [1]
|
128
128
|
)
|
129
|
-
if not (int8 and half)
|
129
|
+
if not (int8 and half)
|
130
|
+
and not (task != "detect" and nms)
|
131
|
+
and not (dynamic and nms)
|
132
|
+
and not (task == "classify" and dynamic)
|
130
133
|
],
|
131
134
|
)
|
132
135
|
def test_export_coreml_matrix(task, dynamic, int8, half, nms, batch):
|
ultralytics/__init__.py
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
2
2
|
|
3
|
-
__version__ = "8.3.
|
3
|
+
__version__ = "8.3.206"
|
4
4
|
|
5
5
|
import importlib
|
6
6
|
import os
|
7
|
+
from typing import TYPE_CHECKING
|
7
8
|
|
8
9
|
# Set ENV variables (place before imports)
|
9
10
|
if not os.environ.get("OMP_NUM_THREADS"):
|
@@ -26,6 +27,10 @@ __all__ = (
|
|
26
27
|
"settings",
|
27
28
|
)
|
28
29
|
|
30
|
+
if TYPE_CHECKING:
|
31
|
+
# Enable hints for type checkers
|
32
|
+
from ultralytics.models import YOLO, YOLOWorld, YOLOE, NAS, SAM, FastSAM, RTDETR # noqa
|
33
|
+
|
29
34
|
|
30
35
|
def __getattr__(name: str):
|
31
36
|
"""Lazy-import model classes on first access."""
|
ultralytics/engine/exporter.py
CHANGED
@@ -137,7 +137,7 @@ def export_formats():
|
|
137
137
|
True,
|
138
138
|
["batch", "dynamic", "half", "int8", "simplify", "nms", "fraction"],
|
139
139
|
],
|
140
|
-
["CoreML", "coreml", ".mlpackage", True, False, ["batch", "half", "int8", "nms"]],
|
140
|
+
["CoreML", "coreml", ".mlpackage", True, False, ["batch", "dynamic", "half", "int8", "nms"]],
|
141
141
|
["TensorFlow SavedModel", "saved_model", "_saved_model", True, True, ["batch", "int8", "keras", "nms"]],
|
142
142
|
["TensorFlow GraphDef", "pb", ".pb", True, True, ["batch"]],
|
143
143
|
["TensorFlow Lite", "tflite", ".tflite", True, False, ["batch", "half", "int8", "nms", "fraction"]],
|
@@ -389,9 +389,9 @@ class Exporter:
|
|
389
389
|
LOGGER.warning("'nms=True' is not available for end2end models. Forcing 'nms=False'.")
|
390
390
|
self.args.nms = False
|
391
391
|
self.args.conf = self.args.conf or 0.25 # set conf default value for nms export
|
392
|
-
if (engine or self.args.nms) and self.args.dynamic and self.args.batch == 1:
|
392
|
+
if (engine or coreml or self.args.nms) and self.args.dynamic and self.args.batch == 1:
|
393
393
|
LOGGER.warning(
|
394
|
-
f"'dynamic=True' model with '{'nms=True' if self.args.nms else 'format=
|
394
|
+
f"'dynamic=True' model with '{'nms=True' if self.args.nms else f'format={self.args.format}'}' requires max batch size, i.e. 'batch=16'"
|
395
395
|
)
|
396
396
|
if edgetpu:
|
397
397
|
if not LINUX or ARM64:
|
@@ -876,13 +876,19 @@ class Exporter:
|
|
876
876
|
LOGGER.info(f"\n{prefix} starting export with coremltools {ct.__version__}...")
|
877
877
|
assert not WINDOWS, "CoreML export is not supported on Windows, please run on macOS or Linux."
|
878
878
|
assert TORCH_1_11, "CoreML export requires torch>=1.11"
|
879
|
-
|
879
|
+
if self.args.batch > 1:
|
880
|
+
assert self.args.dynamic, (
|
881
|
+
"batch sizes > 1 are not supported without 'dynamic=True' for CoreML export. Please retry at 'dynamic=True'."
|
882
|
+
)
|
883
|
+
if self.args.dynamic:
|
884
|
+
assert not self.args.nms, (
|
885
|
+
"'nms=True' cannot be used together with 'dynamic=True' for CoreML export. Please disable one of them."
|
886
|
+
)
|
887
|
+
assert self.model.task != "classify", "'dynamic=True' is not supported for CoreML classification models."
|
880
888
|
f = self.file.with_suffix(".mlmodel" if mlmodel else ".mlpackage")
|
881
889
|
if f.is_dir():
|
882
890
|
shutil.rmtree(f)
|
883
891
|
|
884
|
-
bias = [0.0, 0.0, 0.0]
|
885
|
-
scale = 1 / 255
|
886
892
|
classifier_config = None
|
887
893
|
if self.model.task == "classify":
|
888
894
|
classifier_config = ct.ClassifierConfig(list(self.model.names.values()))
|
@@ -896,13 +902,26 @@ class Exporter:
|
|
896
902
|
model = self.model
|
897
903
|
ts = torch.jit.trace(model.eval(), self.im, strict=False) # TorchScript model
|
898
904
|
|
905
|
+
if self.args.dynamic:
|
906
|
+
input_shape = ct.Shape(
|
907
|
+
shape=(
|
908
|
+
ct.RangeDim(lower_bound=1, upper_bound=self.args.batch, default=1),
|
909
|
+
self.im.shape[1],
|
910
|
+
ct.RangeDim(lower_bound=32, upper_bound=self.imgsz[0] * 2, default=self.imgsz[0]),
|
911
|
+
ct.RangeDim(lower_bound=32, upper_bound=self.imgsz[1] * 2, default=self.imgsz[1]),
|
912
|
+
)
|
913
|
+
)
|
914
|
+
inputs = [ct.TensorType("image", shape=input_shape)]
|
915
|
+
else:
|
916
|
+
inputs = [ct.ImageType("image", shape=self.im.shape, scale=1 / 255, bias=[0.0, 0.0, 0.0])]
|
917
|
+
|
899
918
|
# Based on apple's documentation it is better to leave out the minimum_deployment target and let that get set
|
900
919
|
# Internally based on the model conversion and output type.
|
901
920
|
# Setting minimum_depoloyment_target >= iOS16 will require setting compute_precision=ct.precision.FLOAT32.
|
902
921
|
# iOS16 adds in better support for FP16, but none of the CoreML NMS specifications handle FP16 as input.
|
903
922
|
ct_model = ct.convert(
|
904
923
|
ts,
|
905
|
-
inputs=
|
924
|
+
inputs=inputs,
|
906
925
|
classifier_config=classifier_config,
|
907
926
|
convert_to="neuralnetwork" if mlmodel else "mlprogram",
|
908
927
|
)
|
ultralytics/engine/model.py
CHANGED
@@ -802,7 +802,7 @@ class Model(torch.nn.Module):
|
|
802
802
|
if RANK in {-1, 0}:
|
803
803
|
ckpt = self.trainer.best if self.trainer.best.exists() else self.trainer.last
|
804
804
|
self.model, self.ckpt = load_checkpoint(ckpt)
|
805
|
-
self.overrides = self.model.args
|
805
|
+
self.overrides = self._reset_ckpt_args(self.model.args)
|
806
806
|
self.metrics = getattr(self.trainer.validator, "metrics", None) # TODO: no metrics returned by DDP
|
807
807
|
return self.metrics
|
808
808
|
|
ultralytics/nn/autobackend.py
CHANGED
@@ -406,6 +406,7 @@ class AutoBackend(nn.Module):
|
|
406
406
|
import coremltools as ct
|
407
407
|
|
408
408
|
model = ct.models.MLModel(w)
|
409
|
+
dynamic = model.get_spec().description.input[0].type.HasField("multiArrayType")
|
409
410
|
metadata = dict(model.user_defined_metadata)
|
410
411
|
|
411
412
|
# TF SavedModel
|
@@ -720,10 +721,13 @@ class AutoBackend(nn.Module):
|
|
720
721
|
|
721
722
|
# CoreML
|
722
723
|
elif self.coreml:
|
723
|
-
im = im
|
724
|
-
|
724
|
+
im = im.cpu().numpy()
|
725
|
+
if self.dynamic:
|
726
|
+
im = im.transpose(0, 3, 1, 2)
|
727
|
+
else:
|
728
|
+
im = Image.fromarray((im[0] * 255).astype("uint8"))
|
725
729
|
# im = im.resize((192, 320), Image.BILINEAR)
|
726
|
-
y = self.model.predict({"image":
|
730
|
+
y = self.model.predict({"image": im}) # coordinates are xywh normalized
|
727
731
|
if "confidence" in y: # NMS included
|
728
732
|
from ultralytics.utils.ops import xywh2xyxy
|
729
733
|
|
ultralytics/utils/plotting.py
CHANGED
@@ -712,6 +712,12 @@ def plot_images(
|
|
712
712
|
Note:
|
713
713
|
This function supports both tensor and numpy array inputs. It will automatically
|
714
714
|
convert tensor inputs to numpy arrays for processing.
|
715
|
+
|
716
|
+
Channel Support:
|
717
|
+
- 1 channel: Greyscale
|
718
|
+
- 2 channels: Third channel added as zeros
|
719
|
+
- 3 channels: Used as-is (standard RGB)
|
720
|
+
- 4+ channels: Cropped to first 3 channels
|
715
721
|
"""
|
716
722
|
for k in {"cls", "bboxes", "conf", "masks", "keypoints", "batch_idx", "images"}:
|
717
723
|
if k not in labels:
|
@@ -731,7 +737,13 @@ def plot_images(
|
|
731
737
|
|
732
738
|
if len(images) and isinstance(images, torch.Tensor):
|
733
739
|
images = images.cpu().float().numpy()
|
734
|
-
|
740
|
+
|
741
|
+
# Handle 2-ch and n-ch images
|
742
|
+
c = images.shape[1]
|
743
|
+
if c == 2:
|
744
|
+
zero = np.zeros_like(images[:, :1])
|
745
|
+
images = np.concatenate((images, zero), axis=1) # pad 2-ch with a black channel
|
746
|
+
elif c > 3:
|
735
747
|
images = images[:, :3] # crop multispectral images to first 3 channels
|
736
748
|
|
737
749
|
bs, _, h, w = images.shape # batch size, _, height, width
|
@@ -966,6 +978,14 @@ def plot_tune_results(csv_file: str = "tune_results.csv", exclude_zero_fitness_p
|
|
966
978
|
if exclude_zero_fitness_points:
|
967
979
|
mask = fitness > 0 # exclude zero-fitness points
|
968
980
|
x, fitness = x[mask], fitness[mask]
|
981
|
+
# Iterative sigma rejection on lower bound only
|
982
|
+
for _ in range(3): # max 3 iterations
|
983
|
+
mean, std = fitness.mean(), fitness.std()
|
984
|
+
lower_bound = mean - 3 * std
|
985
|
+
mask = fitness >= lower_bound
|
986
|
+
if mask.all(): # no more outliers
|
987
|
+
break
|
988
|
+
x, fitness = x[mask], fitness[mask]
|
969
989
|
j = np.argmax(fitness) # max fitness index
|
970
990
|
n = math.ceil(len(keys) ** 0.5) # columns and rows in plot
|
971
991
|
plt.figure(figsize=(10, 10), tight_layout=True)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ultralytics
|
3
|
-
Version: 8.3.
|
3
|
+
Version: 8.3.206
|
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>
|
@@ -3,11 +3,11 @@ tests/conftest.py,sha256=LXtQJcFNWPGuzauTGkiXgsvVC3llJKfg22WcmhRzuQc,2593
|
|
3
3
|
tests/test_cli.py,sha256=0jqS6RfzmJeqgjozUqfT4AoP2d_IhUR0Ej-5ToQBK7A,5463
|
4
4
|
tests/test_cuda.py,sha256=L2CAdEIXCwrhWtOAhBLTmaQZ9dnLmSEy5jEsxXjK4-0,8127
|
5
5
|
tests/test_engine.py,sha256=8W4_D48ZBUp-DsUlRYxHTXzougycY8yggvpbVwQDLPg,5025
|
6
|
-
tests/test_exports.py,sha256=
|
6
|
+
tests/test_exports.py,sha256=L_Q0RRCIX80Czx-E4f4ktiAMobNXicVvrnxtv2wndBE,11093
|
7
7
|
tests/test_integrations.py,sha256=kl_AKmE_Qs1GB0_91iVwbzNxofm_hFTt0zzU6JF-pg4,6323
|
8
8
|
tests/test_python.py,sha256=2W1f15r9B1TQ8HEf2yXcJ3s3_Dn7S5SCBY8DIBM373k,28203
|
9
9
|
tests/test_solutions.py,sha256=oaTz5BttPDIeHkQh9oEaw-O73L4iYDP3Lfe82V7DeKM,13416
|
10
|
-
ultralytics/__init__.py,sha256=
|
10
|
+
ultralytics/__init__.py,sha256=LzBGwb9vf_PfLjZnlRpleH6RPVwZwWhajdqcVIsPte8,1302
|
11
11
|
ultralytics/py.typed,sha256=la67KBlbjXN-_-DfGNcdOcjYumVpKG_Tkw-8n5dnGB4,8
|
12
12
|
ultralytics/assets/bus.jpg,sha256=wCAZxJecGR63Od3ZRERe9Aja1Weayrb9Ug751DS_vGM,137419
|
13
13
|
ultralytics/assets/zidane.jpg,sha256=Ftc4aeMmen1O0A3o6GCDO9FlfBslLpTAw0gnetx7bts,50427
|
@@ -121,8 +121,8 @@ ultralytics/data/scripts/get_coco.sh,sha256=UuJpJeo3qQpTHVINeOpmP0NYmg8PhEFE3A8J
|
|
121
121
|
ultralytics/data/scripts/get_coco128.sh,sha256=qmRQl_hOKrsdHrTrnyQuFIH01oDz3lfaz138OgGfLt8,650
|
122
122
|
ultralytics/data/scripts/get_imagenet.sh,sha256=hr42H16bM47iT27rgS7MpEo-GeOZAYUQXgr0B2cwn48,1705
|
123
123
|
ultralytics/engine/__init__.py,sha256=lm6MckFYCPTbqIoX7w0s_daxdjNeBeKW6DXppv1-QUM,70
|
124
|
-
ultralytics/engine/exporter.py,sha256=
|
125
|
-
ultralytics/engine/model.py,sha256=
|
124
|
+
ultralytics/engine/exporter.py,sha256=54MtuyPJuE71pCdexjtl-rPJtHGNNHYZez7x0JDKpSQ,70867
|
125
|
+
ultralytics/engine/model.py,sha256=uX6cTFdlLllGRbz8Lr90IZGb4OrtMDIHQEg7DxUqwe8,53449
|
126
126
|
ultralytics/engine/predictor.py,sha256=4lfw2RbBDE7939011FcSCuznscrcnMuabZtc8GXaKO4,22735
|
127
127
|
ultralytics/engine/results.py,sha256=uQ_tgvdxKAg28pRgb5WCHiqx9Ktu7wYiVbwZy_IJ5bo,71499
|
128
128
|
ultralytics/engine/trainer.py,sha256=OQZWfG2PFm8O6N6fwFmTOgkGeRSR5gSGjfy9NWNnKnQ,41178
|
@@ -196,7 +196,7 @@ ultralytics/models/yolo/yoloe/train.py,sha256=qefvNNXDTOK1tO3va0kNHr8lE5QJkOlV8G
|
|
196
196
|
ultralytics/models/yolo/yoloe/train_seg.py,sha256=aCV7M8oQOvODFnU4piZdJh3tIrBJYAzZfRVRx1vRgxo,4956
|
197
197
|
ultralytics/models/yolo/yoloe/val.py,sha256=5Gd9EoFH0FmKKvWXBl4J7gBe9DVxIczN-s3ceHwdUDo,9458
|
198
198
|
ultralytics/nn/__init__.py,sha256=PJgOn2phQTTBR2P3s_JWvGeGXQpvw1znsumKow4tCuE,545
|
199
|
-
ultralytics/nn/autobackend.py,sha256=
|
199
|
+
ultralytics/nn/autobackend.py,sha256=2M_iz8PdDFEK1muPjserSOrsPRDg7zWb0qOEAJ0eG_A,41270
|
200
200
|
ultralytics/nn/tasks.py,sha256=1hz7w60SNYk7T5TRWBOPup-mbAqCJDgZ91rv9cheqdc,70379
|
201
201
|
ultralytics/nn/text_model.py,sha256=pHqnKe8UueR1MuwJcIE_IvrnYIlt68QL796xjcRJs2A,15275
|
202
202
|
ultralytics/nn/modules/__init__.py,sha256=BPMbEm1daI7Tuds3zph2_afAX7Gq1uAqK8BfiCfKTZs,3198
|
@@ -255,7 +255,7 @@ ultralytics/utils/metrics.py,sha256=DC-JuakuhHfeCeLvUHb7wj1HPhuFakx00rqXicTka5Y,
|
|
255
255
|
ultralytics/utils/nms.py,sha256=AVOmPuUTEJqmq2J6rvjq-nHNxYIyabgzHdc41siyA0w,14161
|
256
256
|
ultralytics/utils/ops.py,sha256=PW3fgw1d18CA2ZNQZVJqUy054cJ_9tIcxd1XnA0FPgU,26905
|
257
257
|
ultralytics/utils/patches.py,sha256=0-2G4jXCIPnMonlft-cPcjfFcOXQS6ODwUDNUwanfg4,6541
|
258
|
-
ultralytics/utils/plotting.py,sha256=
|
258
|
+
ultralytics/utils/plotting.py,sha256=TtEAUGpGh0cL_5RvUD3jyils5pY1yke1_d_bOvZ3Ivc,47948
|
259
259
|
ultralytics/utils/tal.py,sha256=7KQYNyetfx18CNc_bvNG7BDb44CIU3DEu4qziVVvNAE,20869
|
260
260
|
ultralytics/utils/torch_utils.py,sha256=FU3tzaAYZP_FIrusfOxVrfgBN2e7u7QvHY9yM-xB3Jc,40332
|
261
261
|
ultralytics/utils/tqdm.py,sha256=ny5RIg2OTkWQ7gdaXfYaoIgR0Xn2_hNGB6tUpO2Unns,16137
|
@@ -275,9 +275,9 @@ ultralytics/utils/callbacks/tensorboard.py,sha256=_4nfGK1dDLn6ijpvphBDhc-AS8qhS3
|
|
275
275
|
ultralytics/utils/callbacks/wb.py,sha256=ngQO8EJ1kxJDF1YajScVtzBbm26jGuejA0uWeOyvf5A,7685
|
276
276
|
ultralytics/utils/export/__init__.py,sha256=jQtf716PP0jt7bMoY9FkqmjG26KbvDzuR84jGhaBi2U,9901
|
277
277
|
ultralytics/utils/export/imx.py,sha256=Jl5nuNxqaP_bY5yrV2NypmoJSrexHE71TxR72SDdjcg,11394
|
278
|
-
ultralytics-8.3.
|
279
|
-
ultralytics-8.3.
|
280
|
-
ultralytics-8.3.
|
281
|
-
ultralytics-8.3.
|
282
|
-
ultralytics-8.3.
|
283
|
-
ultralytics-8.3.
|
278
|
+
ultralytics-8.3.206.dist-info/licenses/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
|
279
|
+
ultralytics-8.3.206.dist-info/METADATA,sha256=ZwaAICktsOQPV9MRi_rgsRzxsebAfuVaJ07pMD07cPQ,37667
|
280
|
+
ultralytics-8.3.206.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
281
|
+
ultralytics-8.3.206.dist-info/entry_points.txt,sha256=YM_wiKyTe9yRrsEfqvYolNO5ngwfoL4-NwgKzc8_7sI,93
|
282
|
+
ultralytics-8.3.206.dist-info/top_level.txt,sha256=XP49TwiMw4QGsvTLSYiJhz1xF_k7ev5mQ8jJXaXi45Q,12
|
283
|
+
ultralytics-8.3.206.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|