@@ -2010,6 +2010,7 @@ namespace dd
2010
2010
{
2011
2011
APIData ad_res;
2012
2012
APIData ad_bbox;
2013
+ APIData ad_res_bbox;
2013
2014
APIData ad_out = ad.getobj (" parameters" ).getobj (" output" );
2014
2015
int nclasses = _masked_lm ? inputc.vocab_size () : _nclasses;
2015
2016
@@ -2155,6 +2156,59 @@ namespace dd
2155
2156
ad_bbox_per_iou[iou_thres].add (std::to_string (entry_id),
2156
2157
vbad);
2157
2158
}
2159
+
2160
+ // Raw results
2161
+ APIData bad;
2162
+ // predictions
2163
+ auto bboxes_acc = bboxes_tensor.accessor <float , 2 >();
2164
+ auto labels_acc = labels_tensor.accessor <int64_t , 1 >();
2165
+ auto score_acc = score_tensor.accessor <float , 1 >();
2166
+ std::vector<APIData> pred_vad;
2167
+
2168
+ for (int k = 0 ; k < labels_tensor.size (0 ); k++)
2169
+ {
2170
+ APIData pred_ad;
2171
+ pred_ad.add (" label" , labels_acc[k]);
2172
+ pred_ad.add (" prob" , static_cast <double >(score_acc[k]));
2173
+ APIData bbox_ad;
2174
+ bbox_ad.add (" xmin" , static_cast <double >(bboxes_acc[k][0 ]));
2175
+ bbox_ad.add (" ymin" , static_cast <double >(bboxes_acc[k][1 ]));
2176
+ bbox_ad.add (" xmax" , static_cast <double >(bboxes_acc[k][2 ]));
2177
+ bbox_ad.add (" ymax" , static_cast <double >(bboxes_acc[k][3 ]));
2178
+ pred_ad.add (" bbox" , bbox_ad);
2179
+ pred_vad.push_back (pred_ad);
2180
+ }
2181
+ bad.add (" predictions" , pred_vad);
2182
+ // targets
2183
+ auto targ_bboxes_acc = targ_bboxes.accessor <float , 2 >();
2184
+ auto targ_labels_acc = targ_labels.accessor <int64_t , 1 >();
2185
+ std::vector<APIData> targ_vad;
2186
+
2187
+ for (int k = start; k < stop; k++)
2188
+ {
2189
+ APIData targ_ad;
2190
+ targ_ad.add (" label" , targ_labels_acc[k]);
2191
+ APIData bbox_ad;
2192
+ bbox_ad.add (" xmin" ,
2193
+ static_cast <double >(targ_bboxes_acc[k][0 ]));
2194
+ bbox_ad.add (" ymin" ,
2195
+ static_cast <double >(targ_bboxes_acc[k][1 ]));
2196
+ bbox_ad.add (" xmax" ,
2197
+ static_cast <double >(targ_bboxes_acc[k][2 ]));
2198
+ bbox_ad.add (" ymax" ,
2199
+ static_cast <double >(targ_bboxes_acc[k][3 ]));
2200
+ targ_ad.add (" bbox" , bbox_ad);
2201
+ targ_vad.push_back (targ_ad);
2202
+ }
2203
+ bad.add (" targets" , targ_vad);
2204
+ // pred image
2205
+ std::vector<cv::Mat> img_vec;
2206
+ img_vec.push_back (torch_utils::tensorToImage (
2207
+ batch.data .at (0 ).index (
2208
+ { torch::indexing::Slice (i, i + 1 ) }),
2209
+ /* rgb = */ true ));
2210
+ bad.add (" image" , img_vec);
2211
+ ad_res_bbox.add (std::to_string (entry_id), bad);
2158
2212
++entry_id;
2159
2213
}
2160
2214
}
@@ -2336,12 +2390,17 @@ namespace dd
2336
2390
ad_bbox_per_iou[iou_thres]);
2337
2391
}
2338
2392
ad_res.add (" 0" , ad_bbox);
2393
+ // raw bbox results
2394
+ ad_res.add (" raw_bboxes" , ad_res_bbox);
2339
2395
}
2340
2396
else if (_segmentation)
2341
2397
ad_res.add (" segmentation" , true );
2342
2398
ad_res.add (" batch_size" ,
2343
2399
entry_id); // here batch_size = tested entries count
2344
2400
SupervisedOutput::measure (ad_res, ad_out, out, test_id, test_name);
2401
+ SupervisedOutput::create_visuals (
2402
+ ad_res, ad_out, this ->_mlmodel ._repo + this ->_mlmodel ._visuals_dir ,
2403
+ test_id);
2345
2404
_module.train ();
2346
2405
return 0 ;
2347
2406
}
0 commit comments