@@ -2010,6 +2010,7 @@ namespace dd
20102010 {
20112011 APIData ad_res;
20122012 APIData ad_bbox;
2013+ APIData ad_res_bbox;
20132014 APIData ad_out = ad.getobj (" parameters" ).getobj (" output" );
20142015 int nclasses = _masked_lm ? inputc.vocab_size () : _nclasses;
20152016
@@ -2155,6 +2156,59 @@ namespace dd
21552156 ad_bbox_per_iou[iou_thres].add (std::to_string (entry_id),
21562157 vbad);
21572158 }
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);
21582212 ++entry_id;
21592213 }
21602214 }
@@ -2336,12 +2390,17 @@ namespace dd
23362390 ad_bbox_per_iou[iou_thres]);
23372391 }
23382392 ad_res.add (" 0" , ad_bbox);
2393+ // raw bbox results
2394+ ad_res.add (" raw_bboxes" , ad_res_bbox);
23392395 }
23402396 else if (_segmentation)
23412397 ad_res.add (" segmentation" , true );
23422398 ad_res.add (" batch_size" ,
23432399 entry_id); // here batch_size = tested entries count
23442400 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);
23452404 _module.train ();
23462405 return 0 ;
23472406 }
0 commit comments