docstr: test method. wrapper around forward pass of network without usage of any ground truth information.
  prepares input data for processing and stores outputs in a dictionary.
  :param batch: dictionary containing 'data'
  :param kwargs:
  :return: results_dict: dictionary with keys:
         'boxes': list over batch elements. each batch element is a list of boxes. each box is a dictionary:
                 [[{box_0}, ... {box_n}], [{box_0}, ... {box_n}], ...]
         'seg_preds': pixel-wise class predictions (b, 1, y, x, (z)) with values [0, n_classes]
docstr_tok: ["test","method",".","wrapper","around","forward","pass","of","network","without","usage","of","any","ground","truth","information",".","prepares","input","data","for","processing","and","stores","outputs","in","a","dictionary",".",":","param","batch",":","dictionary","containing","'data'",":","param","kwargs",":",":","return",":","results_dict",":","dictionary","with","keys",":","'boxes","'",":","list","over","batch","elements",".","each","batch","element","is","a","list","of","boxes",".","each","box","is","a","dictionary",":","[","[","{","box_0","}",",","...","{","box_n","}","]",",","[","{","box_0","}",",","...","{","box_n","}","]",",","...","]","'seg_preds","'",":","pixel-wise","class","predictions","(","b",",","1",",","y",",","x",",","(","z",")",")","with","values","[","0",",","n_classes","]"]
code: def test_forward(self, batch, **kwargs):
      """
      test method. wrapper around forward pass of network without usage of any ground truth information.
      prepares input data for processing and stores outputs in a dictionary.
      :param batch: dictionary containing 'data'
      :param kwargs:
      :return: results_dict: dictionary with keys:
             'boxes': list over batch elements. each batch element is a list of boxes. each box is a dictionary:
                     [[{box_0}, ... {box_n}], [{box_0}, ... {box_n}], ...]
             'seg_preds': pixel-wise class predictions (b, 1, y, x, (z)) with values [0, n_classes]
      """
      img = batch["data"]
      var_img = torch.FloatTensor(img).cuda()
      seg_logits, box_coords, max_scores = self.forward(var_img)
  
      results_dict = {}
      results_dict["boxes"] = [[] for _ in range(img.shape[0])]
      for cix in range(len(self.cf.class_dict.keys())):
          for bix in range(img.shape[0]):
              for rix in range(len(max_scores[cix][bix])):
                  if (
                      max_scores[cix][bix][rix]
                      > self.cf.detection_min_confidence
                  ):
                      results_dict["boxes"][bix].append(
                          {
                              "box_coords": np.copy(
                                  box_coords[cix][bix][rix]
                              ),
                              "box_score": max_scores[cix][bix][rix],
                              "box_pred_class_id": cix
                              + 1,  # add 0 for background.
                              "box_type": "det",
                          }
                      )
  
      results_dict["seg_preds"] = np.argmax(
          F.softmax(seg_logits, 1).cpu().data.numpy(), 1
      )[:, np.newaxis].astype("uint8")
      return results_dict
  
file_path: medicaldetectiontoolkit/models/detection_unet.py
imports: import torch
  import torch.nn
  import torch.nn.functional
  from scipy.ndimage.measurements import label
  import numpy
  import utils.exp_utils
  import utils.model_utils
label_desc: Use image node_id 4 for calling the net obj's underlying member method code with example usage: obj.test_forward(batch) and returns: results_dict