Giter VIP home page Giter VIP logo

Comments (2)

zhang-tao-whu avatar zhang-tao-whu commented on August 15, 2024

Everything is normal. You have finished fine-tuning the Segmenter, and you can now use this weight for subsequent online and offline DVIS training. Currently, CTVIS and MinVIS only support VIS inference. They are only used to provide pre-trained Segmenter for DVIS. Evaluation of VSS and VPS can only be conducted when running DVIS online or offline.

from dvis_plus.

egeozsoy avatar egeozsoy commented on August 15, 2024

Thanks for the response!

In the meanwhile I found a rough way to adapt the vps_eval.py process function to allow evaluating segmentation models directly without needing to train DVIS on top of it. This is useful if one wants to judge the quality of this segmentation model before starting the additional training on top. I am posting it here for future reference.

  def process(self, inputs, outputs):
      """
      save panoptic segmentation result as an image
      """
      assert len(inputs) == 1, "More than one inputs are loaded for inference!"
      color_generator = IdGenerator(self._metadata.categories)

      # visualization of only panoptic segmentation results like this
      if 'segments_infos' not in outputs:
          mask_pred = torch.stack(outputs['pred_masks']).float()
          labels = torch.asarray(outputs['pred_labels'])
          scores = torch.asarray(outputs['pred_scores'])
          # filter out the background prediction
          keep = labels.ne(124) & (scores > 0.8)
          cur_scores = scores[keep]
          cur_classes = labels[keep]
          cur_masks = mask_pred[keep]
          # interpolation to original image size
          cur_masks = F.interpolate(
              cur_masks, size=(736, 1280), mode="bilinear", align_corners=False
          )
          cur_masks = cur_masks[:, :, :720, :1280].sigmoid()
          cur_masks = F.interpolate(
              cur_masks, size=(720, 1280), mode="bilinear", align_corners=False
          )
          cur_prob_masks = cur_scores.view(-1, 1, 1, 1).to(cur_masks.device) * cur_masks

          # initial panoptic_seg and segments infos
          h, w = cur_masks.shape[-2:]
          panoptic_seg = torch.zeros((cur_masks.size(1), h, w), dtype=torch.int32, device=cur_masks.device)
          segments_infos = []
          out_ids = []
          current_segment_id = 0

          if cur_masks.shape[0] == 0:
              # We didn't detect any mask
              outputs = {
                  "image_size": (720, 1280),
                  "pred_masks": panoptic_seg.cpu(),
                  "segments_infos": segments_infos,
                  "pred_ids": out_ids,
                  "task": "vps",
              }
          else:
              # take argmax
              cur_mask_ids = cur_prob_masks.argmax(0)  # (t, h, w)
              stuff_memory_list = {}
              for k in range(cur_classes.shape[0]):
                  pred_class = cur_classes[k].item()
                  isthing = pred_class < 58
                  # filter out the unstable segmentation results
                  mask_area = (cur_mask_ids == k).sum().item()
                  original_area = (cur_masks[k] >= 0.5).sum().item()
                  mask = (cur_mask_ids == k) & (cur_masks[k] >= 0.5)
                  if mask_area > 0 and original_area > 0 and mask.sum().item() > 0:
                      if mask_area / original_area < 0.01:  # 0.8:
                          continue
                      # merge stuff regions
                      if not isthing:
                          if int(pred_class) in stuff_memory_list.keys():
                              panoptic_seg[mask] = stuff_memory_list[int(pred_class)]
                              continue
                          else:
                              stuff_memory_list[int(pred_class)] = current_segment_id + 1
                      current_segment_id += 1
                      panoptic_seg[mask] = current_segment_id

                      segments_infos.append(
                          {
                              "id": current_segment_id,
                              "isthing": bool(isthing),
                              "category_id": int(pred_class),
                          }
                      )

              outputs = {
                  "image_size": (720, 1280),
                  "pred_masks": panoptic_seg.cpu(),
                  "segments_infos": segments_infos,
                  "pred_ids": out_ids,
                  "task": "vps",
              }

      video_id = inputs[0]["video_id"]
      image_names = [inputs[0]['file_names'][idx] for idx in inputs[0]["frame_idx"]]
      img_shape = outputs['image_size']
      pan_seg_result = outputs['pred_masks']
      segments_infos = outputs['segments_infos']
      segments_infos_ = []
     ...Rest of the code....

from dvis_plus.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.