當前位置: 首頁>>代碼示例>>Python>>正文


Python recordio.MXIndexedRecordIO方法代碼示例

本文整理匯總了Python中mxnet.recordio.MXIndexedRecordIO方法的典型用法代碼示例。如果您正苦於以下問題:Python recordio.MXIndexedRecordIO方法的具體用法?Python recordio.MXIndexedRecordIO怎麽用?Python recordio.MXIndexedRecordIO使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mxnet.recordio的用法示例。


在下文中一共展示了recordio.MXIndexedRecordIO方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _fork

# 需要導入模塊: from mxnet import recordio [as 別名]
# 或者: from mxnet.recordio import MXIndexedRecordIO [as 別名]
def _fork(self):
        if self.use_src:
            self.recs = recordio.MXIndexedRecordIO(self.idx_fs, self.rec_fs, 'r')
            self.idxs = list(self.recs.idx.keys())

        if self.use_tgt:
            self.rect = recordio.MXIndexedRecordIO(self.idx_ft, self.rec_ft, 'r')
            self.idxt = list(self.rect.idx.keys())

            if self.use_src:
                cls_lst = []
                for idx in self.idxt:
                    record = self.rect.read_idx(idx)
                    h, _ = recordio.unpack(record)
                    cls_lst.append(h.label)

                self.idxt_cls = self.generate_cls_dict(cls_lst) 
開發者ID:aws-samples,項目名稱:d-SNE,代碼行數:19,代碼來源:datasets_su.py

示例2: gen_cls_dict

# 需要導入模塊: from mxnet import recordio [as 別名]
# 或者: from mxnet.recordio import MXIndexedRecordIO [as 別名]
def gen_cls_dict():
    rec = recordio.MXIndexedRecordIO(os.path.splitext(args.rec)[0] + '.idx', args.rec, 'r')
    cls_lst = []
    pbar = tqdm(total=len(rec.idx.keys()))
    for idx in rec.idx.keys():
        record = rec.read_idx(idx)
        h, _ = recordio.unpack(record)
        cls_lst.append(int(h.label))
        pbar.update()

    pbar.close()

    cls_dict = {}
    for idx, y in enumerate(cls_lst):
        if y in cls_dict:
            cls_dict[y].append(idx)
        else:
            cls_dict[y] = [idx]

    with open(os.path.splitext(args.rec)[0] + '.json', 'w') as f:
        json.dump(cls_dict, f, indent=4, sort_keys=True) 
開發者ID:aws-samples,項目名稱:d-SNE,代碼行數:23,代碼來源:gen_cls_dict_visda.py

示例3: __init__

# 需要導入模塊: from mxnet import recordio [as 別名]
# 或者: from mxnet.recordio import MXIndexedRecordIO [as 別名]
def __init__(self, batch_size, data_shape,
                 path_imgrec = None,
                 shuffle=False, aug_list=None, mean = None,
                 rand_mirror = False, cutoff = 0, color_jittering = 0,
                 data_name='data', label_name='softmax_label', **kwargs):
        super(FaceImageIter, self).__init__()
        assert path_imgrec
        logging.info('loading recordio %s...',
                     path_imgrec)
        path_imgidx = path_imgrec[0:-4]+".idx"
        self.imgrec = recordio.MXIndexedRecordIO(path_imgidx, path_imgrec, 'r')  # pylint: disable=redefined-variable-type
        s = self.imgrec.read_idx(0)
        header, _ = recordio.unpack(s)
        self.imgidx = list(self.imgrec.keys)
        self.seq = self.imgidx

        self.mean = mean
        self.nd_mean = None
        if self.mean:
          self.mean = np.array(self.mean, dtype=np.float32).reshape(1,1,3)
          self.nd_mean = mx.nd.array(self.mean).reshape((1,1,3))

        self.check_data_shape(data_shape)
        self.provide_data = [(data_name, (batch_size,) + data_shape)]
        self.batch_size = batch_size
        self.data_shape = data_shape
        self.shuffle = shuffle
        self.image_size = '%d,%d'%(data_shape[1],data_shape[2])
        self.rand_mirror = rand_mirror
        print('rand_mirror', rand_mirror)
        self.cutoff = cutoff
        self.color_jittering = color_jittering
        self.CJA = mx.image.ColorJitterAug(0.125, 0.125, 0.125)
        self.provide_label = [(label_name, (batch_size,101))]
        #print(self.provide_label[0][1])
        self.cur = 0
        self.nbatch = 0
        self.is_init = False 
開發者ID:deepinsight,項目名稱:insightface,代碼行數:40,代碼來源:data.py

示例4: _fork

# 需要導入模塊: from mxnet import recordio [as 別名]
# 或者: from mxnet.recordio import MXIndexedRecordIO [as 別名]
def _fork(self):

        self.rec1 = recordio.MXIndexedRecordIO(self.idx_f1, self.rec_f1, 'r')
        self.cls_idx_d1 = self.load_or_gen_dict(self.rec_f1, self.rec1)
        self.idx1 = list(self.rec1.idx.keys())

        self.rec2 = recordio.MXIndexedRecordIO(self.idx_2, self.rec_f2, 'r')
        self.cls_idx_d2 = self.load_or_gen_dict(self.rec_f2, self.rec2)
        self.idx2 = list(self.rec2.idx.keys()) 
開發者ID:aws-samples,項目名稱:d-SNE,代碼行數:11,代碼來源:datasets_ss.py

示例5: __init__

# 需要導入模塊: from mxnet import recordio [as 別名]
# 或者: from mxnet.recordio import MXIndexedRecordIO [as 別名]
def __init__(self, batch_size, data_shape,
                 path_imgrec = None,
                 shuffle=False, aug_list=None, mean = None,
                 rand_mirror = False, cutoff = 0,
                 data_name='data', label_name='softmax_label', **kwargs):
        super(FaceImageIter, self).__init__()
        assert path_imgrec
        if path_imgrec:
            logging.info('loading recordio %s...',
                         path_imgrec)
            path_imgidx = path_imgrec[0:-4]+".idx"
            self.imgrec = recordio.MXIndexedRecordIO(path_imgidx, path_imgrec, 'r')  # pylint: disable=redefined-variable-type
            s = self.imgrec.read_idx(0)
            header, _ = recordio.unpack(s)
            self.imgidx = list(self.imgrec.keys)
            if shuffle:
              self.seq = self.imgidx
              self.oseq = self.imgidx
              print(len(self.seq))
            else:
              self.seq = None

        self.mean = mean
        self.nd_mean = None
        if self.mean:
          self.mean = np.array(self.mean, dtype=np.float32).reshape(1,1,3)
          self.nd_mean = mx.nd.array(self.mean).reshape((1,1,3))

        self.check_data_shape(data_shape)
        self.provide_data = [(data_name, (batch_size,) + data_shape)]
        self.batch_size = batch_size
        self.data_shape = data_shape
        self.shuffle = shuffle
        self.image_size = '%d,%d'%(data_shape[1],data_shape[2])
        self.rand_mirror = rand_mirror
        print('rand_mirror', rand_mirror)
        self.cutoff = cutoff
        self.provide_label = [(label_name, (batch_size,102))]
        #print(self.provide_label[0][1])
        self.cur = 0
        self.nbatch = 0
        self.is_init = False 
開發者ID:deepinsight,項目名稱:insightface,代碼行數:44,代碼來源:age_iter.py


注:本文中的mxnet.recordio.MXIndexedRecordIO方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。