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