supervisely 6.73.418__py3-none-any.whl → 6.73.420__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 +212 -74
- {supervisely-6.73.418.dist-info → supervisely-6.73.420.dist-info}/METADATA +3 -1
- {supervisely-6.73.418.dist-info → supervisely-6.73.420.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.420.dist-info}/LICENSE +0 -0
- {supervisely-6.73.418.dist-info → supervisely-6.73.420.dist-info}/WHEEL +0 -0
- {supervisely-6.73.418.dist-info → supervisely-6.73.420.dist-info}/entry_points.txt +0 -0
- {supervisely-6.73.418.dist-info → supervisely-6.73.420.dist-info}/top_level.txt +0 -0
|
@@ -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=Xl_L_dRJp0KZJMioabXWGO2Zt1X6dl2W9v4-Zt66zYs,246561
|
|
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.420.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
1107
|
+
supervisely-6.73.420.dist-info/METADATA,sha256=6wWuelPBg3V20xDmnkT_ZYPt4RxkNbbN94i0z9Q2y1M,35338
|
|
1108
|
+
supervisely-6.73.420.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
|
|
1109
|
+
supervisely-6.73.420.dist-info/entry_points.txt,sha256=U96-5Hxrp2ApRjnCoUiUhWMqijqh8zLR03sEhWtAcms,102
|
|
1110
|
+
supervisely-6.73.420.dist-info/top_level.txt,sha256=kcFVwb7SXtfqZifrZaSE3owHExX4gcNYe7Q2uoby084,28
|
|
1111
|
+
supervisely-6.73.420.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
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import lap # pylint: disable=import-error
|
|
2
|
-
import numpy as np
|
|
3
|
-
from cython_bbox import bbox_overlaps as bbox_ious # pylint: disable=import-error
|
|
4
|
-
from scipy.spatial.distance import cdist
|
|
5
|
-
|
|
6
|
-
from supervisely.nn.tracker.utils import kalman_filter
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def linear_assignment(cost_matrix, thresh):
|
|
10
|
-
if cost_matrix.size == 0:
|
|
11
|
-
return (
|
|
12
|
-
np.empty((0, 2), dtype=int),
|
|
13
|
-
tuple(range(cost_matrix.shape[0])),
|
|
14
|
-
tuple(range(cost_matrix.shape[1])),
|
|
15
|
-
)
|
|
16
|
-
matches, unmatched_a, unmatched_b = [], [], []
|
|
17
|
-
cost, x, y = lap.lapjv(cost_matrix, extend_cost=True, cost_limit=thresh)
|
|
18
|
-
for ix, mx in enumerate(x):
|
|
19
|
-
if mx >= 0:
|
|
20
|
-
matches.append([ix, mx])
|
|
21
|
-
unmatched_a = np.where(x < 0)[0]
|
|
22
|
-
unmatched_b = np.where(y < 0)[0]
|
|
23
|
-
matches = np.asarray(matches)
|
|
24
|
-
return matches, unmatched_a, unmatched_b
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def ious(atlbrs, btlbrs):
|
|
28
|
-
"""
|
|
29
|
-
Compute cost based on IoU
|
|
30
|
-
:type atlbrs: list[tlbr] | np.ndarray
|
|
31
|
-
:type atlbrs: list[tlbr] | np.ndarray
|
|
32
|
-
|
|
33
|
-
:rtype ious np.ndarray
|
|
34
|
-
"""
|
|
35
|
-
ious = np.zeros((len(atlbrs), len(btlbrs)), dtype=float)
|
|
36
|
-
if ious.size == 0:
|
|
37
|
-
return ious
|
|
38
|
-
|
|
39
|
-
ious = bbox_ious(
|
|
40
|
-
np.ascontiguousarray(atlbrs, dtype=float), np.ascontiguousarray(btlbrs, dtype=float)
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
return ious
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
def iou_distance(atracks, btracks):
|
|
47
|
-
"""
|
|
48
|
-
Compute cost based on IoU
|
|
49
|
-
:type atracks: list[STrack]
|
|
50
|
-
:type btracks: list[STrack]
|
|
51
|
-
|
|
52
|
-
:rtype cost_matrix np.ndarray
|
|
53
|
-
"""
|
|
54
|
-
|
|
55
|
-
if (len(atracks) > 0 and isinstance(atracks[0], np.ndarray)) or (
|
|
56
|
-
len(btracks) > 0 and isinstance(btracks[0], np.ndarray)
|
|
57
|
-
):
|
|
58
|
-
atlbrs = atracks
|
|
59
|
-
btlbrs = btracks
|
|
60
|
-
else:
|
|
61
|
-
atlbrs = [track.tlbr for track in atracks]
|
|
62
|
-
btlbrs = [track.tlbr for track in btracks]
|
|
63
|
-
_ious = ious(atlbrs, btlbrs)
|
|
64
|
-
cost_matrix = 1 - _ious
|
|
65
|
-
|
|
66
|
-
return cost_matrix
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
def embedding_distance(tracks, detections, metric="cosine"):
|
|
70
|
-
"""
|
|
71
|
-
:param tracks: list[STrack]
|
|
72
|
-
:param detections: list[BaseTrack]
|
|
73
|
-
:param metric:
|
|
74
|
-
:return: cost_matrix np.ndarray
|
|
75
|
-
"""
|
|
76
|
-
|
|
77
|
-
cost_matrix = np.zeros((len(tracks), len(detections)), dtype=float)
|
|
78
|
-
if cost_matrix.size == 0:
|
|
79
|
-
return cost_matrix
|
|
80
|
-
det_features = np.asarray([track.curr_feat for track in detections], dtype=float)
|
|
81
|
-
track_features = np.asarray([track.smooth_feat for track in tracks], dtype=float)
|
|
82
|
-
|
|
83
|
-
cost_matrix = np.maximum(
|
|
84
|
-
0.0, cdist(track_features, det_features, metric)
|
|
85
|
-
) # / 2.0 # Nomalized features
|
|
86
|
-
return cost_matrix
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
def fuse_motion(kf, cost_matrix, tracks, detections, only_position=False, lambda_=0.98):
|
|
90
|
-
if cost_matrix.size == 0:
|
|
91
|
-
return cost_matrix
|
|
92
|
-
gating_dim = 2 if only_position else 4
|
|
93
|
-
gating_threshold = kalman_filter.chi2inv95[gating_dim]
|
|
94
|
-
# measurements = np.asarray([det.to_xyah() for det in detections])
|
|
95
|
-
measurements = np.asarray([det.to_xywh() for det in detections])
|
|
96
|
-
for row, track in enumerate(tracks):
|
|
97
|
-
gating_distance = kf.gating_distance(
|
|
98
|
-
track.mean, track.covariance, measurements, only_position, metric="maha"
|
|
99
|
-
)
|
|
100
|
-
cost_matrix[row, gating_distance > gating_threshold] = np.inf
|
|
101
|
-
cost_matrix[row] = lambda_ * cost_matrix[row] + (1 - lambda_) * gating_distance
|
|
102
|
-
return cost_matrix
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
def fuse_iou(cost_matrix, tracks, detections):
|
|
106
|
-
if cost_matrix.size == 0:
|
|
107
|
-
return cost_matrix
|
|
108
|
-
reid_sim = 1 - cost_matrix
|
|
109
|
-
iou_dist = iou_distance(tracks, detections)
|
|
110
|
-
iou_sim = 1 - iou_dist
|
|
111
|
-
fuse_sim = reid_sim * (1 + iou_sim) / 2
|
|
112
|
-
det_scores = np.array([det.score for det in detections])
|
|
113
|
-
det_scores = np.expand_dims(det_scores, axis=0).repeat(cost_matrix.shape[0], axis=0)
|
|
114
|
-
# fuse_sim = fuse_sim * (1 + det_scores) / 2
|
|
115
|
-
fuse_cost = 1 - fuse_sim
|
|
116
|
-
return fuse_cost
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
def fuse_score(cost_matrix, detections):
|
|
120
|
-
if cost_matrix.size == 0:
|
|
121
|
-
return cost_matrix
|
|
122
|
-
iou_sim = 1 - cost_matrix
|
|
123
|
-
det_scores = np.array([det.score for det in detections])
|
|
124
|
-
det_scores = np.expand_dims(det_scores, axis=0).repeat(cost_matrix.shape[0], axis=0)
|
|
125
|
-
fuse_sim = iou_sim * det_scores
|
|
126
|
-
fuse_cost = 1 - fuse_sim
|
|
127
|
-
return fuse_cost
|