supervisely 6.73.418__py3-none-any.whl → 6.73.419__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.
- supervisely/api/entity_annotation/figure_api.py +89 -45
- supervisely/nn/inference/inference.py +61 -45
- supervisely/nn/inference/instance_segmentation/instance_segmentation.py +1 -0
- supervisely/nn/inference/object_detection/object_detection.py +1 -0
- supervisely/nn/inference/session.py +4 -4
- supervisely/nn/model/model_api.py +31 -20
- supervisely/nn/model/prediction.py +11 -0
- supervisely/nn/model/prediction_session.py +33 -6
- supervisely/nn/tracker/__init__.py +1 -2
- supervisely/nn/tracker/base_tracker.py +44 -0
- supervisely/nn/tracker/botsort/__init__.py +1 -0
- supervisely/nn/tracker/botsort/botsort_config.yaml +31 -0
- supervisely/nn/tracker/botsort/osnet_reid/osnet.py +566 -0
- supervisely/nn/tracker/botsort/osnet_reid/osnet_reid_interface.py +88 -0
- supervisely/nn/tracker/botsort/tracker/__init__.py +0 -0
- supervisely/nn/tracker/{bot_sort → botsort/tracker}/basetrack.py +1 -2
- supervisely/nn/tracker/{utils → botsort/tracker}/gmc.py +51 -59
- supervisely/nn/tracker/{deep_sort/deep_sort → botsort/tracker}/kalman_filter.py +71 -33
- supervisely/nn/tracker/botsort/tracker/matching.py +202 -0
- supervisely/nn/tracker/{bot_sort/bot_sort.py → botsort/tracker/mc_bot_sort.py} +68 -81
- supervisely/nn/tracker/botsort_tracker.py +259 -0
- supervisely/project/project.py +1 -1
- {supervisely-6.73.418.dist-info → supervisely-6.73.419.dist-info}/METADATA +3 -1
- {supervisely-6.73.418.dist-info → supervisely-6.73.419.dist-info}/RECORD +29 -42
- supervisely/nn/tracker/bot_sort/__init__.py +0 -21
- supervisely/nn/tracker/bot_sort/fast_reid_interface.py +0 -152
- supervisely/nn/tracker/bot_sort/matching.py +0 -127
- supervisely/nn/tracker/bot_sort/sly_tracker.py +0 -401
- supervisely/nn/tracker/deep_sort/__init__.py +0 -6
- supervisely/nn/tracker/deep_sort/deep_sort/__init__.py +0 -1
- supervisely/nn/tracker/deep_sort/deep_sort/detection.py +0 -49
- supervisely/nn/tracker/deep_sort/deep_sort/iou_matching.py +0 -81
- supervisely/nn/tracker/deep_sort/deep_sort/linear_assignment.py +0 -202
- supervisely/nn/tracker/deep_sort/deep_sort/nn_matching.py +0 -176
- supervisely/nn/tracker/deep_sort/deep_sort/track.py +0 -166
- supervisely/nn/tracker/deep_sort/deep_sort/tracker.py +0 -145
- supervisely/nn/tracker/deep_sort/deep_sort.py +0 -301
- supervisely/nn/tracker/deep_sort/generate_clip_detections.py +0 -90
- supervisely/nn/tracker/deep_sort/preprocessing.py +0 -70
- supervisely/nn/tracker/deep_sort/sly_tracker.py +0 -273
- supervisely/nn/tracker/tracker.py +0 -285
- supervisely/nn/tracker/utils/kalman_filter.py +0 -492
- supervisely/nn/tracking/__init__.py +0 -1
- supervisely/nn/tracking/boxmot.py +0 -114
- supervisely/nn/tracking/tracking.py +0 -24
- /supervisely/nn/tracker/{utils → botsort/osnet_reid}/__init__.py +0 -0
- {supervisely-6.73.418.dist-info → supervisely-6.73.419.dist-info}/LICENSE +0 -0
- {supervisely-6.73.418.dist-info → supervisely-6.73.419.dist-info}/WHEEL +0 -0
- {supervisely-6.73.418.dist-info → supervisely-6.73.419.dist-info}/entry_points.txt +0 -0
- {supervisely-6.73.418.dist-info → supervisely-6.73.419.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import supervisely as sly
|
|
2
|
+
from supervisely.nn.tracker.base_tracker import BaseTracker
|
|
3
|
+
from supervisely.nn.tracker.botsort.tracker.mc_bot_sort import BoTSORT
|
|
4
|
+
from supervisely import Annotation, VideoAnnotation
|
|
5
|
+
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
from types import SimpleNamespace
|
|
8
|
+
from typing import List, Dict, Tuple, Any, Optional
|
|
9
|
+
import numpy as np
|
|
10
|
+
import yaml
|
|
11
|
+
import os
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
from supervisely import logger
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@dataclass
|
|
17
|
+
class TrackedObject:
|
|
18
|
+
"""
|
|
19
|
+
Data class representing a tracked object in a single frame.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
track_id: Unique identifier for the track
|
|
23
|
+
det_id: Detection ID for mapping back to original annotation
|
|
24
|
+
bbox: Bounding box coordinates in format [x1, y1, x2, y2]
|
|
25
|
+
class_name: String class name
|
|
26
|
+
class_sly_id: Supervisely class ID (from ObjClass.sly_id)
|
|
27
|
+
score: Confidence score of the detection/track
|
|
28
|
+
"""
|
|
29
|
+
track_id: int
|
|
30
|
+
det_id: int
|
|
31
|
+
bbox: List[float] # [x1, y1, x2, y2]
|
|
32
|
+
class_name: str
|
|
33
|
+
class_sly_id: Optional[int] # Supervisely class ID
|
|
34
|
+
score: float
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class BotSortTracker(BaseTracker):
|
|
38
|
+
|
|
39
|
+
def __init__(self, settings: dict = None, device: str = None):
|
|
40
|
+
super().__init__(settings=settings, device=device)
|
|
41
|
+
|
|
42
|
+
# Load default settings from YAML file
|
|
43
|
+
self.settings = self._load_default_settings()
|
|
44
|
+
|
|
45
|
+
# Override with user settings if provided
|
|
46
|
+
if settings:
|
|
47
|
+
self.settings.update(settings)
|
|
48
|
+
|
|
49
|
+
args = SimpleNamespace(**self.settings)
|
|
50
|
+
args.device = self.device
|
|
51
|
+
|
|
52
|
+
self.tracker = BoTSORT(args=args)
|
|
53
|
+
|
|
54
|
+
# State for accumulating results
|
|
55
|
+
self.frame_tracks = []
|
|
56
|
+
self.obj_classes = {} # class_id -> ObjClass
|
|
57
|
+
self.current_frame = 0
|
|
58
|
+
self.class_ids = {} # class_name -> class_id mapping
|
|
59
|
+
self.frame_shape = ()
|
|
60
|
+
|
|
61
|
+
def _load_default_settings(self) -> dict:
|
|
62
|
+
"""Load default settings from YAML file in the same directory."""
|
|
63
|
+
current_dir = Path(__file__).parent
|
|
64
|
+
config_path = current_dir / "botsort/botsort_config.yaml"
|
|
65
|
+
|
|
66
|
+
with open(config_path, 'r', encoding='utf-8') as file:
|
|
67
|
+
return yaml.safe_load(file)
|
|
68
|
+
|
|
69
|
+
def update(self, frame: np.ndarray, annotation: Annotation) -> List[Dict[str, Any]]:
|
|
70
|
+
"""Update tracker and return list of matches for current frame."""
|
|
71
|
+
self.frame_shape = frame.shape[:2]
|
|
72
|
+
self._update_obj_classes(annotation)
|
|
73
|
+
detections = self._convert_annotation(annotation)
|
|
74
|
+
output_stracks, detection_track_map = self.tracker.update(detections, frame)
|
|
75
|
+
tracks = self._stracks_to_tracks(output_stracks, detection_track_map)
|
|
76
|
+
|
|
77
|
+
# Store tracks for VideoAnnotation creation
|
|
78
|
+
self.frame_tracks.append(tracks)
|
|
79
|
+
self.current_frame += 1
|
|
80
|
+
|
|
81
|
+
matches = []
|
|
82
|
+
for pair in detection_track_map:
|
|
83
|
+
det_id = pair["det_id"]
|
|
84
|
+
track_id = pair["track_id"]
|
|
85
|
+
|
|
86
|
+
if track_id is not None:
|
|
87
|
+
match = {
|
|
88
|
+
"track_id": track_id,
|
|
89
|
+
"label": annotation.labels[det_id]
|
|
90
|
+
}
|
|
91
|
+
matches.append(match)
|
|
92
|
+
|
|
93
|
+
return matches
|
|
94
|
+
|
|
95
|
+
def reset(self) -> None:
|
|
96
|
+
super().reset()
|
|
97
|
+
self.frame_tracks = []
|
|
98
|
+
self.obj_classes = {}
|
|
99
|
+
self.current_frame = 0
|
|
100
|
+
self.class_ids = {}
|
|
101
|
+
self.frame_shape = ()
|
|
102
|
+
|
|
103
|
+
def track(self, frames: List[np.ndarray], annotations: List[Annotation]) -> VideoAnnotation:
|
|
104
|
+
"""Track objects through sequence of frames and return VideoAnnotation."""
|
|
105
|
+
if len(frames) != len(annotations):
|
|
106
|
+
raise ValueError("Number of frames and annotations must match")
|
|
107
|
+
|
|
108
|
+
self.reset()
|
|
109
|
+
|
|
110
|
+
# Process each frame
|
|
111
|
+
for frame_idx, (frame, annotation) in enumerate(zip(frames, annotations)):
|
|
112
|
+
self.current_frame = frame_idx
|
|
113
|
+
self.update(frame, annotation)
|
|
114
|
+
|
|
115
|
+
# Convert accumulated tracks to VideoAnnotation
|
|
116
|
+
return self._create_video_annotation()
|
|
117
|
+
|
|
118
|
+
def _convert_annotation(self, annotation: Annotation) -> np.ndarray:
|
|
119
|
+
"""Convert Supervisely annotation to BoTSORT detection format."""
|
|
120
|
+
detections_list = []
|
|
121
|
+
|
|
122
|
+
for label in annotation.labels:
|
|
123
|
+
if label.tags.get("confidence", None) is not None:
|
|
124
|
+
confidence = label.tags.get("confidence").value
|
|
125
|
+
elif label.tags.get("conf", None) is not None:
|
|
126
|
+
confidence = label.tags.get("conf").value
|
|
127
|
+
else:
|
|
128
|
+
confidence = 1.0
|
|
129
|
+
logger.debug(
|
|
130
|
+
f"Label {label.obj_class.name} does not have confidence tag, using default value 1.0"
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
rectangle = label.geometry.to_bbox()
|
|
134
|
+
|
|
135
|
+
class_name = label.obj_class.name
|
|
136
|
+
class_id = self.class_ids[class_name]
|
|
137
|
+
|
|
138
|
+
detection = [
|
|
139
|
+
rectangle.left, # x1
|
|
140
|
+
rectangle.top, # y1
|
|
141
|
+
rectangle.right, # x2
|
|
142
|
+
rectangle.bottom, # y2
|
|
143
|
+
confidence, # score
|
|
144
|
+
class_id, # class_id as number
|
|
145
|
+
]
|
|
146
|
+
detections_list.append(detection)
|
|
147
|
+
|
|
148
|
+
if detections_list:
|
|
149
|
+
return np.array(detections_list, dtype=np.float32)
|
|
150
|
+
else:
|
|
151
|
+
return np.zeros((0, 6), dtype=np.float32)
|
|
152
|
+
|
|
153
|
+
def _stracks_to_tracks(self, output_stracks, detection_track_map) -> List[TrackedObject]:
|
|
154
|
+
"""Convert BoTSORT output tracks to TrackedObject dataclass instances."""
|
|
155
|
+
tracks = []
|
|
156
|
+
|
|
157
|
+
id_to_name = {v: k for k, v in self.class_ids.items()}
|
|
158
|
+
|
|
159
|
+
track_id_to_det_id = {}
|
|
160
|
+
for pair in detection_track_map:
|
|
161
|
+
det_id = pair["det_id"]
|
|
162
|
+
track_id = pair["track_id"]
|
|
163
|
+
track_id_to_det_id[track_id] = det_id
|
|
164
|
+
|
|
165
|
+
for strack in output_stracks:
|
|
166
|
+
# BoTSORT may store class info in different attributes
|
|
167
|
+
# Try to get class_id from various possible sources
|
|
168
|
+
class_id = 0 # default
|
|
169
|
+
|
|
170
|
+
if hasattr(strack, 'cls') and strack.cls != -1:
|
|
171
|
+
# cls should contain the numeric ID we passed in
|
|
172
|
+
class_id = int(strack.cls)
|
|
173
|
+
elif hasattr(strack, 'class_id'):
|
|
174
|
+
class_id = int(strack.class_id)
|
|
175
|
+
|
|
176
|
+
class_name = id_to_name.get(class_id, "unknown")
|
|
177
|
+
|
|
178
|
+
# Get Supervisely class ID from stored ObjClass
|
|
179
|
+
class_sly_id = None
|
|
180
|
+
if class_name in self.obj_classes:
|
|
181
|
+
obj_class = self.obj_classes[class_name]
|
|
182
|
+
class_sly_id = obj_class.sly_id
|
|
183
|
+
|
|
184
|
+
track = TrackedObject(
|
|
185
|
+
track_id=strack.track_id,
|
|
186
|
+
det_id=track_id_to_det_id.get(strack.track_id),
|
|
187
|
+
bbox=strack.tlbr.tolist(), # [x1, y1, x2, y2]
|
|
188
|
+
class_name=class_name,
|
|
189
|
+
class_sly_id=class_sly_id,
|
|
190
|
+
score=getattr(strack, 'score', 1.0)
|
|
191
|
+
)
|
|
192
|
+
tracks.append(track)
|
|
193
|
+
|
|
194
|
+
return tracks
|
|
195
|
+
|
|
196
|
+
def _update_obj_classes(self, annotation: Annotation):
|
|
197
|
+
"""Extract and store object classes from annotation."""
|
|
198
|
+
for label in annotation.labels:
|
|
199
|
+
class_name = label.obj_class.name
|
|
200
|
+
if class_name not in self.obj_classes:
|
|
201
|
+
self.obj_classes[class_name] = label.obj_class
|
|
202
|
+
|
|
203
|
+
if class_name not in self.class_ids:
|
|
204
|
+
self.class_ids[class_name] = len(self.class_ids)
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
def _create_video_annotation(self) -> VideoAnnotation:
|
|
208
|
+
"""Convert accumulated tracking results to Supervisely VideoAnnotation."""
|
|
209
|
+
img_h, img_w = self.frame_shape
|
|
210
|
+
video_objects = {} # track_id -> VideoObject
|
|
211
|
+
frames = []
|
|
212
|
+
|
|
213
|
+
for frame_idx, tracks in enumerate(self.frame_tracks):
|
|
214
|
+
frame_figures = []
|
|
215
|
+
|
|
216
|
+
for track in tracks:
|
|
217
|
+
track_id = track.track_id
|
|
218
|
+
bbox = track.bbox # [x1, y1, x2, y2]
|
|
219
|
+
class_name = track.class_name
|
|
220
|
+
|
|
221
|
+
# Clip bbox to image boundaries
|
|
222
|
+
x1, y1, x2, y2 = bbox
|
|
223
|
+
dims = np.array([img_w, img_h, img_w, img_h]) - 1
|
|
224
|
+
x1, y1, x2, y2 = np.clip([x1, y1, x2, y2], 0, dims)
|
|
225
|
+
|
|
226
|
+
# Get or create VideoObject
|
|
227
|
+
if track_id not in video_objects:
|
|
228
|
+
obj_class = self.obj_classes.get(class_name)
|
|
229
|
+
if obj_class is None:
|
|
230
|
+
continue # Skip if class not found
|
|
231
|
+
video_objects[track_id] = sly.VideoObject(obj_class)
|
|
232
|
+
|
|
233
|
+
video_object = video_objects[track_id]
|
|
234
|
+
rect = sly.Rectangle(top=y1, left=x1, bottom=y2, right=x2)
|
|
235
|
+
frame_figures.append(sly.VideoFigure(video_object, rect, frame_idx))
|
|
236
|
+
|
|
237
|
+
frames.append(sly.Frame(frame_idx, frame_figures))
|
|
238
|
+
|
|
239
|
+
objects = list(video_objects.values())
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
return VideoAnnotation(
|
|
243
|
+
img_size=self.frame_shape,
|
|
244
|
+
frames_count=len(self.frame_tracks),
|
|
245
|
+
objects=sly.VideoObjectCollection(objects),
|
|
246
|
+
frames=sly.FrameCollection(frames)
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
@property
|
|
250
|
+
def video_annotation(self) -> VideoAnnotation:
|
|
251
|
+
"""Return the accumulated VideoAnnotation."""
|
|
252
|
+
if not self.frame_tracks:
|
|
253
|
+
error_msg = (
|
|
254
|
+
"No tracking data available. "
|
|
255
|
+
"Please run tracking first using track() method or process frames with update()."
|
|
256
|
+
)
|
|
257
|
+
raise ValueError(error_msg)
|
|
258
|
+
|
|
259
|
+
return self._create_video_annotation()
|
supervisely/project/project.py
CHANGED
|
@@ -5621,7 +5621,7 @@ async def _download_project_async(
|
|
|
5621
5621
|
if download_blob_files and image.related_data_id is not None:
|
|
5622
5622
|
blob_files_to_download[image.related_data_id] = image.download_id
|
|
5623
5623
|
blob_images.append(image)
|
|
5624
|
-
elif image.size < switch_size:
|
|
5624
|
+
elif image.size is not None and image.size < switch_size:
|
|
5625
5625
|
small_images.append(image)
|
|
5626
5626
|
else:
|
|
5627
5627
|
large_images.append(image)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: supervisely
|
|
3
|
-
Version: 6.73.
|
|
3
|
+
Version: 6.73.419
|
|
4
4
|
Summary: Supervisely Python SDK.
|
|
5
5
|
Home-page: https://github.com/supervisely/supervisely
|
|
6
6
|
Author: Supervisely
|
|
@@ -129,6 +129,8 @@ Requires-Dist: faiss-gpu; extra == "tracking"
|
|
|
129
129
|
Requires-Dist: tabulate; extra == "tracking"
|
|
130
130
|
Requires-Dist: tensorboard; extra == "tracking"
|
|
131
131
|
Requires-Dist: decord; extra == "tracking"
|
|
132
|
+
Requires-Dist: gdown; extra == "tracking"
|
|
133
|
+
Requires-Dist: torch; extra == "tracking"
|
|
132
134
|
Provides-Extra: training
|
|
133
135
|
Requires-Dist: pycocotools; extra == "training"
|
|
134
136
|
Requires-Dist: scikit-learn; extra == "training"
|
|
@@ -52,7 +52,7 @@ supervisely/api/video_annotation_tool_api.py,sha256=3A9-U8WJzrTShP_n9T8U01M9FzGY
|
|
|
52
52
|
supervisely/api/workspace_api.py,sha256=24O9uR5eIA2JdD0eQLi9LGaaHISdb2gUqnxJtx7bTew,9222
|
|
53
53
|
supervisely/api/entity_annotation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
54
54
|
supervisely/api/entity_annotation/entity_annotation_api.py,sha256=R7irdsYmUecsibuUFbcPRiS6tV3GnCHi9NfWeuoN7_0,3085
|
|
55
|
-
supervisely/api/entity_annotation/figure_api.py,sha256=
|
|
55
|
+
supervisely/api/entity_annotation/figure_api.py,sha256=0tG-eJ3HEzcOSQBKSmsAzB-tQ2uZZLyBGsYxA1Bk5us,38052
|
|
56
56
|
supervisely/api/entity_annotation/object_api.py,sha256=gbcNvN_KY6G80Me8fHKQgryc2Co7VU_kfFd1GYILZ4E,8875
|
|
57
57
|
supervisely/api/entity_annotation/tag_api.py,sha256=IapvSZmakjdOn0yvqP2tQRY8gkZg0bcvIZBwWRcafrg,18996
|
|
58
58
|
supervisely/api/nn/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -895,9 +895,9 @@ supervisely/nn/benchmark/visualization/widgets/table/__init__.py,sha256=47DEQpj8
|
|
|
895
895
|
supervisely/nn/benchmark/visualization/widgets/table/table.py,sha256=atmDnF1Af6qLQBUjLhK18RMDKAYlxnsuVHMSEa5a-e8,4319
|
|
896
896
|
supervisely/nn/inference/__init__.py,sha256=QFukX2ip-U7263aEPCF_UCFwj6EujbMnsgrXp5Bbt8I,1623
|
|
897
897
|
supervisely/nn/inference/cache.py,sha256=rfmb1teJ9lNDfisUSh6bwDCVkPZocn8GMvDgLQktnbo,35023
|
|
898
|
-
supervisely/nn/inference/inference.py,sha256=
|
|
898
|
+
supervisely/nn/inference/inference.py,sha256=tOEoUTvdmFiHsGKri_9pvlu4iqx30tB0aMXr9q8-L3c,199776
|
|
899
899
|
supervisely/nn/inference/inference_request.py,sha256=y6yw0vbaRRcEBS27nq3y0sL6Gmq2qLA_Bm0GrnJGegE,14267
|
|
900
|
-
supervisely/nn/inference/session.py,sha256=
|
|
900
|
+
supervisely/nn/inference/session.py,sha256=XUqJ_CqHk3ZJYkWxdnErN_6afCpIBU76nq6Ek7DiOQI,35792
|
|
901
901
|
supervisely/nn/inference/uploader.py,sha256=21a9coOimCHhEqAbV-llZWcp12847DEMoQp3N16bpK0,5425
|
|
902
902
|
supervisely/nn/inference/video_inference.py,sha256=8Bshjr6rDyLay5Za8IB8Dr6FURMO2R_v7aELasO8pR4,5746
|
|
903
903
|
supervisely/nn/inference/gui/__init__.py,sha256=wCxd-lF5Zhcwsis-wScDA8n1Gk_1O00PKgDviUZ3F1U,221
|
|
@@ -905,7 +905,7 @@ supervisely/nn/inference/gui/gui.py,sha256=0OjGcU0KGZgWfLVQkBbljNy-QV22pdZ0bbpPv
|
|
|
905
905
|
supervisely/nn/inference/gui/serving_gui.py,sha256=JCIVp3B_tX0VKMMBJ-TdRzzAMnAL-sdqHnb1vd28r50,8596
|
|
906
906
|
supervisely/nn/inference/gui/serving_gui_template.py,sha256=V2FJYLyWT9a315npIeVkEEpB8Xc-AOL7TgG0wgM08sc,9777
|
|
907
907
|
supervisely/nn/inference/instance_segmentation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
908
|
-
supervisely/nn/inference/instance_segmentation/instance_segmentation.py,sha256=
|
|
908
|
+
supervisely/nn/inference/instance_segmentation/instance_segmentation.py,sha256=7B5PLkbCv6e5oqqia6Ugf3OUlff_83kYfcAk_3GJXRg,2261
|
|
909
909
|
supervisely/nn/inference/instance_segmentation/dashboard/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
910
910
|
supervisely/nn/inference/instance_segmentation/dashboard/classes_ui.py,sha256=glu31SzXVxSK2tEgDPNGNCG4_S72XPHY9u1U5lUckSg,2915
|
|
911
911
|
supervisely/nn/inference/instance_segmentation/dashboard/deploy_ui.py,sha256=XbLqrLhZASSbjUM5Kt29IRSdPnv-nVNQUU1U5Xdw7FU,1215
|
|
@@ -916,7 +916,7 @@ supervisely/nn/inference/interactive_segmentation/__init__.py,sha256=47DEQpj8HBS
|
|
|
916
916
|
supervisely/nn/inference/interactive_segmentation/functional.py,sha256=3GaeeOemji_ym0-C2mwj6SVEhnPkq7v3KCc4npw3iZ8,4905
|
|
917
917
|
supervisely/nn/inference/interactive_segmentation/interactive_segmentation.py,sha256=vX1H9eaR8oRfMecQxJfpu6hGxbtf8bEESGJp_fPmfWc,20402
|
|
918
918
|
supervisely/nn/inference/object_detection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
919
|
-
supervisely/nn/inference/object_detection/object_detection.py,sha256=
|
|
919
|
+
supervisely/nn/inference/object_detection/object_detection.py,sha256=aDM29aMeM3UMHk5c28sB2UK5t1Ir5NMuQwzqH2vxg_Y,1796
|
|
920
920
|
supervisely/nn/inference/object_detection_3d/__init__.py,sha256=1N1fTXgJ6zbTVhM4CXwyobQy5pe1Sb1tNm8vm-i6DaE,94
|
|
921
921
|
supervisely/nn/inference/object_detection_3d/object_detection_3d.py,sha256=GmBz7VQ9-nl6EGrTb0b6Icm-TVdXT0qLiKg1pbvCUws,5601
|
|
922
922
|
supervisely/nn/inference/pose_estimation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -970,36 +970,23 @@ supervisely/nn/legacy/pytorch/weights.py,sha256=Zb9kcpUCg6ykr7seO53CkKSQa2K44wo8
|
|
|
970
970
|
supervisely/nn/legacy/training/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
971
971
|
supervisely/nn/legacy/training/eval_planner.py,sha256=zN9b0_CX7sWGdC8e6riTvD-NOUc3_Xduyhj00S7PEIo,1311
|
|
972
972
|
supervisely/nn/model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
973
|
-
supervisely/nn/model/model_api.py,sha256=
|
|
974
|
-
supervisely/nn/model/prediction.py,sha256=
|
|
975
|
-
supervisely/nn/model/prediction_session.py,sha256=
|
|
976
|
-
supervisely/nn/tracker/__init__.py,sha256=
|
|
977
|
-
supervisely/nn/tracker/
|
|
978
|
-
supervisely/nn/tracker/
|
|
979
|
-
supervisely/nn/tracker/
|
|
980
|
-
supervisely/nn/tracker/
|
|
981
|
-
supervisely/nn/tracker/
|
|
982
|
-
supervisely/nn/tracker/
|
|
983
|
-
supervisely/nn/tracker/
|
|
984
|
-
supervisely/nn/tracker/
|
|
985
|
-
supervisely/nn/tracker/
|
|
986
|
-
supervisely/nn/tracker/
|
|
987
|
-
supervisely/nn/tracker/
|
|
988
|
-
supervisely/nn/tracker/
|
|
989
|
-
supervisely/nn/tracker/
|
|
990
|
-
supervisely/nn/tracker/deep_sort/deep_sort/detection.py,sha256=cS7YqK8RPbr7C3l6myKTHGBvQbYoKxnEyVa4ZGVbsLY,1430
|
|
991
|
-
supervisely/nn/tracker/deep_sort/deep_sort/iou_matching.py,sha256=HSzn9FjOSHrqH9h6qJlYe1i4o0ZJhjERxCcuIYnLmPE,2830
|
|
992
|
-
supervisely/nn/tracker/deep_sort/deep_sort/kalman_filter.py,sha256=wDSbs2QA3cnnWB-WAzjNcKKqGiNZmfpN0_Cm9dTxU38,7888
|
|
993
|
-
supervisely/nn/tracker/deep_sort/deep_sort/linear_assignment.py,sha256=hAqMNk2CFPDJvmGJCfNbGVngUgKGM2oYldaGaU2zWC4,7871
|
|
994
|
-
supervisely/nn/tracker/deep_sort/deep_sort/nn_matching.py,sha256=U0NYReianEohMc9eA_eAuXjqMkqkNjWlq40S7VvYKHs,5469
|
|
995
|
-
supervisely/nn/tracker/deep_sort/deep_sort/track.py,sha256=eNvBlhhBcTzyTWOX_TKyT3sWJM6fSz3vPi30kfz8wE4,4976
|
|
996
|
-
supervisely/nn/tracker/deep_sort/deep_sort/tracker.py,sha256=cz--uel4ROLHPem8dOofitCoQj_bTd8srWFp2FpaBR0,5357
|
|
997
|
-
supervisely/nn/tracker/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
998
|
-
supervisely/nn/tracker/utils/gmc.py,sha256=3JX8979H3NA-YHNaRQyj9Z-xb9qtyMittPEjGw8y2Jo,11557
|
|
999
|
-
supervisely/nn/tracker/utils/kalman_filter.py,sha256=eSFmCjM0mikHCAFvj-KCVzw-0Jxpoc3Cfc2NWEjJC1Q,17268
|
|
1000
|
-
supervisely/nn/tracking/__init__.py,sha256=Ld1ed7ZZQZPkhX-5Xr-UbHZx5zLCm2-tInHnPhioOak,50
|
|
1001
|
-
supervisely/nn/tracking/boxmot.py,sha256=H9cQjYGL9nX_TLrfKDChhljTIiE9lffcgbwWCf_4PJU,4277
|
|
1002
|
-
supervisely/nn/tracking/tracking.py,sha256=WNrNm02B1pspA3d_AmzSJ-54RZTqWV2NZiC7FHe88bo,857
|
|
973
|
+
supervisely/nn/model/model_api.py,sha256=tSstGGdzm3cHc81P7IoM447sMVesUYJpspzMqUY70pg,10322
|
|
974
|
+
supervisely/nn/model/prediction.py,sha256=C_lbgfDQD29MrBflSQNsxRghwnJ5LmPwMf6S4y2hwoY,11795
|
|
975
|
+
supervisely/nn/model/prediction_session.py,sha256=Lyr3D6KwvjwHtzow6OYdNsoEecdP4ys2RC-usZ9PCM0,26639
|
|
976
|
+
supervisely/nn/tracker/__init__.py,sha256=fTyXg-q_LuYx9sv6TueDDhxCfwQmDxUkIK4iLZgfBOk,283
|
|
977
|
+
supervisely/nn/tracker/base_tracker.py,sha256=2d23JlHizOqVye324YT20EE8RP52uwoQUkPYvPXJTdw,1668
|
|
978
|
+
supervisely/nn/tracker/botsort_tracker.py,sha256=jNtzhdUMoBYMvvreEV4bFQbYav97koiD4gLU5LvICr8,9817
|
|
979
|
+
supervisely/nn/tracker/botsort/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
980
|
+
supervisely/nn/tracker/botsort/botsort_config.yaml,sha256=q_7Gp1-15lGYOLv7JvxVJ69mm6hbCLbUAl_ZBOYNGpw,535
|
|
981
|
+
supervisely/nn/tracker/botsort/osnet_reid/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
982
|
+
supervisely/nn/tracker/botsort/osnet_reid/osnet.py,sha256=07-svZiVfzEf92Q3f2ffbgXPePAbO61FenaAsaGDj74,16824
|
|
983
|
+
supervisely/nn/tracker/botsort/osnet_reid/osnet_reid_interface.py,sha256=Qzp35-V8xv2zQUIr6vvNrTzyvdxCaa2USJVbyBae6DI,3227
|
|
984
|
+
supervisely/nn/tracker/botsort/tracker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
985
|
+
supervisely/nn/tracker/botsort/tracker/basetrack.py,sha256=oPcXpQWev6YmpjzqWwQKZJrNdyAHL1A8q_ok10nwgvY,1111
|
|
986
|
+
supervisely/nn/tracker/botsort/tracker/gmc.py,sha256=E6LkkVEYeBUjKaQ7VnYxMAj0fdDDWH8Es_tC1a0Z0rs,11754
|
|
987
|
+
supervisely/nn/tracker/botsort/tracker/kalman_filter.py,sha256=waTArMcbmpHAzb57aJ-IcS1o5-i-TX5U-0N_M_28nlo,9671
|
|
988
|
+
supervisely/nn/tracker/botsort/tracker/matching.py,sha256=bgnheHwWD3XZSI3OJVfdrU5bYJ44rxPHzzSElfg6LZM,6600
|
|
989
|
+
supervisely/nn/tracker/botsort/tracker/mc_bot_sort.py,sha256=AE_yi4pVg_bIsK-6-ZlPziqb98tA-9iWgjT8aRE-8sA,17775
|
|
1003
990
|
supervisely/nn/training/__init__.py,sha256=gY4PCykJ-42MWKsqb9kl-skemKa8yB6t_fb5kzqR66U,111
|
|
1004
991
|
supervisely/nn/training/train_app.py,sha256=c71Y9rV-0qnZ0VsE156HS9Q5Fowg8RoGsItyYFjdyPA,125210
|
|
1005
992
|
supervisely/nn/training/gui/__init__.py,sha256=Nqnn8clbgv-5l0PgxcTOldg8mkMKrFn4TvPL-rYUUGg,1
|
|
@@ -1042,7 +1029,7 @@ supervisely/project/data_version.py,sha256=P5Lui6i64pYeJWmAdGJDv8GRXxjfpSSZ8zT_M
|
|
|
1042
1029
|
supervisely/project/download.py,sha256=yCFpRum_q8fbY_z2mcRAhYAcYFcDc215ldioO3Gzg3Q,28680
|
|
1043
1030
|
supervisely/project/pointcloud_episode_project.py,sha256=ahwL79Ojf5gLdvAph5SLKXr66jmVWzgiOXLsk2P8eVQ,48433
|
|
1044
1031
|
supervisely/project/pointcloud_project.py,sha256=NcrsMf673cITLoErJhcdQN85w3k9TBqolEbWR4qjPZQ,56872
|
|
1045
|
-
supervisely/project/project.py,sha256=
|
|
1032
|
+
supervisely/project/project.py,sha256=YBDW0i83fpmE2UT28Tsqk4hMb9OVUsEd02pZsch4xgM,240428
|
|
1046
1033
|
supervisely/project/project_meta.py,sha256=UTQPstRmRJvbtCcQ1noCtzcw3Sd4llwRMHes-Sz-JQg,51429
|
|
1047
1034
|
supervisely/project/project_settings.py,sha256=NLThzU_DCynOK6hkHhVdFyezwprn9UqlnrLDe_3qhkY,9347
|
|
1048
1035
|
supervisely/project/project_type.py,sha256=7mQ7zg6r7Bm2oFn5aR8n_PeLqMmOaPZd6ph7Z8ZISTw,608
|
|
@@ -1116,9 +1103,9 @@ supervisely/worker_proto/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
|
|
|
1116
1103
|
supervisely/worker_proto/worker_api_pb2.py,sha256=VQfi5JRBHs2pFCK1snec3JECgGnua3Xjqw_-b3aFxuM,59142
|
|
1117
1104
|
supervisely/worker_proto/worker_api_pb2_grpc.py,sha256=3BwQXOaP9qpdi0Dt9EKG--Lm8KGN0C5AgmUfRv77_Jk,28940
|
|
1118
1105
|
supervisely_lib/__init__.py,sha256=7-3QnN8Zf0wj8NCr2oJmqoQWMKKPKTECvjH9pd2S5vY,159
|
|
1119
|
-
supervisely-6.73.
|
|
1120
|
-
supervisely-6.73.
|
|
1121
|
-
supervisely-6.73.
|
|
1122
|
-
supervisely-6.73.
|
|
1123
|
-
supervisely-6.73.
|
|
1124
|
-
supervisely-6.73.
|
|
1106
|
+
supervisely-6.73.419.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
1107
|
+
supervisely-6.73.419.dist-info/METADATA,sha256=j4oQqDt11Jv3-V0vS0ILCLC4jh1o7KQvoIrAaTF8n3U,35338
|
|
1108
|
+
supervisely-6.73.419.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
|
|
1109
|
+
supervisely-6.73.419.dist-info/entry_points.txt,sha256=U96-5Hxrp2ApRjnCoUiUhWMqijqh8zLR03sEhWtAcms,102
|
|
1110
|
+
supervisely-6.73.419.dist-info/top_level.txt,sha256=kcFVwb7SXtfqZifrZaSE3owHExX4gcNYe7Q2uoby084,28
|
|
1111
|
+
supervisely-6.73.419.dist-info/RECORD,,
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import torch # pylint: disable=import-error
|
|
2
|
-
|
|
3
|
-
try:
|
|
4
|
-
import fastreid
|
|
5
|
-
except ImportError:
|
|
6
|
-
import sys
|
|
7
|
-
from pathlib import Path
|
|
8
|
-
|
|
9
|
-
fast_reid_repo_url = "https://github.com/supervisely-ecosystem/fast-reid.git"
|
|
10
|
-
fast_reid_parent_path = Path(__file__).parent
|
|
11
|
-
fast_reid_path = fast_reid_parent_path.joinpath("fast_reid")
|
|
12
|
-
if not fast_reid_path.exists():
|
|
13
|
-
import subprocess
|
|
14
|
-
|
|
15
|
-
subprocess.run(["git", "clone", fast_reid_repo_url, str(fast_reid_path.resolve())])
|
|
16
|
-
|
|
17
|
-
sys.path.insert(0, str(fast_reid_path.resolve()))
|
|
18
|
-
|
|
19
|
-
import fastreid
|
|
20
|
-
|
|
21
|
-
from supervisely.nn.tracker.bot_sort.sly_tracker import BoTTracker
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import cv2
|
|
2
|
-
import matplotlib.pyplot as plt
|
|
3
|
-
import numpy as np
|
|
4
|
-
import torch # pylint: disable=import-error
|
|
5
|
-
import torch.nn.functional as F # pylint: disable=import-error
|
|
6
|
-
from fastreid.config import get_cfg # pylint: disable=import-error
|
|
7
|
-
from fastreid.modeling.meta_arch import build_model # pylint: disable=import-error
|
|
8
|
-
from fastreid.utils.checkpoint import Checkpointer # pylint: disable=import-error
|
|
9
|
-
|
|
10
|
-
# from torch.backends import cudnn
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
# cudnn.benchmark = True
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def setup_cfg(config_file, opts):
|
|
17
|
-
# load config from file and command-line arguments
|
|
18
|
-
cfg = get_cfg()
|
|
19
|
-
cfg.merge_from_file(config_file)
|
|
20
|
-
cfg.merge_from_list(opts)
|
|
21
|
-
cfg.MODEL.BACKBONE.PRETRAIN = False
|
|
22
|
-
|
|
23
|
-
cfg.freeze()
|
|
24
|
-
|
|
25
|
-
return cfg
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def postprocess(features):
|
|
29
|
-
# Normalize feature to compute cosine distance
|
|
30
|
-
features = F.normalize(features)
|
|
31
|
-
features = features.cpu().data.numpy()
|
|
32
|
-
return features
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def preprocess(image, input_size):
|
|
36
|
-
if len(image.shape) == 3:
|
|
37
|
-
padded_img = np.ones((input_size[1], input_size[0], 3), dtype=np.uint8) * 114
|
|
38
|
-
else:
|
|
39
|
-
padded_img = np.ones(input_size) * 114
|
|
40
|
-
img = np.array(image)
|
|
41
|
-
r = min(input_size[1] / img.shape[0], input_size[0] / img.shape[1])
|
|
42
|
-
resized_img = cv2.resize(
|
|
43
|
-
img,
|
|
44
|
-
(int(img.shape[1] * r), int(img.shape[0] * r)),
|
|
45
|
-
interpolation=cv2.INTER_LINEAR,
|
|
46
|
-
)
|
|
47
|
-
padded_img[: int(img.shape[0] * r), : int(img.shape[1] * r)] = resized_img
|
|
48
|
-
|
|
49
|
-
return padded_img, r
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
class FastReIDInterface:
|
|
53
|
-
def __init__(self, config_file, weights_path, device, batch_size=8):
|
|
54
|
-
super(FastReIDInterface, self).__init__()
|
|
55
|
-
if device != "cpu":
|
|
56
|
-
self.device = "cuda"
|
|
57
|
-
else:
|
|
58
|
-
self.device = "cpu"
|
|
59
|
-
|
|
60
|
-
self.batch_size = batch_size
|
|
61
|
-
|
|
62
|
-
self.cfg = setup_cfg(config_file, ["MODEL.WEIGHTS", weights_path])
|
|
63
|
-
|
|
64
|
-
self.model = build_model(self.cfg)
|
|
65
|
-
self.model.eval()
|
|
66
|
-
|
|
67
|
-
Checkpointer(self.model).load(weights_path)
|
|
68
|
-
|
|
69
|
-
if self.device != "cpu":
|
|
70
|
-
self.model = self.model.eval().to(device="cuda").half()
|
|
71
|
-
else:
|
|
72
|
-
self.model = self.model.eval()
|
|
73
|
-
|
|
74
|
-
self.pH, self.pW = self.cfg.INPUT.SIZE_TEST
|
|
75
|
-
|
|
76
|
-
def inference(self, image, detections):
|
|
77
|
-
|
|
78
|
-
if detections is None or np.size(detections) == 0:
|
|
79
|
-
return []
|
|
80
|
-
|
|
81
|
-
H, W, _ = np.shape(image)
|
|
82
|
-
|
|
83
|
-
batch_patches = []
|
|
84
|
-
patches = []
|
|
85
|
-
for d in range(np.size(detections, 0)):
|
|
86
|
-
tlbr = detections[d, :4].astype(np.int_)
|
|
87
|
-
tlbr[0] = max(0, tlbr[0])
|
|
88
|
-
tlbr[1] = max(0, tlbr[1])
|
|
89
|
-
tlbr[2] = min(W - 1, tlbr[2])
|
|
90
|
-
tlbr[3] = min(H - 1, tlbr[3])
|
|
91
|
-
patch = image[tlbr[1] : tlbr[3], tlbr[0] : tlbr[2], :]
|
|
92
|
-
|
|
93
|
-
# the model expects RGB inputs
|
|
94
|
-
patch = patch[:, :, ::-1]
|
|
95
|
-
|
|
96
|
-
# Apply pre-processing to image.
|
|
97
|
-
patch = cv2.resize(
|
|
98
|
-
patch, tuple(self.cfg.INPUT.SIZE_TEST[::-1]), interpolation=cv2.INTER_LINEAR
|
|
99
|
-
)
|
|
100
|
-
# patch, scale = preprocess(patch, self.cfg.INPUT.SIZE_TEST[::-1])
|
|
101
|
-
|
|
102
|
-
# plt.figure()
|
|
103
|
-
# plt.imshow(patch)
|
|
104
|
-
# plt.show()
|
|
105
|
-
|
|
106
|
-
# Make shape with a new batch dimension which is adapted for network input
|
|
107
|
-
patch = torch.as_tensor(patch.astype("float32").transpose(2, 0, 1))
|
|
108
|
-
patch = patch.to(device=self.device).half()
|
|
109
|
-
|
|
110
|
-
patches.append(patch)
|
|
111
|
-
|
|
112
|
-
if (d + 1) % self.batch_size == 0:
|
|
113
|
-
patches = torch.stack(patches, dim=0)
|
|
114
|
-
batch_patches.append(patches)
|
|
115
|
-
patches = []
|
|
116
|
-
|
|
117
|
-
if len(patches):
|
|
118
|
-
patches = torch.stack(patches, dim=0)
|
|
119
|
-
batch_patches.append(patches)
|
|
120
|
-
|
|
121
|
-
features = np.zeros((0, 2048))
|
|
122
|
-
# features = np.zeros((0, 768))
|
|
123
|
-
|
|
124
|
-
for patches in batch_patches:
|
|
125
|
-
|
|
126
|
-
# Run model
|
|
127
|
-
patches_ = torch.clone(patches)
|
|
128
|
-
pred = self.model(patches)
|
|
129
|
-
pred[torch.isinf(pred)] = 1.0
|
|
130
|
-
|
|
131
|
-
feat = postprocess(pred)
|
|
132
|
-
|
|
133
|
-
nans = np.isnan(np.sum(feat, axis=1))
|
|
134
|
-
if np.isnan(feat).any():
|
|
135
|
-
for n in range(np.size(nans)):
|
|
136
|
-
if nans[n]:
|
|
137
|
-
# patch_np = patches[n, ...].squeeze().transpose(1, 2, 0).cpu().numpy()
|
|
138
|
-
patch_np = patches_[n, ...]
|
|
139
|
-
patch_np_ = torch.unsqueeze(patch_np, 0)
|
|
140
|
-
pred_ = self.model(patch_np_)
|
|
141
|
-
|
|
142
|
-
patch_np = torch.squeeze(patch_np).cpu()
|
|
143
|
-
patch_np = torch.permute(patch_np, (1, 2, 0)).int()
|
|
144
|
-
patch_np = patch_np.numpy()
|
|
145
|
-
|
|
146
|
-
plt.figure()
|
|
147
|
-
plt.imshow(patch_np)
|
|
148
|
-
plt.show()
|
|
149
|
-
|
|
150
|
-
features = np.vstack((features, feat))
|
|
151
|
-
|
|
152
|
-
return features
|