ultralytics 8.3.68__py3-none-any.whl → 8.3.69__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.
- ultralytics/__init__.py +1 -1
- ultralytics/engine/results.py +69 -0
- ultralytics/models/utils/ops.py +1 -1
- ultralytics/utils/benchmarks.py +8 -3
- ultralytics/utils/torch_utils.py +1 -1
- {ultralytics-8.3.68.dist-info → ultralytics-8.3.69.dist-info}/METADATA +1 -1
- {ultralytics-8.3.68.dist-info → ultralytics-8.3.69.dist-info}/RECORD +11 -11
- {ultralytics-8.3.68.dist-info → ultralytics-8.3.69.dist-info}/LICENSE +0 -0
- {ultralytics-8.3.68.dist-info → ultralytics-8.3.69.dist-info}/WHEEL +0 -0
- {ultralytics-8.3.68.dist-info → ultralytics-8.3.69.dist-info}/entry_points.txt +0 -0
- {ultralytics-8.3.68.dist-info → ultralytics-8.3.69.dist-info}/top_level.txt +0 -0
ultralytics/__init__.py
CHANGED
ultralytics/engine/results.py
CHANGED
@@ -937,6 +937,75 @@ class Results(SimpleClass):
|
|
937
937
|
|
938
938
|
return json.dumps(self.summary(normalize=normalize, decimals=decimals), indent=2)
|
939
939
|
|
940
|
+
def to_sql(self, table_name="results", normalize=False, decimals=5, db_path="results.db"):
|
941
|
+
"""
|
942
|
+
Converts detection results to an SQL-compatible format.
|
943
|
+
|
944
|
+
This method serializes the detection results into a format compatible with SQL databases.
|
945
|
+
It includes information about detected objects such as bounding boxes, class names, confidence scores,
|
946
|
+
and optionally segmentation masks, keypoints or oriented bounding boxes.
|
947
|
+
|
948
|
+
Args:
|
949
|
+
table_name (str): Name of the SQL table where the data will be inserted. Defaults to "detection_results".
|
950
|
+
normalize (bool): Whether to normalize the bounding box coordinates by the image dimensions.
|
951
|
+
If True, coordinates will be returned as float values between 0 and 1. Defaults to False.
|
952
|
+
decimals (int): Number of decimal places to round the bounding boxes values to. Defaults to 5.
|
953
|
+
db_path (str): Path to the SQLite database file. Defaults to "results.db".
|
954
|
+
|
955
|
+
Examples:
|
956
|
+
>>> results = model("path/to/image.jpg")
|
957
|
+
>>> results[0].to_sql()
|
958
|
+
>>> print("SQL data written successfully.")
|
959
|
+
"""
|
960
|
+
import json
|
961
|
+
import sqlite3
|
962
|
+
|
963
|
+
# Convert results to a list of dictionaries
|
964
|
+
data = self.summary(normalize=normalize, decimals=decimals)
|
965
|
+
if not data:
|
966
|
+
LOGGER.warning("⚠️ No results to save to SQL. Results dict is empty")
|
967
|
+
return
|
968
|
+
|
969
|
+
# Connect to the SQLite database
|
970
|
+
conn = sqlite3.connect(db_path)
|
971
|
+
cursor = conn.cursor()
|
972
|
+
|
973
|
+
# Create table if it doesn't exist
|
974
|
+
columns = (
|
975
|
+
"id INTEGER PRIMARY KEY AUTOINCREMENT, class_name TEXT, confidence REAL, "
|
976
|
+
"box TEXT, masks TEXT, kpts TEXT, obb TEXT"
|
977
|
+
)
|
978
|
+
cursor.execute(f"CREATE TABLE IF NOT EXISTS {table_name} ({columns})")
|
979
|
+
|
980
|
+
# Insert data into the table
|
981
|
+
for i, item in enumerate(data):
|
982
|
+
detect, obb = None, None # necessary to reinit these variables inside for loop to avoid duplication
|
983
|
+
class_name = item.get("name")
|
984
|
+
box = item.get("box", {})
|
985
|
+
# Serialize the box as JSON for 'detect' and 'obb' based on key presence
|
986
|
+
if all(key in box for key in ["x1", "y1", "x2", "y2"]) and not any(key in box for key in ["x3", "x4"]):
|
987
|
+
detect = json.dumps(box)
|
988
|
+
if all(key in box for key in ["x1", "y1", "x2", "y2", "x3", "x4"]):
|
989
|
+
obb = json.dumps(box)
|
990
|
+
|
991
|
+
cursor.execute(
|
992
|
+
f"INSERT INTO {table_name} (class_name, confidence, box, masks, kpts, obb) VALUES (?, ?, ?, ?, ?, ?)",
|
993
|
+
(
|
994
|
+
class_name,
|
995
|
+
item.get("confidence"),
|
996
|
+
detect,
|
997
|
+
json.dumps(item.get("segments", {}).get("x", [])),
|
998
|
+
json.dumps(item.get("keypoints", {}).get("x", [])),
|
999
|
+
obb,
|
1000
|
+
),
|
1001
|
+
)
|
1002
|
+
|
1003
|
+
# Commit and close the connection
|
1004
|
+
conn.commit()
|
1005
|
+
conn.close()
|
1006
|
+
|
1007
|
+
LOGGER.info(f"✅ Detection results successfully written to SQL table '{table_name}' in database '{db_path}'.")
|
1008
|
+
|
940
1009
|
|
941
1010
|
class Boxes(BaseTensor):
|
942
1011
|
"""
|
ultralytics/models/utils/ops.py
CHANGED
@@ -172,7 +172,7 @@ def get_cdn_group(
|
|
172
172
|
bounding boxes, attention mask and meta information for denoising. If not in training mode or 'num_dn'
|
173
173
|
is less than or equal to 0, the function returns None for all elements in the tuple.
|
174
174
|
"""
|
175
|
-
if (not training) or num_dn <= 0:
|
175
|
+
if (not training) or num_dn <= 0 or batch is None:
|
176
176
|
return None, None, None, None
|
177
177
|
gt_groups = batch["gt_groups"]
|
178
178
|
total_num = sum(gt_groups)
|
ultralytics/utils/benchmarks.py
CHANGED
@@ -42,7 +42,7 @@ from ultralytics import YOLO, YOLOWorld
|
|
42
42
|
from ultralytics.cfg import TASK2DATA, TASK2METRIC
|
43
43
|
from ultralytics.engine.exporter import export_formats
|
44
44
|
from ultralytics.utils import ARM64, ASSETS, LINUX, LOGGER, MACOS, TQDM, WEIGHTS_DIR
|
45
|
-
from ultralytics.utils.checks import IS_PYTHON_3_12, check_requirements, check_yolo, is_rockchip
|
45
|
+
from ultralytics.utils.checks import IS_PYTHON_3_12, check_imgsz, check_requirements, check_yolo, is_rockchip
|
46
46
|
from ultralytics.utils.downloads import safe_download
|
47
47
|
from ultralytics.utils.files import file_size
|
48
48
|
from ultralytics.utils.torch_utils import get_cpu_info, select_device
|
@@ -80,6 +80,9 @@ def benchmark(
|
|
80
80
|
>>> from ultralytics.utils.benchmarks import benchmark
|
81
81
|
>>> benchmark(model="yolo11n.pt", imgsz=640)
|
82
82
|
"""
|
83
|
+
imgsz = check_imgsz(imgsz)
|
84
|
+
assert imgsz[0] == imgsz[1] if isinstance(imgsz, list) else True, "benchmark() only supports square imgsz."
|
85
|
+
|
83
86
|
import pandas as pd # scope for faster 'import ultralytics'
|
84
87
|
|
85
88
|
pd.options.display.max_columns = 10
|
@@ -148,7 +151,7 @@ def benchmark(
|
|
148
151
|
assert i != 5 or platform.system() == "Darwin", "inference only supported on macOS>=10.13" # CoreML
|
149
152
|
if i in {13}:
|
150
153
|
assert not is_end2end, "End-to-end torch.topk operation is not supported for NCNN prediction yet"
|
151
|
-
exported_model.predict(ASSETS / "bus.jpg", imgsz=imgsz, device=device, half=half)
|
154
|
+
exported_model.predict(ASSETS / "bus.jpg", imgsz=imgsz, device=device, half=half, verbose=False)
|
152
155
|
|
153
156
|
# Validate
|
154
157
|
data = data or TASK2DATA[model.task] # task to dataset, i.e. coco8.yaml for task=detect
|
@@ -170,7 +173,9 @@ def benchmark(
|
|
170
173
|
df = pd.DataFrame(y, columns=["Format", "Status❔", "Size (MB)", key, "Inference time (ms/im)", "FPS"])
|
171
174
|
|
172
175
|
name = model.model_name
|
173
|
-
|
176
|
+
dt = time.time() - t0
|
177
|
+
legend = "Benchmarks legend: - ✅ Success - ❎ Export passed but validation failed - ❌️ Export failed"
|
178
|
+
s = f"\nBenchmarks complete for {name} on {data} at imgsz={imgsz} ({dt:.2f}s)\n{legend}\n{df.fillna('-')}\n"
|
174
179
|
LOGGER.info(s)
|
175
180
|
with open("benchmarks.log", "a", errors="ignore", encoding="utf-8") as f:
|
176
181
|
f.write(s)
|
ultralytics/utils/torch_utils.py
CHANGED
@@ -667,7 +667,7 @@ def profile(input, ops, n=10, device=None, max_num_obj=0):
|
|
667
667
|
m = m.half() if hasattr(m, "half") and isinstance(x, torch.Tensor) and x.dtype is torch.float16 else m
|
668
668
|
tf, tb, t = 0, 0, [0, 0, 0] # dt forward, backward
|
669
669
|
try:
|
670
|
-
flops = thop.profile(m, inputs=[x], verbose=False)[0] / 1e9 * 2 # GFLOPs
|
670
|
+
flops = thop.profile(deepcopy(m), inputs=[x], verbose=False)[0] / 1e9 * 2 # GFLOPs
|
671
671
|
except Exception:
|
672
672
|
flops = 0
|
673
673
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: ultralytics
|
3
|
-
Version: 8.3.
|
3
|
+
Version: 8.3.69
|
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>
|
@@ -7,7 +7,7 @@ tests/test_exports.py,sha256=T_z_NUS9URQXv83k5XNLHTuksJ8srtzbZnWuiiQWM98,9260
|
|
7
7
|
tests/test_integrations.py,sha256=p3DMnnPMKsV0Qm82JVJUIY1UZ67xRgF9E8AaL76TEHE,6154
|
8
8
|
tests/test_python.py,sha256=tW-EFJC2rjl_DvAa8khXGWYdypseQjrLjGHhe2p9r9A,23238
|
9
9
|
tests/test_solutions.py,sha256=aY0G3vNzXGCENG9FD76MfUp7jgzeESPsUvbvQYBUvH0,4205
|
10
|
-
ultralytics/__init__.py,sha256=
|
10
|
+
ultralytics/__init__.py,sha256=AmBs8gI8Wd8RZmYCZilP06XA8mpUvbFqUDMWP5PpKbo,709
|
11
11
|
ultralytics/assets/bus.jpg,sha256=wCAZxJecGR63Od3ZRERe9Aja1Weayrb9Ug751DS_vGM,137419
|
12
12
|
ultralytics/assets/zidane.jpg,sha256=Ftc4aeMmen1O0A3o6GCDO9FlfBslLpTAw0gnetx7bts,50427
|
13
13
|
ultralytics/cfg/__init__.py,sha256=qP44HnFP4QcC5FQz29A-EGTuwdtxXAzPvw_IvCVmiqA,39771
|
@@ -105,7 +105,7 @@ ultralytics/engine/__init__.py,sha256=lm6MckFYCPTbqIoX7w0s_daxdjNeBeKW6DXppv1-QU
|
|
105
105
|
ultralytics/engine/exporter.py,sha256=aXUX8GZUw1CBaXYSI7OFwx1tsnl6VkgQQXb_iKi-cs8,76632
|
106
106
|
ultralytics/engine/model.py,sha256=IHeaCwXlbxs6f2gVF5hEQVUiY-3F9Oz1wJNSTPZ-tZ0,53110
|
107
107
|
ultralytics/engine/predictor.py,sha256=jiYDAjupOlRUpPvw9tu7or9PjXtLm-YCRiawANtWxj0,17881
|
108
|
-
ultralytics/engine/results.py,sha256=
|
108
|
+
ultralytics/engine/results.py,sha256=3jag9GQcJ2a_No76tEOWvT8gqm4X-SWAxoVc0NYenbI,78512
|
109
109
|
ultralytics/engine/trainer.py,sha256=ZGAc6C1_LUBHDdZlr6wT6sbMtDzWa5rr7M8QVlXpBLs,37362
|
110
110
|
ultralytics/engine/tuner.py,sha256=EUlTs7KJQ2RVABm8pihr_14M_Z2kGSzJaWH-Y9TJYDw,11976
|
111
111
|
ultralytics/engine/validator.py,sha256=r27X8HGeDEwq7V5sFjEQH_3EnP1CyG-HcOLpFABUisU,15034
|
@@ -145,7 +145,7 @@ ultralytics/models/sam/modules/transformer.py,sha256=T_8AXVrxl9HDlBAUHNOysKZqKLD
|
|
145
145
|
ultralytics/models/sam/modules/utils.py,sha256=udx4cIfISm5nS8_YPUQwtWPSwACKbJdAnR8Rtyei6Ds,12343
|
146
146
|
ultralytics/models/utils/__init__.py,sha256=lm6MckFYCPTbqIoX7w0s_daxdjNeBeKW6DXppv1-QUM,70
|
147
147
|
ultralytics/models/utils/loss.py,sha256=-DtL5zJYyMb40OKSghdAj8Paei5i27v6Lzug2DgX-Cg,15833
|
148
|
-
ultralytics/models/utils/ops.py,sha256=
|
148
|
+
ultralytics/models/utils/ops.py,sha256=4SShalce_6ZgGjJc9VokDIGzU0QdWlEFLFbt4GBZayA,13266
|
149
149
|
ultralytics/models/yolo/__init__.py,sha256=ol-bnRJEHdhdrNRAgyP_5SlhnJtZquCKQXEf_0kFs-o,275
|
150
150
|
ultralytics/models/yolo/model.py,sha256=EZ-e4auePxXs0747Bo45hnM8Rz0cRalslBrkA9FKxas,4261
|
151
151
|
ultralytics/models/yolo/classify/__init__.py,sha256=9--HVaNOfI1K7rn_rRqclL8FUAnpfeBrRqEQIaQw2xM,383
|
@@ -206,7 +206,7 @@ ultralytics/trackers/utils/kalman_filter.py,sha256=OBvemZXptgn9v1sgBLvFomCqOWwjI
|
|
206
206
|
ultralytics/trackers/utils/matching.py,sha256=64PKHGoETwXhuZ9udE217hbjJHygLOPaYA66J2qMSno,7130
|
207
207
|
ultralytics/utils/__init__.py,sha256=Ahn7Vn60HIquaBZwLWfWH4bKnm0JcpJXYxnOnY-RH-s,50010
|
208
208
|
ultralytics/utils/autobatch.py,sha256=zc81HlAMArPASEbExty0E_zpITF8PVwin7w-xBFFZ5w,5048
|
209
|
-
ultralytics/utils/benchmarks.py,sha256=
|
209
|
+
ultralytics/utils/benchmarks.py,sha256=MDvH3sPR6KJnjApdNsMz9t1y7KHZndyvVRoKcMXXIa4,26315
|
210
210
|
ultralytics/utils/checks.py,sha256=P543iMxEbXi0WWGrY67GaA7jIsas63K4uCSZpqmVx8M,31017
|
211
211
|
ultralytics/utils/dist.py,sha256=fuiJQEnyyL-SighlI3hUlZPaaSreUl4Q39snF6OhQtI,2386
|
212
212
|
ultralytics/utils/downloads.py,sha256=aUESyJOE2d7mJwbGECHWLR3RF8HVQPSwNH0cfmLGgdI,21999
|
@@ -219,7 +219,7 @@ ultralytics/utils/ops.py,sha256=HJ33Z9U1_Fl2MJyiv1JKLb2hTmvQqbeNemqR0lbCZgQ,3457
|
|
219
219
|
ultralytics/utils/patches.py,sha256=ARR89dP4YKq7Dd3g2eU-ukbnc2lo3BELukL_1c_d854,3298
|
220
220
|
ultralytics/utils/plotting.py,sha256=cl8mctrkBMMTE976yrqDn1I8dH6IPO3ROZl99t5fo9w,62987
|
221
221
|
ultralytics/utils/tal.py,sha256=DO-c006HEI62pcrNRpmt4lpqJPC5yu3veRDOvUuExno,18498
|
222
|
-
ultralytics/utils/torch_utils.py,sha256=
|
222
|
+
ultralytics/utils/torch_utils.py,sha256=LjgZg5O9G2Qw1ZwX6axOt8QFwu3wqm0mWZHerMCy9jg,33165
|
223
223
|
ultralytics/utils/triton.py,sha256=2L1_rZ8xCJEjexRVj75g9YU-u4tQln_DJ5N1Yr_0bSs,4071
|
224
224
|
ultralytics/utils/tuner.py,sha256=gySDBzTlq_klTOq6CGEyUN58HXzPCulObaMBHacXzHo,6294
|
225
225
|
ultralytics/utils/callbacks/__init__.py,sha256=hzL63Rce6VkZhP4Lcim9LKjadixaQG86nKqPhk7IkS0,242
|
@@ -233,9 +233,9 @@ ultralytics/utils/callbacks/neptune.py,sha256=waZ_bRu0-qBKujTLuqonC2gx2DkgBuVnfq
|
|
233
233
|
ultralytics/utils/callbacks/raytune.py,sha256=TbuZlDb721aIkh-nMozZcP2g_ttUh2cG5LUaXmept6g,728
|
234
234
|
ultralytics/utils/callbacks/tensorboard.py,sha256=JHOEVlNQ5dYJPd4Z-EvqbXowuK5uA0p8wPgyyaIUQs0,4194
|
235
235
|
ultralytics/utils/callbacks/wb.py,sha256=ayhT2y62AcSOacnawshATU0rWrlSFQ77mrGgBdRl3W4,7086
|
236
|
-
ultralytics-8.3.
|
237
|
-
ultralytics-8.3.
|
238
|
-
ultralytics-8.3.
|
239
|
-
ultralytics-8.3.
|
240
|
-
ultralytics-8.3.
|
241
|
-
ultralytics-8.3.
|
236
|
+
ultralytics-8.3.69.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
|
237
|
+
ultralytics-8.3.69.dist-info/METADATA,sha256=2c2ngPmnx2wTvDCASBt4b8x7XGnVX-C5XCjFPJjDFEo,35202
|
238
|
+
ultralytics-8.3.69.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
239
|
+
ultralytics-8.3.69.dist-info/entry_points.txt,sha256=YM_wiKyTe9yRrsEfqvYolNO5ngwfoL4-NwgKzc8_7sI,93
|
240
|
+
ultralytics-8.3.69.dist-info/top_level.txt,sha256=XP49TwiMw4QGsvTLSYiJhz1xF_k7ev5mQ8jJXaXi45Q,12
|
241
|
+
ultralytics-8.3.69.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|