subnet_bridge: copy winning miner repo into library
Browse files- README.md +2 -8
- benchmark/synthetic/bfb9a039-8a71-4ab5-9097-117d87572930.json +0 -171
- benchmark/synthetic/index.json +0 -16
- benchmark/synthetic/latest.json +0 -171
- main.py +53 -17
- pyproject.toml +1 -1
README.md
CHANGED
|
@@ -8,19 +8,13 @@ tags:
|
|
| 8 |
- object:truck
|
| 9 |
- object:motorcycle
|
| 10 |
- object:van
|
|
|
|
| 11 |
manako:
|
| 12 |
source: winner_fetch
|
| 13 |
manifest_element_name: manak0/Detect-Vehicle
|
| 14 |
winner_repo_id: danieldushku/s
|
| 15 |
winner_revision: 52f7ac2a3342a57a9dce79159ea94b831d55de8d
|
| 16 |
-
|
| 17 |
-
size_mb: 9.888267
|
| 18 |
-
performance_map50: 0.7555753708996942
|
| 19 |
-
E: 0.0764113035074492
|
| 20 |
-
last_benchmark:
|
| 21 |
-
type: synthetic_fixed
|
| 22 |
-
ran_at: '2026-10-26T08:39:39.426218Z'
|
| 23 |
-
result_path: benchmark/synthetic/bfb9a039-8a71-4ab5-9097-117d87572930.json
|
| 24 |
---
|
| 25 |
|
| 26 |
# Detect-Vehicle-winner
|
|
|
|
| 8 |
- object:truck
|
| 9 |
- object:motorcycle
|
| 10 |
- object:van
|
| 11 |
+
|
| 12 |
manako:
|
| 13 |
source: winner_fetch
|
| 14 |
manifest_element_name: manak0/Detect-Vehicle
|
| 15 |
winner_repo_id: danieldushku/s
|
| 16 |
winner_revision: 52f7ac2a3342a57a9dce79159ea94b831d55de8d
|
| 17 |
+
note: E=0.06073950 (map50=0.600000, size_mb=9.878250)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
---
|
| 19 |
|
| 20 |
# Detect-Vehicle-winner
|
benchmark/synthetic/bfb9a039-8a71-4ab5-9097-117d87572930.json
DELETED
|
@@ -1,171 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"meta": {
|
| 3 |
-
"element_id": "manako/Detect-Vehicle-winner",
|
| 4 |
-
"run_id": "bfb9a039-8a71-4ab5-9097-117d87572930",
|
| 5 |
-
"benchmark_type": "synthetic_fixed",
|
| 6 |
-
"saved_at": "2026-10-26T08:39:39.426218Z",
|
| 7 |
-
"result_path": "benchmark/synthetic/bfb9a039-8a71-4ab5-9097-117d87572930.json",
|
| 8 |
-
"split_ref": "private_final"
|
| 9 |
-
},
|
| 10 |
-
"results": {
|
| 11 |
-
"overall_iou": 0.711301418417662,
|
| 12 |
-
"per_class_iou": {
|
| 13 |
-
"car": 0.7070302145582933,
|
| 14 |
-
"bus": 0.5482735465755711,
|
| 15 |
-
"truck": 0.5751458422637304,
|
| 16 |
-
"motorcycle": 0.5297182473130839,
|
| 17 |
-
"van": 0.0
|
| 18 |
-
},
|
| 19 |
-
"map_50": 0.7555753708996942,
|
| 20 |
-
"map_50_90": 0.579080216734731,
|
| 21 |
-
"precision": 0.9343807763401109,
|
| 22 |
-
"recall": 0.7567365269461078,
|
| 23 |
-
"per_class_map_50": {
|
| 24 |
-
"bus": 0.9262408088235294,
|
| 25 |
-
"car": 0.7609370193011648,
|
| 26 |
-
"motorcycle": 0.6351600115463183,
|
| 27 |
-
"truck": 0.6999636439277644,
|
| 28 |
-
"van": 0.0
|
| 29 |
-
},
|
| 30 |
-
"per_class_map_50_90": {
|
| 31 |
-
"bus": 0.8002013873465061,
|
| 32 |
-
"car": 0.5558016885440995,
|
| 33 |
-
"motorcycle": 0.3591731876237153,
|
| 34 |
-
"truck": 0.6011446034246029,
|
| 35 |
-
"van": 0.0
|
| 36 |
-
},
|
| 37 |
-
"per_class_precision": {
|
| 38 |
-
"bus": 0.984375,
|
| 39 |
-
"car": 0.951530612244898,
|
| 40 |
-
"motorcycle": 0.792,
|
| 41 |
-
"truck": 0.944954128440367,
|
| 42 |
-
"van": 0.0
|
| 43 |
-
},
|
| 44 |
-
"per_class_recall": {
|
| 45 |
-
"bus": 0.9264705882352942,
|
| 46 |
-
"car": 0.7659137577002053,
|
| 47 |
-
"motorcycle": 0.673469387755102,
|
| 48 |
-
"truck": 0.7006802721088435,
|
| 49 |
-
"van": 0.0
|
| 50 |
-
},
|
| 51 |
-
"adaptive_map_50": 0.7846899619936487,
|
| 52 |
-
"ffpi": 0.4835164835164835,
|
| 53 |
-
"false_positive_score": 0.9516483516483516,
|
| 54 |
-
"foundry_score": 0.8514733178555298,
|
| 55 |
-
"composite_score": 0.8514733178555298,
|
| 56 |
-
"scoring_policy": "subnet-style-composite-v1",
|
| 57 |
-
"matched_images": 91,
|
| 58 |
-
"gt_count": 1336,
|
| 59 |
-
"pred_count": 1082,
|
| 60 |
-
"classes": [
|
| 61 |
-
"car",
|
| 62 |
-
"bus",
|
| 63 |
-
"truck",
|
| 64 |
-
"motorcycle",
|
| 65 |
-
"van"
|
| 66 |
-
],
|
| 67 |
-
"evaluated_element_revision": null,
|
| 68 |
-
"dataset_id": "7f5bf8d2-bf7a-4ecc-9d2f-b1071588f225",
|
| 69 |
-
"dataset_version_id": "bfb9a039-8a71-4ab5-9097-117d87572930",
|
| 70 |
-
"run_id": "bfb9a039-8a71-4ab5-9097-117d87572930",
|
| 71 |
-
"split_ref": "private_final",
|
| 72 |
-
"selected_frame_count": 91,
|
| 73 |
-
"selected_frame_indices": [
|
| 74 |
-
4,
|
| 75 |
-
8,
|
| 76 |
-
9,
|
| 77 |
-
12,
|
| 78 |
-
18,
|
| 79 |
-
22,
|
| 80 |
-
23,
|
| 81 |
-
26,
|
| 82 |
-
33,
|
| 83 |
-
34,
|
| 84 |
-
40,
|
| 85 |
-
49,
|
| 86 |
-
50,
|
| 87 |
-
62,
|
| 88 |
-
63,
|
| 89 |
-
68,
|
| 90 |
-
74,
|
| 91 |
-
76,
|
| 92 |
-
77,
|
| 93 |
-
89,
|
| 94 |
-
96,
|
| 95 |
-
98,
|
| 96 |
-
99,
|
| 97 |
-
100,
|
| 98 |
-
103,
|
| 99 |
-
105,
|
| 100 |
-
106,
|
| 101 |
-
113,
|
| 102 |
-
125,
|
| 103 |
-
128,
|
| 104 |
-
130,
|
| 105 |
-
137,
|
| 106 |
-
141,
|
| 107 |
-
144,
|
| 108 |
-
146,
|
| 109 |
-
148,
|
| 110 |
-
149,
|
| 111 |
-
154,
|
| 112 |
-
155,
|
| 113 |
-
156,
|
| 114 |
-
161,
|
| 115 |
-
164,
|
| 116 |
-
167,
|
| 117 |
-
169,
|
| 118 |
-
177,
|
| 119 |
-
184,
|
| 120 |
-
187,
|
| 121 |
-
193,
|
| 122 |
-
194,
|
| 123 |
-
201,
|
| 124 |
-
202,
|
| 125 |
-
204,
|
| 126 |
-
209,
|
| 127 |
-
217,
|
| 128 |
-
225,
|
| 129 |
-
227,
|
| 130 |
-
228,
|
| 131 |
-
231,
|
| 132 |
-
234,
|
| 133 |
-
237,
|
| 134 |
-
240,
|
| 135 |
-
243,
|
| 136 |
-
246,
|
| 137 |
-
249,
|
| 138 |
-
252,
|
| 139 |
-
255,
|
| 140 |
-
256,
|
| 141 |
-
259,
|
| 142 |
-
261,
|
| 143 |
-
264,
|
| 144 |
-
266,
|
| 145 |
-
277,
|
| 146 |
-
288,
|
| 147 |
-
290,
|
| 148 |
-
315,
|
| 149 |
-
318,
|
| 150 |
-
319,
|
| 151 |
-
325,
|
| 152 |
-
329,
|
| 153 |
-
340,
|
| 154 |
-
342,
|
| 155 |
-
344,
|
| 156 |
-
347,
|
| 157 |
-
356,
|
| 158 |
-
365,
|
| 159 |
-
374,
|
| 160 |
-
380,
|
| 161 |
-
387,
|
| 162 |
-
389,
|
| 163 |
-
393,
|
| 164 |
-
403
|
| 165 |
-
],
|
| 166 |
-
"evaluated_version_ids": [
|
| 167 |
-
"bfb9a039-8a71-4ab5-9097-117d87572930"
|
| 168 |
-
],
|
| 169 |
-
"skipped_missing_pairs": 0
|
| 170 |
-
}
|
| 171 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
benchmark/synthetic/index.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
| 1 |
-
[
|
| 2 |
-
{
|
| 3 |
-
"run_id": "bfb9a039-8a71-4ab5-9097-117d87572930",
|
| 4 |
-
"saved_at": "2026-10-26T08:39:39.426218Z",
|
| 5 |
-
"result_path": "benchmark/synthetic/bfb9a039-8a71-4ab5-9097-117d87572930.json",
|
| 6 |
-
"overall_iou": 0.711301418417662,
|
| 7 |
-
"map_50": 0.7555753708996942,
|
| 8 |
-
"map_50_90": 0.579080216734731,
|
| 9 |
-
"precision": 0.9343807763401109,
|
| 10 |
-
"recall": 0.7567365269461078,
|
| 11 |
-
"matched_images": 91,
|
| 12 |
-
"gt_count": 1336,
|
| 13 |
-
"pred_count": 1082,
|
| 14 |
-
"split_ref": "private_final"
|
| 15 |
-
}
|
| 16 |
-
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
benchmark/synthetic/latest.json
DELETED
|
@@ -1,171 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"meta": {
|
| 3 |
-
"element_id": "manako/Detect-Vehicle-winner",
|
| 4 |
-
"run_id": "bfb9a039-8a71-4ab5-9097-117d87572930",
|
| 5 |
-
"benchmark_type": "synthetic_fixed",
|
| 6 |
-
"saved_at": "2026-10-26T08:39:39.426218Z",
|
| 7 |
-
"result_path": "benchmark/synthetic/bfb9a039-8a71-4ab5-9097-117d87572930.json",
|
| 8 |
-
"split_ref": "private_final"
|
| 9 |
-
},
|
| 10 |
-
"results": {
|
| 11 |
-
"overall_iou": 0.711301418417662,
|
| 12 |
-
"per_class_iou": {
|
| 13 |
-
"car": 0.7070302145582933,
|
| 14 |
-
"bus": 0.5482735465755711,
|
| 15 |
-
"truck": 0.5751458422637304,
|
| 16 |
-
"motorcycle": 0.5297182473130839,
|
| 17 |
-
"van": 0.0
|
| 18 |
-
},
|
| 19 |
-
"map_50": 0.7555753708996942,
|
| 20 |
-
"map_50_90": 0.579080216734731,
|
| 21 |
-
"precision": 0.9343807763401109,
|
| 22 |
-
"recall": 0.7567365269461078,
|
| 23 |
-
"per_class_map_50": {
|
| 24 |
-
"bus": 0.9262408088235294,
|
| 25 |
-
"car": 0.7609370193011648,
|
| 26 |
-
"motorcycle": 0.6351600115463183,
|
| 27 |
-
"truck": 0.6999636439277644,
|
| 28 |
-
"van": 0.0
|
| 29 |
-
},
|
| 30 |
-
"per_class_map_50_90": {
|
| 31 |
-
"bus": 0.8002013873465061,
|
| 32 |
-
"car": 0.5558016885440995,
|
| 33 |
-
"motorcycle": 0.3591731876237153,
|
| 34 |
-
"truck": 0.6011446034246029,
|
| 35 |
-
"van": 0.0
|
| 36 |
-
},
|
| 37 |
-
"per_class_precision": {
|
| 38 |
-
"bus": 0.984375,
|
| 39 |
-
"car": 0.951530612244898,
|
| 40 |
-
"motorcycle": 0.792,
|
| 41 |
-
"truck": 0.944954128440367,
|
| 42 |
-
"van": 0.0
|
| 43 |
-
},
|
| 44 |
-
"per_class_recall": {
|
| 45 |
-
"bus": 0.9264705882352942,
|
| 46 |
-
"car": 0.7659137577002053,
|
| 47 |
-
"motorcycle": 0.673469387755102,
|
| 48 |
-
"truck": 0.7006802721088435,
|
| 49 |
-
"van": 0.0
|
| 50 |
-
},
|
| 51 |
-
"adaptive_map_50": 0.7846899619936487,
|
| 52 |
-
"ffpi": 0.4835164835164835,
|
| 53 |
-
"false_positive_score": 0.9516483516483516,
|
| 54 |
-
"foundry_score": 0.8514733178555298,
|
| 55 |
-
"composite_score": 0.8514733178555298,
|
| 56 |
-
"scoring_policy": "subnet-style-composite-v1",
|
| 57 |
-
"matched_images": 91,
|
| 58 |
-
"gt_count": 1336,
|
| 59 |
-
"pred_count": 1082,
|
| 60 |
-
"classes": [
|
| 61 |
-
"car",
|
| 62 |
-
"bus",
|
| 63 |
-
"truck",
|
| 64 |
-
"motorcycle",
|
| 65 |
-
"van"
|
| 66 |
-
],
|
| 67 |
-
"evaluated_element_revision": null,
|
| 68 |
-
"dataset_id": "7f5bf8d2-bf7a-4ecc-9d2f-b1071588f225",
|
| 69 |
-
"dataset_version_id": "bfb9a039-8a71-4ab5-9097-117d87572930",
|
| 70 |
-
"run_id": "bfb9a039-8a71-4ab5-9097-117d87572930",
|
| 71 |
-
"split_ref": "private_final",
|
| 72 |
-
"selected_frame_count": 91,
|
| 73 |
-
"selected_frame_indices": [
|
| 74 |
-
4,
|
| 75 |
-
8,
|
| 76 |
-
9,
|
| 77 |
-
12,
|
| 78 |
-
18,
|
| 79 |
-
22,
|
| 80 |
-
23,
|
| 81 |
-
26,
|
| 82 |
-
33,
|
| 83 |
-
34,
|
| 84 |
-
40,
|
| 85 |
-
49,
|
| 86 |
-
50,
|
| 87 |
-
62,
|
| 88 |
-
63,
|
| 89 |
-
68,
|
| 90 |
-
74,
|
| 91 |
-
76,
|
| 92 |
-
77,
|
| 93 |
-
89,
|
| 94 |
-
96,
|
| 95 |
-
98,
|
| 96 |
-
99,
|
| 97 |
-
100,
|
| 98 |
-
103,
|
| 99 |
-
105,
|
| 100 |
-
106,
|
| 101 |
-
113,
|
| 102 |
-
125,
|
| 103 |
-
128,
|
| 104 |
-
130,
|
| 105 |
-
137,
|
| 106 |
-
141,
|
| 107 |
-
144,
|
| 108 |
-
146,
|
| 109 |
-
148,
|
| 110 |
-
149,
|
| 111 |
-
154,
|
| 112 |
-
155,
|
| 113 |
-
156,
|
| 114 |
-
161,
|
| 115 |
-
164,
|
| 116 |
-
167,
|
| 117 |
-
169,
|
| 118 |
-
177,
|
| 119 |
-
184,
|
| 120 |
-
187,
|
| 121 |
-
193,
|
| 122 |
-
194,
|
| 123 |
-
201,
|
| 124 |
-
202,
|
| 125 |
-
204,
|
| 126 |
-
209,
|
| 127 |
-
217,
|
| 128 |
-
225,
|
| 129 |
-
227,
|
| 130 |
-
228,
|
| 131 |
-
231,
|
| 132 |
-
234,
|
| 133 |
-
237,
|
| 134 |
-
240,
|
| 135 |
-
243,
|
| 136 |
-
246,
|
| 137 |
-
249,
|
| 138 |
-
252,
|
| 139 |
-
255,
|
| 140 |
-
256,
|
| 141 |
-
259,
|
| 142 |
-
261,
|
| 143 |
-
264,
|
| 144 |
-
266,
|
| 145 |
-
277,
|
| 146 |
-
288,
|
| 147 |
-
290,
|
| 148 |
-
315,
|
| 149 |
-
318,
|
| 150 |
-
319,
|
| 151 |
-
325,
|
| 152 |
-
329,
|
| 153 |
-
340,
|
| 154 |
-
342,
|
| 155 |
-
344,
|
| 156 |
-
347,
|
| 157 |
-
356,
|
| 158 |
-
365,
|
| 159 |
-
374,
|
| 160 |
-
380,
|
| 161 |
-
387,
|
| 162 |
-
389,
|
| 163 |
-
393,
|
| 164 |
-
403
|
| 165 |
-
],
|
| 166 |
-
"evaluated_version_ids": [
|
| 167 |
-
"bfb9a039-8a71-4ab5-9097-117d87572930"
|
| 168 |
-
],
|
| 169 |
-
"skipped_missing_pairs": 0
|
| 170 |
-
}
|
| 171 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
main.py
CHANGED
|
@@ -146,16 +146,32 @@ def _to_detection(box: Any, class_names: list[str]) -> dict[str, Any]:
|
|
| 146 |
return detection
|
| 147 |
|
| 148 |
|
| 149 |
-
def
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
return image
|
| 160 |
|
| 161 |
|
|
@@ -171,14 +187,34 @@ def load_model(onnx_path: str | None = None, data_dir: str | None = None):
|
|
| 171 |
}
|
| 172 |
|
| 173 |
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
|
| 178 |
|
| 179 |
-
def
|
| 180 |
-
|
| 181 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
|
| 183 |
|
| 184 |
def run_model(model: Any, image: Any = None, onnx_path: str | None = None, data_dir: str | None = None):
|
|
@@ -190,7 +226,7 @@ def run_model(model: Any, image: Any = None, onnx_path: str | None = None, data_
|
|
| 190 |
class_names = model.get("class_names")
|
| 191 |
if not isinstance(class_names, list):
|
| 192 |
class_names = list(CLASS_NAMES)
|
| 193 |
-
results =
|
| 194 |
if not results:
|
| 195 |
return [[]]
|
| 196 |
frame_boxes = _extract_boxes(results[0])
|
|
|
|
| 146 |
return detection
|
| 147 |
|
| 148 |
|
| 149 |
+
def _normalize_image_for_miner(image: Any) -> Any:
|
| 150 |
+
if image is None or hasattr(image, "shape"):
|
| 151 |
+
return image
|
| 152 |
+
if isinstance(image, (bytes, bytearray, memoryview)):
|
| 153 |
+
try:
|
| 154 |
+
buffer = np.frombuffer(bytes(image), dtype=np.uint8)
|
| 155 |
+
decoded = cv2.imdecode(buffer, cv2.IMREAD_COLOR)
|
| 156 |
+
if decoded is not None:
|
| 157 |
+
return decoded
|
| 158 |
+
except Exception:
|
| 159 |
+
return image
|
| 160 |
+
if hasattr(image, "convert") and callable(image.convert):
|
| 161 |
+
try:
|
| 162 |
+
rgb = image.convert("RGB")
|
| 163 |
+
array = np.array(rgb)
|
| 164 |
+
if getattr(array, "ndim", 0) == 3 and array.shape[-1] == 3:
|
| 165 |
+
return cv2.cvtColor(array, cv2.COLOR_RGB2BGR)
|
| 166 |
+
return array
|
| 167 |
+
except Exception:
|
| 168 |
+
return image
|
| 169 |
+
try:
|
| 170 |
+
array = np.asarray(image)
|
| 171 |
+
if getattr(array, "shape", None):
|
| 172 |
+
return array
|
| 173 |
+
except Exception:
|
| 174 |
+
return image
|
| 175 |
return image
|
| 176 |
|
| 177 |
|
|
|
|
| 187 |
}
|
| 188 |
|
| 189 |
|
| 190 |
+
def _candidate_keypoint_counts(miner: Any) -> list[int]:
|
| 191 |
+
counts: list[int] = [0]
|
| 192 |
+
for attr in ("n_keypoints", "num_keypoints", "keypoint_count", "num_joints"):
|
| 193 |
+
value = getattr(miner, attr, None)
|
| 194 |
+
if isinstance(value, int) and value > 0:
|
| 195 |
+
counts.append(value)
|
| 196 |
+
counts.append(32)
|
| 197 |
+
|
| 198 |
+
seen: set[int] = set()
|
| 199 |
+
ordered: list[int] = []
|
| 200 |
+
for count in counts:
|
| 201 |
+
if count in seen:
|
| 202 |
+
continue
|
| 203 |
+
seen.add(count)
|
| 204 |
+
ordered.append(count)
|
| 205 |
+
return ordered
|
| 206 |
|
| 207 |
|
| 208 |
+
def _predict_batch_with_fallbacks(miner: Any, image: Any) -> list[Any]:
|
| 209 |
+
normalized_image = _normalize_image_for_miner(image)
|
| 210 |
+
errors: list[str] = []
|
| 211 |
+
for n_keypoints in _candidate_keypoint_counts(miner):
|
| 212 |
+
try:
|
| 213 |
+
return miner.predict_batch([normalized_image], offset=0, n_keypoints=n_keypoints)
|
| 214 |
+
except Exception as exc:
|
| 215 |
+
errors.append(f"n_keypoints={n_keypoints} -> {exc}")
|
| 216 |
+
continue
|
| 217 |
+
raise RuntimeError("predict_batch failed for all keypoint candidates: " + " | ".join(errors))
|
| 218 |
|
| 219 |
|
| 220 |
def run_model(model: Any, image: Any = None, onnx_path: str | None = None, data_dir: str | None = None):
|
|
|
|
| 226 |
class_names = model.get("class_names")
|
| 227 |
if not isinstance(class_names, list):
|
| 228 |
class_names = list(CLASS_NAMES)
|
| 229 |
+
results = _predict_batch_with_fallbacks(miner, image)
|
| 230 |
if not results:
|
| 231 |
return [[]]
|
| 232 |
frame_boxes = _extract_boxes(results[0])
|
pyproject.toml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
[project]
|
| 2 |
name = "miner-element-adapter"
|
| 3 |
version = "0.1.0"
|
| 4 |
-
requires-python = ">=3.
|
| 5 |
|
| 6 |
dependencies = [
|
| 7 |
"numpy>=1.23",
|
|
|
|
| 1 |
[project]
|
| 2 |
name = "miner-element-adapter"
|
| 3 |
version = "0.1.0"
|
| 4 |
+
requires-python = ">=3.9"
|
| 5 |
|
| 6 |
dependencies = [
|
| 7 |
"numpy>=1.23",
|