@@ -2014,6 +2014,7 @@ namespace dd
20142014 {
20152015 APIData ad_res;
20162016 APIData ad_bbox;
2017+ APIData ad_res_bbox;
20172018 APIData ad_out = ad.getobj (" parameters" ).getobj (" output" );
20182019 int nclasses = _masked_lm ? inputc.vocab_size () : _nclasses;
20192020
@@ -2159,6 +2160,59 @@ namespace dd
21592160 ad_bbox_per_iou[iou_thres].add (std::to_string (entry_id),
21602161 vbad);
21612162 }
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);
21622216 ++entry_id;
21632217 }
21642218 }
@@ -2340,12 +2394,17 @@ namespace dd
23402394 ad_bbox_per_iou[iou_thres]);
23412395 }
23422396 ad_res.add (" 0" , ad_bbox);
2397+ // raw bbox results
2398+ ad_res.add (" raw_bboxes" , ad_res_bbox);
23432399 }
23442400 else if (_segmentation)
23452401 ad_res.add (" segmentation" , true );
23462402 ad_res.add (" batch_size" ,
23472403 entry_id); // here batch_size = tested entries count
23482404 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);
23492408 _module.train ();
23502409 return 0 ;
23512410 }
0 commit comments