当前位置: 首页>>代码示例>>Python>>正文


Python cPickle.HIGHEST_PROTOCOL属性代码示例

本文整理汇总了Python中cPickle.HIGHEST_PROTOCOL属性的典型用法代码示例。如果您正苦于以下问题:Python cPickle.HIGHEST_PROTOCOL属性的具体用法?Python cPickle.HIGHEST_PROTOCOL怎么用?Python cPickle.HIGHEST_PROTOCOL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在模块cPickle的用法示例。

在下文中一共展示了cPickle.HIGHEST_PROTOCOL属性的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: set

# 需要导入模块: import cPickle [as 别名]
# 或者: from cPickle import HIGHEST_PROTOCOL [as 别名]
def set(self, key, value, timeout=None):
        if timeout is None:
            timeout = self.default_timeout
        filename = self._get_filename(key)
        self._prune()
        try:
            fd, tmp = tempfile.mkstemp(suffix=self._fs_transaction_suffix,
                                       dir=self._path)
            f = os.fdopen(fd, 'wb')
            try:
                pickle.dump(int(time() + timeout), f, 1)
                pickle.dump(value, f, pickle.HIGHEST_PROTOCOL)
            finally:
                f.close()
            rename(tmp, filename)
            os.chmod(filename, self._mode)
        except (IOError, OSError):
            pass 
开发者ID:jojoin,项目名称:cutout,代码行数:20,代码来源:filecache.py


示例2: gt_segdb

# 需要导入模块: import cPickle [as 别名]
# 或者: from cPickle import HIGHEST_PROTOCOL [as 别名]
def gt_segdb(self):
        """
        return ground truth image regions database
        :return: imdb[image_index]['', 'flipped']
        """
        print("======== Starting to get gt_segdb ========")
        cache_file = os.path.join(self.cache_path, self.name + '_gt_segdb.pkl')
        if os.path.exists(cache_file):
            with open(cache_file, 'rb') as fid:
                segdb = cPickle.load(fid)
            print '========= {} gt segdb loaded from {}'.format(self.name, cache_file)
            return segdb
        print("======== Starting to create gt_segdb ======")
        gt_segdb = []
        for index in tqdm(self.image_set_index):
            gt_segdb.append(self.load_segdb_from_index(index))

        # gt_segdb = [self.load_segdb_from_index(index) for index in self.image_set_index]
        with open(cache_file, 'wb') as fid:
            cPickle.dump(gt_segdb, fid, cPickle.HIGHEST_PROTOCOL)
        print '========= Wrote gt segdb to {}'.format(cache_file)

        return gt_segdb 
开发者ID:tonysy,项目名称:Deep-Feature-Flow-Segmentation,代码行数:25,代码来源:cityscape_video.py


示例3: gt_roidb

# 需要导入模块: import cPickle [as 别名]
# 或者: from cPickle import HIGHEST_PROTOCOL [as 别名]
def gt_roidb(self):
        """
        return ground truth image regions database
        :return: imdb[image_index]['boxes', 'gt_classes', 'gt_overlaps', 'flipped']
        """
        cache_file = os.path.join(self.cache_path, self.name + '_gt_roidb.pkl')
        if os.path.exists(cache_file):
            with open(cache_file, 'rb') as fid:
                roidb = cPickle.load(fid)
            print '{} gt roidb loaded from {}'.format(self.name, cache_file)
            return roidb

        gt_roidb = [self.load_pascal_annotation(index) for index in self.image_set_index]
        with open(cache_file, 'wb') as fid:
            cPickle.dump(gt_roidb, fid, cPickle.HIGHEST_PROTOCOL)
        print 'wrote gt roidb to {}'.format(cache_file)

        return gt_roidb 
开发者ID:tonysy,项目名称:Deep-Feature-Flow-Segmentation,代码行数:20,代码来源:pascal_voc.py


示例4: gt_segdb

# 需要导入模块: import cPickle [as 别名]
# 或者: from cPickle import HIGHEST_PROTOCOL [as 别名]
def gt_segdb(self):
        """
        return ground truth image regions database
        :return: imdb[image_index]['boxes', 'gt_classes', 'gt_overlaps', 'flipped']
        """
        cache_file = os.path.join(self.cache_path, self.name + '_gt_segdb.pkl')
        if os.path.exists(cache_file):
            with open(cache_file, 'rb') as fid:
                segdb = cPickle.load(fid)
            print '{} gt segdb loaded from {}'.format(self.name, cache_file)
            return segdb

        gt_segdb = [self.load_pascal_segmentation_annotation(index) for index in self.image_set_index]
        with open(cache_file, 'wb') as fid:
            cPickle.dump(gt_segdb, fid, cPickle.HIGHEST_PROTOCOL)
        print 'wrote gt segdb to {}'.format(cache_file)

        return gt_segdb 
开发者ID:tonysy,项目名称:Deep-Feature-Flow-Segmentation,代码行数:20,代码来源:pascal_voc.py


示例5: selective_search_roidb

# 需要导入模块: import cPickle [as 别名]
# 或者: from cPickle import HIGHEST_PROTOCOL [as 别名]
def selective_search_roidb(self, gt_roidb, append_gt=False):
        """
        get selective search roidb and ground truth roidb
        :param gt_roidb: ground truth roidb
        :param append_gt: append ground truth
        :return: roidb of selective search
        """
        cache_file = os.path.join(self.cache_path, self.name + '_ss_roidb.pkl')
        if os.path.exists(cache_file):
            with open(cache_file, 'rb') as fid:
                roidb = cPickle.load(fid)
            print '{} ss roidb loaded from {}'.format(self.name, cache_file)
            return roidb

        if append_gt:
            print 'appending ground truth annotations'
            ss_roidb = self.load_selective_search_roidb(gt_roidb)
            roidb = IMDB.merge_roidbs(gt_roidb, ss_roidb)
        else:
            roidb = self.load_selective_search_roidb(gt_roidb)
        with open(cache_file, 'wb') as fid:
            cPickle.dump(roidb, fid, cPickle.HIGHEST_PROTOCOL)
        print 'wrote ss roidb to {}'.format(cache_file)

        return roidb 
开发者ID:tonysy,项目名称:Deep-Feature-Flow-Segmentation,代码行数:27,代码来源:pascal_voc.py


示例6: gt_segdb

# 需要导入模块: import cPickle [as 别名]
# 或者: from cPickle import HIGHEST_PROTOCOL [as 别名]
def gt_segdb(self):
        """
        return ground truth image regions database
        :return: imdb[image_index]['', 'flipped']
        """
        cache_file = os.path.join(self.cache_path, self.name + '_gt_segdb.pkl')
        if os.path.exists(cache_file):
            with open(cache_file, 'rb') as fid:
                segdb = cPickle.load(fid)
            print '{} gt segdb loaded from {}'.format(self.name, cache_file)
            return segdb

        # gt_segdb = [self.load_segdb_from_index(index) for index in self.image_set_index]
        print("======== Load segmentation ground truth data =======")
        gt_segdb = []
        for index in tqdm(self.image_set_index):
            gt_segdb.append(self.load_segdb_from_index(index))

        with open(cache_file, 'wb') as fid:
            cPickle.dump(gt_segdb, fid, cPickle.HIGHEST_PROTOCOL)
        print 'wrote gt segdb to {}'.format(cache_file)

        return gt_segdb 
开发者ID:tonysy,项目名称:Deep-Feature-Flow-Segmentation,代码行数:25,代码来源:cityscape.py


示例7: gt_roidb

# 需要导入模块: import cPickle [as 别名]
# 或者: from cPickle import HIGHEST_PROTOCOL [as 别名]
def gt_roidb(self):
        """
        Return the database of ground-truth regions of interest.

        This function loads/saves from/to a cache file to speed up future calls.
        """
        cache_file = os.path.join(self.cache_path, self.name + '_gt_roidb.pkl')
        if os.path.exists(cache_file):
            with open(cache_file, 'rb') as fid:
                roidb = cPickle.load(fid)
            print '{} gt roidb loaded from {}'.format(self.name, cache_file)
            return roidb

        gt_roidb = [self._load_pascal_annotation(index)
                    for index in self.image_index]
        with open(cache_file, 'wb') as fid:
            cPickle.dump(gt_roidb, fid, cPickle.HIGHEST_PROTOCOL)
        print 'wrote gt roidb to {}'.format(cache_file)

        return gt_roidb 
开发者ID:CharlesShang,项目名称:TFFRCNN,代码行数:22,代码来源:pascal_voc.py


示例8: gt_roidb

# 需要导入模块: import cPickle [as 别名]
# 或者: from cPickle import HIGHEST_PROTOCOL [as 别名]
def gt_roidb(self):
        """
        Return the database of ground-truth regions of interest.
        This function loads/saves from/to a cache file to speed up future calls.
        """
        cache_file = osp.join(self.cache_path, self.name + '_gt_roidb.pkl')
        if osp.exists(cache_file):
            with open(cache_file, 'rb') as fid:
                roidb = cPickle.load(fid)
            print '{} gt roidb loaded from {}'.format(self.name, cache_file)
            return roidb

        gt_roidb = [self._load_coco_annotation(index)
                    for index in self._image_index]

        with open(cache_file, 'wb') as fid:
            cPickle.dump(gt_roidb, fid, cPickle.HIGHEST_PROTOCOL)
        print 'wrote gt roidb to {}'.format(cache_file)
        return gt_roidb 
开发者ID:CharlesShang,项目名称:TFFRCNN,代码行数:21,代码来源:coco.py


示例9: gt_roidb

# 需要导入模块: import cPickle [as 别名]
# 或者: from cPickle import HIGHEST_PROTOCOL [as 别名]
def gt_roidb(self):
        """
        Return the database of ground-truth regions of interest, aka, the annotations.

        This function loads/saves from/to a cache file to speed up future calls.
        """
        cache_file = os.path.join(self.cache_path, self.name + '_gt_roidb.pkl')
        if os.path.exists(cache_file):
            with open(cache_file, 'rb') as fid:
                roidb = cPickle.load(fid)
            print '{} gt roidb loaded from {}'.format(self.name, cache_file)
            return roidb

        gt_roidb = [self._load_pascal_annotation(index)
                    for index in self.image_index]
        with open(cache_file, 'wb') as fid:
            cPickle.dump(gt_roidb, fid, cPickle.HIGHEST_PROTOCOL)
        print 'wrote gt roidb to {}'.format(cache_file)

        return gt_roidb 
开发者ID:CharlesShang,项目名称:TFFRCNN,代码行数:22,代码来源:kittivoc.py


示例10: process

# 需要导入模块: import cPickle [as 别名]
# 或者: from cPickle import HIGHEST_PROTOCOL [as 别名]
def process(options, workingCollection, annotationName, outputpkl):
    rootpath = options.rootpath
    overwrite = options.overwrite

    resultfile = os.path.join(outputpkl)
    if checkToSkip(resultfile, overwrite):
        return 0

    concepts = readConcepts(workingCollection, annotationName, rootpath)
    id_images = readImageSet(workingCollection, workingCollection, rootpath)
    tagmatrix = np.random.rand(len(id_images), len(concepts))

    # save results in pkl format
    printStatus(INFO, "Dump results in pkl format at %s" % resultfile)    
    makedirsforfile(resultfile)
    with open(resultfile, 'w') as f:
        pickle.dump({'concepts':concepts, 'id_images':map(int, id_images), 'scores':tagmatrix}, f, pickle.HIGHEST_PROTOCOL) 
开发者ID:li-xirong,项目名称:jingwei,代码行数:19,代码来源:randomtags.py


示例11: set

# 需要导入模块: import cPickle [as 别名]
# 或者: from cPickle import HIGHEST_PROTOCOL [as 别名]
def set(self, key, value, timeout=None):
        if timeout is None:
            timeout = int(time() + self.default_timeout)
        elif timeout != 0:
            timeout = int(time() + timeout)
        filename = self._get_filename(key)
        self._prune()
        try:
            fd, tmp = tempfile.mkstemp(suffix=self._fs_transaction_suffix,
                                       dir=self._path)
            with os.fdopen(fd, 'wb') as f:
                pickle.dump(timeout, f, 1)
                pickle.dump(value, f, pickle.HIGHEST_PROTOCOL)
            rename(tmp, filename)
            os.chmod(filename, self._mode)
        except (IOError, OSError):
            return False
        else:
            return True 
开发者ID:jpush,项目名称:jbox,代码行数:21,代码来源:cache.py


示例12: flush

# 需要导入模块: import cPickle [as 别名]
# 或者: from cPickle import HIGHEST_PROTOCOL [as 别名]
def flush():
	prints = []

	for name, vals in _since_last_flush.items():
		prints.append("{}\t{}".format(name, np.mean(vals.values())))
		_since_beginning[name].update(vals)

		x_vals = np.sort(_since_beginning[name].keys())
		y_vals = [_since_beginning[name][x] for x in x_vals]

		plt.clf()
		plt.plot(x_vals, y_vals)
		plt.xlabel('iteration')
		plt.ylabel(name)
		plt.savefig(name.replace(' ', '_')+'.jpg')

	print "iter {}\t{}".format(_iter[0], "\t".join(prints))
	_since_last_flush.clear()

	with open('log.pkl', 'wb') as f:
		pickle.dump(dict(_since_beginning), f, pickle.HIGHEST_PROTOCOL) 
开发者ID:igul222,项目名称:improved_wgan_training,代码行数:23,代码来源:plot.py


示例13: test_pickleing

# 需要导入模块: import cPickle [as 别名]
# 或者: from cPickle import HIGHEST_PROTOCOL [as 别名]
def test_pickleing(self):
        """
        Test pickling for example save vm env.
        """
        m = factory(AA, system_version=0, qemu_version=0)()
        mm = factory(BB, qemu_version=3)()

        f = open("/tmp/pick", "w+")
        cPickle.dump(m, f, cPickle.HIGHEST_PROTOCOL)
        cPickle.dump(mm, f, cPickle.HIGHEST_PROTOCOL)
        f.close()

        # Delete classes for ensure that pickel works correctly.
        name = m.__class__.__name__
        del m
        del globals()[name]

        name = mm.__class__.__name__
        del mm
        del globals()[name]

        f = open("/tmp/pick", "r+")
        c = cPickle.load(f)
        cc = cPickle.load(f)
        f.close() 
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:27,代码来源:test_versionable_class.py


示例14: snapshot

# 需要导入模块: import cPickle [as 别名]
# 或者: from cPickle import HIGHEST_PROTOCOL [as 别名]
def snapshot(self, iter):
    net = self.net

    if not os.path.exists(self.output_dir):
      os.makedirs(self.output_dir)

    # Store the model snapshot
    filename = cfg.TRAIN.SNAPSHOT_PREFIX + '_iter_{:d}'.format(iter) + '.pth'
    filename = os.path.join(self.output_dir, filename)
    torch.save(self.net.state_dict(), filename)
    print('Wrote snapshot to: {:s}'.format(filename))
    
    
    if iter % 10000 == 0:
        shutil.copyfile(filename, filename + '.{:d}_cache'.format(iter))
    
    # Also store some meta information, random state, etc.
    nfilename = cfg.TRAIN.SNAPSHOT_PREFIX + '_iter_{:d}'.format(iter) + '.pkl'
    nfilename = os.path.join(self.output_dir, nfilename)
    # current state of numpy random
    st0 = np.random.get_state()
    # current position in the database
    cur = self.data_layer._cur
    # current shuffled indexes of the database
    perm = self.data_layer._perm
    # current position in the validation database
    cur_val = self.data_layer_val._cur
    # current shuffled indexes of the validation database
    perm_val = self.data_layer_val._perm

    # Dump the meta info
    with open(nfilename, 'wb') as fid:
      pickle.dump(st0, fid, pickle.HIGHEST_PROTOCOL)
      pickle.dump(cur, fid, pickle.HIGHEST_PROTOCOL)
      pickle.dump(perm, fid, pickle.HIGHEST_PROTOCOL)
      pickle.dump(cur_val, fid, pickle.HIGHEST_PROTOCOL)
      pickle.dump(perm_val, fid, pickle.HIGHEST_PROTOCOL)
      pickle.dump(iter, fid, pickle.HIGHEST_PROTOCOL)

    return filename, nfilename 
开发者ID:Sunarker,项目名称:Collaborative-Learning-for-Weakly-Supervised-Object-Detection,代码行数:42,代码来源:train_val.py


示例15: evaluate_detections

# 需要导入模块: import cPickle [as 别名]
# 或者: from cPickle import HIGHEST_PROTOCOL [as 别名]
def evaluate_detections(self, detections, **kwargs):
        cache_path = os.path.join(self._root_path, 'cache', '{}_{}.pkl'.format(self._name, 'detections'))
        logger.info('saving cache {}'.format(cache_path))
        with open(cache_path, 'wb') as fid:
            pickle.dump(detections, fid, pickle.HIGHEST_PROTOCOL)
        self._evaluate_detections(detections, **kwargs) 
开发者ID:awslabs,项目名称:dynamic-training-with-apache-mxnet-on-aws,代码行数:8,代码来源:imdb.py


示例16: _get_cached

# 需要导入模块: import cPickle [as 别名]
# 或者: from cPickle import HIGHEST_PROTOCOL [as 别名]
def _get_cached(self, cache_item, fn):
        cache_path = os.path.join(self._root_path, 'cache', '{}_{}.pkl'.format(self._name, cache_item))
        if os.path.exists(cache_path):
            logger.info('loading cache {}'.format(cache_path))
            with open(cache_path, 'rb') as fid:
                cached = pickle.load(fid)
            return cached
        else:
            logger.info('computing cache {}'.format(cache_path))
            cached = fn()
            logger.info('saving cache {}'.format(cache_path))
            with open(cache_path, 'wb') as fid:
                pickle.dump(cached, fid, pickle.HIGHEST_PROTOCOL)
            return cached 
开发者ID:awslabs,项目名称:dynamic-training-with-apache-mxnet-on-aws,代码行数:16,代码来源:imdb.py


示例17: save_variables

# 需要导入模块: import cPickle [as 别名]
# 或者: from cPickle import HIGHEST_PROTOCOL [as 别名]
def save_variables(pickle_file_name, var, info, overwrite = False):
  if fu.exists(pickle_file_name) and overwrite == False:
    raise Exception('{:s} exists and over write is false.'.format(pickle_file_name))
  # Construct the dictionary
  assert(type(var) == list); assert(type(info) == list);
  d = {}
  for i in xrange(len(var)):
    d[info[i]] = var[i]
  with fu.fopen(pickle_file_name, 'w') as f:
    cPickle.dump(d, f, cPickle.HIGHEST_PROTOCOL) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:12,代码来源:utils.py


示例18: set

# 需要导入模块: import cPickle [as 别名]
# 或者: from cPickle import HIGHEST_PROTOCOL [as 别名]
def set(self, key, value, timeout=None):
        if timeout is None:
            timeout = self.default_timeout
        self._prune()
        self._cache[key] = (time() + timeout, pickle.dumps(value,
            pickle.HIGHEST_PROTOCOL)) 
开发者ID:jojoin,项目名称:cutout,代码行数:8,代码来源:memcache.py


示例19: add

# 需要导入模块: import cPickle [as 别名]
# 或者: from cPickle import HIGHEST_PROTOCOL [as 别名]
def add(self, key, value, timeout=None):
        if timeout is None:
            timeout = self.default_timeout
        if len(self._cache) > self._threshold:
            self._prune()
        item = (time() + timeout, pickle.dumps(value,
            pickle.HIGHEST_PROTOCOL))
        self._cache.setdefault(key, item) 
开发者ID:jojoin,项目名称:cutout,代码行数:10,代码来源:memcache.py


示例20: _save_params

# 需要导入模块: import cPickle [as 别名]
# 或者: from cPickle import HIGHEST_PROTOCOL [as 别名]
def _save_params(self, dir=None, fn=None, attrs=[]):
        if fn is None:
            fn = self._params_filename()
        if dir:
            fn = os.path.join(dir, fn)
        pdict = dict((x, getattr(self, x)) for x in attrs)
        if self.params:
            pdict.update((p.name, p) for p in self.params)
            pdict['params'] = [p.name for p in self.params]
        with logutil.open(fn, 'w') as f:
            cPickle.dump(pdict, f, cPickle.HIGHEST_PROTOCOL)
    #根据文件名,加载参数模型,记住是文件名,而不是文件夹名 
开发者ID:hjimce,项目名称:Depth-Map-Prediction,代码行数:14,代码来源:net.py


示例21: _do_python_eval

# 需要导入模块: import cPickle [as 别名]
# 或者: from cPickle import HIGHEST_PROTOCOL [as 别名]
def _do_python_eval(self, res_file, res_folder, ann_type):
        coco_dt = self.coco.loadRes(res_file)
        coco_eval = COCOeval(self.coco, coco_dt)
        coco_eval.params.useSegm = (ann_type == 'segm')
        coco_eval.evaluate()
        coco_eval.accumulate()
        info_str = self._print_detection_metrics(coco_eval)

        eval_file = os.path.join(res_folder, 'detections_%s_results.pkl' % self.image_set)
        with open(eval_file, 'w') as f:
            cPickle.dump(coco_eval, f, cPickle.HIGHEST_PROTOCOL)
        print 'coco eval results saved to %s' % eval_file
        info_str +=  'coco eval results saved to %s\n' % eval_file
        return info_str 
开发者ID:tonysy,项目名称:Deep-Feature-Flow-Segmentation,代码行数:16,代码来源:coco.py


示例22: _default_encoder

# 需要导入模块: import cPickle [as 别名]
# 或者: from cPickle import HIGHEST_PROTOCOL [as 别名]
def _default_encoder(o):
    return pickle.dumps(o, pickle.HIGHEST_PROTOCOL) 
开发者ID:jgehrcke,项目名称:gipc,代码行数:4,代码来源:gipc.py


示例23: set

# 需要导入模块: import cPickle [as 别名]
# 或者: from cPickle import HIGHEST_PROTOCOL [as 别名]
def set(self, key, value, timeout=None):
        expires = self._normalize_timeout(timeout)
        self._prune()
        self._cache[key] = (expires, pickle.dumps(value, pickle.HIGHEST_PROTOCOL))
        return True 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:7,代码来源:cache.py


示例24: add

# 需要导入模块: import cPickle [as 别名]
# 或者: from cPickle import HIGHEST_PROTOCOL [as 别名]
def add(self, key, value, timeout=None):
        expires = self._normalize_timeout(timeout)
        self._prune()
        item = (expires, pickle.dumps(value, pickle.HIGHEST_PROTOCOL))
        if key in self._cache:
            return False
        self._cache.setdefault(key, item)
        return True 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:10,代码来源:cache.py


示例25: Store

# 需要导入模块: import cPickle [as 别名]
# 或者: from cPickle import HIGHEST_PROTOCOL [as 别名]
def Store(key, value):
  logging.debug("Saving {}".format(key))
  save = {}
  global DB_FILENAME
  if os.path.exists(DB_FILENAME):
    with open(DB_FILENAME, "rb") as f:
      save = pickle.load(f)

  with open(DB_FILENAME, "wb") as f:
    save[key] = value
    pickle.dump(save, f, pickle.HIGHEST_PROTOCOL) 
开发者ID:cfircohen,项目名称:airport,代码行数:13,代码来源:solutions.py


示例26: gt_roidb

# 需要导入模块: import cPickle [as 别名]
# 或者: from cPickle import HIGHEST_PROTOCOL [as 别名]
def gt_roidb(self):
        """
        Return the database of ground-truth regions of interest.

        This function loads/saves from/to a cache file to speed up future calls.
        """

        cache_file = os.path.join(self.cache_path, self.name + '_' + cfg.SUBCLS_NAME + '_gt_roidb.pkl')
        if os.path.exists(cache_file):
            with open(cache_file, 'rb') as fid:
                roidb = cPickle.load(fid)
            print '{} gt roidb loaded from {}'.format(self.name, cache_file)
            return roidb

        gt_roidb = [self._load_imagenet3d_annotation(index)
                    for index in self.image_index]

        if cfg.IS_RPN:
            # print out recall
            for i in xrange(1, self.num_classes):
                print '{}: Total number of boxes {:d}'.format(self.classes[i], self._num_boxes_all[i])
                print '{}: Number of boxes covered {:d}'.format(self.classes[i], self._num_boxes_covered[i])
                print '{}: Recall {:f}'.format(self.classes[i], float(self._num_boxes_covered[i]) / float(self._num_boxes_all[i]))

        with open(cache_file, 'wb') as fid:
            cPickle.dump(gt_roidb, fid, cPickle.HIGHEST_PROTOCOL)
        print 'wrote gt roidb to {}'.format(cache_file)

        return gt_roidb 
开发者ID:CharlesShang,项目名称:TFFRCNN,代码行数:31,代码来源:imagenet3d.py


示例27: gt_roidb

# 需要导入模块: import cPickle [as 别名]
# 或者: from cPickle import HIGHEST_PROTOCOL [as 别名]
def gt_roidb(self):
        """
        Return the database of ground-truth regions of interest.

        This function loads/saves from/to a cache file to speed up future calls.
        """
        cache_file = os.path.join(self.cache_path, self.name + '_' + cfg.SUBCLS_NAME + '_gt_roidb.pkl')
        if os.path.exists(cache_file):
            with open(cache_file, 'rb') as fid:
                roidb = cPickle.load(fid)
            print '{} gt roidb loaded from {}'.format(self.name, cache_file)
            return roidb

        gt_roidb = [self._load_pascal3d_voxel_exemplar_annotation(index)
                    for index in self.image_index]

        if cfg.IS_RPN:
            # print out recall
            for i in xrange(1, self.num_classes):
                print '{}: Total number of boxes {:d}'.format(self.classes[i], self._num_boxes_all[i])
                print '{}: Number of boxes covered {:d}'.format(self.classes[i], self._num_boxes_covered[i])
                print '{}: Recall {:f}'.format(self.classes[i], float(self._num_boxes_covered[i]) / float(self._num_boxes_all[i]))

        with open(cache_file, 'wb') as fid:
            cPickle.dump(gt_roidb, fid, cPickle.HIGHEST_PROTOCOL)
        print 'wrote gt roidb to {}'.format(cache_file)

        return gt_roidb 
开发者ID:CharlesShang,项目名称:TFFRCNN,代码行数:30,代码来源:pascal3d.py


示例28: region_proposal_roidb

# 需要导入模块: import cPickle [as 别名]
# 或者: from cPickle import HIGHEST_PROTOCOL [as 别名]
def region_proposal_roidb(self):
        """
        Return the database of regions of interest.
        Ground-truth ROIs are also included.

        This function loads/saves from/to a cache file to speed up future calls.
        """
        cache_file = os.path.join(self.cache_path,
                                  self.name + '_' + cfg.SUBCLS_NAME + '_' + cfg.REGION_PROPOSAL + '_region_proposal_roidb.pkl')

        if os.path.exists(cache_file):
            with open(cache_file, 'rb') as fid:
                roidb = cPickle.load(fid)
            print '{} roidb loaded from {}'.format(self.name, cache_file)
            return roidb

        if self._image_set != 'test':
            gt_roidb = self.gt_roidb()

            print 'Loading region proposal network boxes...'
            model = cfg.REGION_PROPOSAL
            rpn_roidb = self._load_rpn_roidb(gt_roidb, model)
            print 'Region proposal network boxes loaded'
            roidb = imdb.merge_roidbs(rpn_roidb, gt_roidb)
        else:
            print 'Loading region proposal network boxes...'
            model = cfg.REGION_PROPOSAL
            roidb = self._load_rpn_roidb(None, model)
            print 'Region proposal network boxes loaded'

        print '{} region proposals per image'.format(self._num_boxes_proposal / len(self.image_index))

        with open(cache_file, 'wb') as fid:
            cPickle.dump(roidb, fid, cPickle.HIGHEST_PROTOCOL)
        print 'wrote roidb to {}'.format(cache_file)

        return roidb 
开发者ID:CharlesShang,项目名称:TFFRCNN,代码行数:39,代码来源:pascal3d.py



注:本文中的cPickle.HIGHEST_PROTOCOL属性示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。