vasgaowei / pytorch_MELM

The pytorch implementation of the Min-Entropy Latent Model for Weakly Supervised Object Detection
104 stars 19 forks source link

What should I change in your 'network' if I want to test the performance of your model on the other dataset? #9

Open magemoumou opened 5 years ago

magemoumou commented 5 years ago

What should I change in your 'network' if I want to test the performance of your model on the other dataset? I looked through your network.forward() part, the code is as follow:

def forward(self, image, image_level_label ,im_info, gt_boxes=None, ss_boxes=None, mode='TRAIN'):

print('forward ss_boxes ', ss_boxes.shape)

self._image_gt_summaries['image'] = image
self._image_gt_summaries['image_level_label'] = image_level_label
self._image_gt_summaries['gt_boxes'] = gt_boxes
self._image_gt_summaries['im_info'] = im_info
self._image_gt_summaries['ss_boxes'] = ss_boxes

self._image = torch.from_numpy(image.transpose([0,3,1,2]).copy()).to(self._device)
self._image_level_label = torch.from_numpy(image_level_label) if image_level_label is not None else None
self._im_info = im_info # No need to change; actually it can be an list
self._gt_boxes = torch.from_numpy(gt_boxes).to(self._device) if gt_boxes is not None else None

self._mode = mode

rois, cls_prob, det_prob, bbox_pred ,cls_det_prob_product ,det_cls_prob = self._predict(ss_boxes)

bbox_pred = bbox_pred[:,:80]

if mode == 'TEST':
  stds = bbox_pred.data.new(cfg.TRAIN.BBOX_NORMALIZE_STDS).repeat(self._num_classes).unsqueeze(0).expand_as(bbox_pred)
  means = bbox_pred.data.new(cfg.TRAIN.BBOX_NORMALIZE_MEANS).repeat(self._num_classes).unsqueeze(0).expand_as(bbox_pred)
  self._predictions["bbox_pred"] = bbox_pred.mul(stds).add(means)
else:
  self._add_losses() # compute losses

And I want to konw the meaning of the sentence "bbox_pred = bbox_pred[:,:80]". What is the meaning of the number 80 in this sentence? Does it have relationship with the "num_classes"? For example, your model is tested on the dataset pascal voc2007, there are 20 object classes(without the 'background' class) in this dataset. What if my dataset has only 8 object classes without 'background' ?

And expect for this part, is there any module in your code I need to change if I want to test the model on other dataset?

Look forward to your early reply. Thanks for your patience.

vasgaowei commented 5 years ago
  1. My code is based on faster-rcnn. And "bbox_pred" in the faster rcnn code is the regression network's output for each proposal. And a proposal is represented by a tuple (center_x, center_y, w, h), and the bbox_pred is the corresponding deltas, (dx, dy, dw, dh). And for pascal_voc dataset, there are 20 classes, so for a proposal, a bbox_pred should have length of 4 x 20 = 80.
  2. And if you want to test the model on other dataset, I think first should change the dataset's format into the pascal_voc's format. And train the model, and test it.