lmdb_creator.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:phocnet 作者: ssudholt 项目源码 文件源码
def open_single_lmdb_for_write(self, lmdb_path, max_lmdb_size=1024**4, create=True, label_map=None):
        '''
        Opens a single LMDB for inserting ndarrays (i.e. images)

        Args:
            lmdb_path (str): Where to save the LMDB
            max_lmdb_size (int): The maximum size in bytes of the LMDB (default: 1TB)
            create (bool):  If this flag is set, a potentially previously created LMDB at lmdb_path
                            is deleted and overwritten by this new LMDB
            label_map (dictionary): If you supply a dictionary mapping string labels to integer indices, you can later
                                    call put_single with string labels instead of int labels
        '''
        # delete existing LMDB if necessary
        if os.path.exists(lmdb_path) and create:
            self.logger.debug('Erasing previously created LMDB at %s', lmdb_path)
            shutil.rmtree(lmdb_path)
        self.logger.info('Opening single LMDB at %s for writing', lmdb_path)
        self.database_images = lmdb.open(path=lmdb_path, map_size=max_lmdb_size)
        self.txn_images = self.database_images.begin(write=True)
        self.label_map = label_map
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号