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() processed_ims = [] labels = [] coords = [] for idx in db_inds: idx = int(idx) try: if self._phase == 'TEST': img, label, coord = minibatch_detector.get_img(idx,self._roidb, self._u_roidb, self._phase) else: img, label, coord = minibatch.get_img(idx, self._roidb, self._u_roidb, self._phase) except: print 'wrong idx:%d' % idx import traceback traceback.print_exc() db_inds.append(self._get_next_ind()) continue processed_ims.append(img) labels.append(label) coords.append(coord) return get_minibatch(processed_ims,labels,coords)
def run(self): print 'BlobFetcher started' while True: db_inds = self._get_next_minibatch_inds() processed_ims = [] labels = [] coords = [] for idx in db_inds: idx = int(idx) try: if self._phase == 'TEST': img, label, coord = minibatch_detector.get_img(idx, self._roidb, self._u_roidb, self._phase) else: img, label, coord = minibatch.get_img(idx, self._roidb, self._u_roidb, self._phase) except: print 'wrong idx:%d' % idx import traceback traceback.print_exc() db_inds.append(self._get_next_ind()) continue processed_ims.append(img) labels.append(label) coords.append(coord) blobs = get_minibatch(processed_ims, labels, coords) self._queue.put(blobs)
def test_net(net, imdb, max_per_image=8, thresh=0.05): """Test a Fast R-CNN network on an image database.""" num_images = len(imdb._image_index) # all detections are collected into: # all_boxes[cls][image] = N x 5 array of detections in # (x1, y1, x2, y2, score) output_dir = get_output_dir(imdb, net) print output_dir for i in xrange(num_images): # imgs, bboxes, coord2, nzhw,name = queue.get() imgs, bboxes, coord2, nzhw = get_img(i, imdb, 'TEST') name = imdb._image_index[i] im_detect(net, name, imgs, bboxes, coord2, nzhw, output_dir)
def run(self): print 'BlobFetcher started' while True: #print('Current process id: {}'.format(os.getpid())) #print('Current affinity: {}'.format(p.cpu_affinity())) db_inds = self._get_next_minibatch_inds() processed_ims = [] labels = [] coords = [] db_inds = db_inds[0:cfg.TRAIN.IMS_PER_BATCH] for idx in db_inds: idx = int(idx) # print idx try: if self._phase == 'TEST': img, label, coord = minibatch_detector.get_img( idx, self._roidb, self._u_roidb, self._phase) else: img, label, coord = minibatch.get_img( idx, self._roidb, self._u_roidb, self._phase) except: print 'wrong idx:%d' % idx import traceback traceback.print_exc() db_inds.append(self._get_next_ind()) continue if type(img) == type(None): db_inds.append(self._get_next_ind()) continue # img = np.ones(img.shape) # label = np.ones(label.shape) # coord = np.ones(coord.shape) processed_ims.append(img) labels.append(label) coords.append(coord) blobs = get_minibatch(processed_ims, labels, coords) self._queue.put(blobs)