def run(self): print 'BlobFetcher started' while True: db_inds = self._get_next_minibatch_inds() minibatch_db = [self._roidb[i] for i in db_inds] blobs = get_minibatch(minibatch_db, self._num_classes) self._queue.put(blobs)
def run(self): print 'BlobFetcher started' while True: db_inds = self._get_next_minibatch_inds() minibatch_db = [self._roidb[i] for i in db_inds] blobs = get_minibatch(minibatch_db) self._queue.put(blobs)
def predict(): #imdb, roidb = combined_roidb('voc_2007_trainval') imdb, roidb = combined_roidb('voc_2007_test', is_training=False) print imdb.classes #from data_layer.layer import RoIDataLayer #data_layer = RoIDataLayer(roidb, imdb.num_classes) #for _ in range(10): # blobs = data_layer.forward() # print blobs sv = Predict(imdb.num_classes) ids=0 for roi in roidb: print "=====================================================================" print roi blobs=get_minibatch([roi], imdb.num_classes) image = blobs['data'] gt_boxes = blobs['gt_boxes'] im_info = blobs['im_info'] clss_score, clss_bbox = sv.predict(image, im_info) for i,(score, bbox) in enumerate(zip(clss_score, clss_bbox)): if len(score)>0: print ("class:",i+1, imdb.classes[i+1]) print "score:",score print "bbox:",bbox ids+=1 if ids > 10: break
def __getitem__(self, item): minibatch_db = [self.roidb[item]] blobs = get_minibatch(minibatch_db, self.num_classes) data = blobs['data'] im_info = blobs['im_info'] if self.training: gt_boxes = blobs['gt_boxes'] else: gt_boxes = torch.FloatTensor([0, 0, 0, 0, 0]) return data[0].transpose(2, 0, 1), im_info.reshape([3]), gt_boxes
def _get_next_minibatch(self): """Return the blobs to be used for the next minibatch. If cfg.TRAIN.USE_PREFETCH is True, then blobs will be computed in a separate process and made available through self._blob_queue. """ if cfg.TRAIN.USE_PREFETCH: return self._blob_queue.get() else: db_inds = self._get_next_minibatch_inds() minibatch_db = [self._roidb[i] for i in db_inds] return get_minibatch(minibatch_db)
def _get_next_minibatch(self): """Return the blobs to be used for the next minibatch. If cfg.TRAIN.USE_PREFETCH is True, then blobs will be computed in a separate process and made available through self._blob_queue. """ if cfg.TRAIN.USE_PREFETCH: return self._blob_queue.get() else: db_inds = self._get_next_minibatch_inds() minibatch_db = [self._roidb[i] for i in db_inds] return get_minibatch(minibatch_db, self._num_classes)
def run(self): print 'BlobFetcher started' while True: minibatch_inds = self._get_next_minibatch_inds() minibatch_img_paths = \ [self._db.get_img_path(self._db.train_ind[ i if i < len(self._db.train_ind) else i - len(self._db.train_ind)]) for i in minibatch_inds] minibatch_labels = \ [self._db.labels[self._db.train_ind[ i if i < len(self._db.train_ind) else i - len(self._db.train_ind)]] for i in minibatch_inds] minibatch_flip = \ [0 if i < len(self._db.train_ind) else 1 for i in minibatch_inds] blobs = get_minibatch(minibatch_img_paths, minibatch_labels, minibatch_flip, self._db.flip_attr_pairs, self._weight) self._queue.put(blobs)
def run(self): print 'BlobFetcher started' while True: minibatch_inds, img_ratio = self._get_next_minibatch_inds() if len(minibatch_inds) < cfg.TRAIN.BATCH_SIZE: continue #print "The ratio of this blob is: %d" % img_ratio #print "Size of minibatch %d" % len(minibatch_inds) #print minibatch_inds #print minibatch_img_paths = \ [self._db.get_img_path(self._db.train_ind[i]) for i in minibatch_inds] minibatch_labels = \ [self._db.labels[self._db.train_ind[i]] for i in minibatch_inds] minibatch_flip = \ np.random.random_integers(0, 1, len(minibatch_inds)) blobs = get_minibatch(minibatch_img_paths, minibatch_labels, minibatch_flip, self._db.flip_attr_pairs, self._weight, img_ratio) self._queue.put(blobs)
def _get_next_minibatch(self): db_inds = self._get_next_minibatch_inds() minibatch_db = [self._roidb[i] for i in db_inds] return get_minibatch(minibatch_db, self._num_classes)
def _get_next_minibatch(self): db_inds = self._get_next_minibatch_inds() # minibatch_db = [self._db[i] for i in db_inds] return get_minibatch(self._db, db_inds, self._labels)