ultralytics 8.3.105__py3-none-any.whl → 8.3.106__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_solutions.py DELETED
@@ -1,167 +0,0 @@
1
- # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
-
3
- # Tests Ultralytics Solutions: https://docs.ultralytics.com/solutions/,
4
- # including every solution excluding DistanceCalculation and Security Alarm System.
5
-
6
- import cv2
7
- import pytest
8
-
9
- from tests import TMP
10
- from ultralytics import solutions
11
- from ultralytics.utils import ASSETS_URL
12
- from ultralytics.utils.downloads import safe_download
13
-
14
- # Pre-defined arguments values
15
- SHOW = False
16
- DEMO_VIDEO = "solutions_ci_demo.mp4" # for all the solutions, except workout, object cropping and parking management
17
- CROP_VIDEO = "decelera_landscape_min.mov" # for object cropping solution
18
- POSE_VIDEO = "solution_ci_pose_demo.mp4" # only for workouts monitoring solution
19
- PARKING_VIDEO = "solution_ci_parking_demo.mp4" # only for parking management solution
20
- PARKING_AREAS_JSON = "solution_ci_parking_areas.json" # only for parking management solution
21
- PARKING_MODEL = "solutions_ci_parking_model.pt" # only for parking management solution
22
- MODEL_FILE = "yolo11n.pt" # model file used for solutions, except parking management and instance segmentation
23
- REGION = [(10, 200), (540, 200), (540, 180), (10, 180)] # for object counting, speed estimation and queue management
24
-
25
- # Test configs for each solution : (name, class, needs_frame_count, video, kwargs)
26
- SOLUTIONS = [
27
- (
28
- "ObjectCounter",
29
- solutions.ObjectCounter,
30
- False,
31
- DEMO_VIDEO,
32
- {"region": REGION, "model": MODEL_FILE, "show": SHOW},
33
- ),
34
- (
35
- "Heatmap",
36
- solutions.Heatmap,
37
- False,
38
- DEMO_VIDEO,
39
- {"colormap": cv2.COLORMAP_PARULA, "model": MODEL_FILE, "show": SHOW, "region": None},
40
- ),
41
- (
42
- "HeatmapWithRegion",
43
- solutions.Heatmap,
44
- False,
45
- DEMO_VIDEO,
46
- {"colormap": cv2.COLORMAP_PARULA, "region": REGION, "model": MODEL_FILE, "show": SHOW},
47
- ),
48
- (
49
- "SpeedEstimator",
50
- solutions.SpeedEstimator,
51
- False,
52
- DEMO_VIDEO,
53
- {"region": REGION, "model": MODEL_FILE, "show": SHOW},
54
- ),
55
- (
56
- "QueueManager",
57
- solutions.QueueManager,
58
- False,
59
- DEMO_VIDEO,
60
- {"region": REGION, "model": MODEL_FILE, "show": SHOW},
61
- ),
62
- (
63
- "LineAnalytics",
64
- solutions.Analytics,
65
- True,
66
- DEMO_VIDEO,
67
- {"analytics_type": "line", "model": MODEL_FILE, "show": SHOW},
68
- ),
69
- (
70
- "PieAnalytics",
71
- solutions.Analytics,
72
- True,
73
- DEMO_VIDEO,
74
- {"analytics_type": "pie", "model": MODEL_FILE, "show": SHOW},
75
- ),
76
- (
77
- "BarAnalytics",
78
- solutions.Analytics,
79
- True,
80
- DEMO_VIDEO,
81
- {"analytics_type": "bar", "model": MODEL_FILE, "show": SHOW},
82
- ),
83
- (
84
- "AreaAnalytics",
85
- solutions.Analytics,
86
- True,
87
- DEMO_VIDEO,
88
- {"analytics_type": "area", "model": MODEL_FILE, "show": SHOW},
89
- ),
90
- ("TrackZone", solutions.TrackZone, False, DEMO_VIDEO, {"region": REGION, "model": MODEL_FILE, "show": SHOW}),
91
- (
92
- "ObjectCropper",
93
- solutions.ObjectCropper,
94
- False,
95
- CROP_VIDEO,
96
- {"crop_dir": str(TMP / "cropped-detections"), "model": MODEL_FILE, "show": SHOW},
97
- ),
98
- (
99
- "ObjectBlurrer",
100
- solutions.ObjectBlurrer,
101
- False,
102
- DEMO_VIDEO,
103
- {"blur_ratio": 0.5, "model": MODEL_FILE, "show": SHOW},
104
- ),
105
- (
106
- "InstanceSegmentation",
107
- solutions.InstanceSegmentation,
108
- False,
109
- DEMO_VIDEO,
110
- {"model": "yolo11n-seg.pt", "show": SHOW},
111
- ),
112
- ("VisionEye", solutions.VisionEye, False, DEMO_VIDEO, {"model": MODEL_FILE, "show": SHOW}),
113
- (
114
- "RegionCounter",
115
- solutions.RegionCounter,
116
- False,
117
- DEMO_VIDEO,
118
- {"region": REGION, "model": MODEL_FILE, "show": SHOW},
119
- ),
120
- ("AIGym", solutions.AIGym, False, POSE_VIDEO, {"kpts": [6, 8, 10], "show": SHOW}),
121
- (
122
- "ParkingManager",
123
- solutions.ParkingManagement,
124
- False,
125
- PARKING_VIDEO,
126
- {"model": str(TMP / PARKING_MODEL), "show": SHOW, "json_file": str(TMP / PARKING_AREAS_JSON)},
127
- ),
128
- (
129
- "StreamlitInference",
130
- solutions.Inference,
131
- False,
132
- None, # streamlit application don't require video file
133
- {}, # streamlit application don't accept arguments
134
- ),
135
- ]
136
-
137
-
138
- def process_video(solution, video_path, needs_frame_count=False):
139
- """Process video with solution, feeding frames and optional frame count."""
140
- cap = cv2.VideoCapture(video_path)
141
- assert cap.isOpened(), f"Error reading video file {video_path}"
142
-
143
- frame_count = 0
144
- while cap.isOpened():
145
- success, im0 = cap.read()
146
- if not success:
147
- break
148
- frame_count += 1
149
- im_copy = im0.copy()
150
- args = [im_copy, frame_count] if needs_frame_count else [im_copy]
151
- _ = solution(*args)
152
-
153
- cap.release()
154
-
155
-
156
- @pytest.mark.slow
157
- @pytest.mark.parametrize("name, solution_class, needs_frame_count, video, kwargs", SOLUTIONS)
158
- def test_solution(name, solution_class, needs_frame_count, video, kwargs):
159
- """Test individual Ultralytics solution."""
160
- safe_download(url=f"{ASSETS_URL}/{video}", dir=TMP)
161
- if name == "ParkingManager":
162
- safe_download(url=f"{ASSETS_URL}/{PARKING_AREAS_JSON}", dir=TMP)
163
- safe_download(url=f"{ASSETS_URL}/{PARKING_MODEL}", dir=TMP)
164
- solution = solution_class(**kwargs)
165
- solution.inference() if name == "StreamlitInference" else process_video(
166
- solution, str(TMP / video), needs_frame_count
167
- )