|
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- """
- 为了加速创建trainsets,分两次生成data,需要把这两次的data合并
- """
- import os
- import numpy as np
-
- # root_dir = '/userhome/NNCTX-main/train_datasets/'
- # samples = ['andrew10','david10','sarah10']#,'soldier','longdress'
- # nfr_per_samples = [6,6,6]#,9,9
-
- data = np.load("/userhome/NNCTX-main/train_datasets/data_100/data1.npy",allow_pickle=True)
- ctxs1 = data[()]['ctxs']
- counts1 = data[()]['counts']
- ply_paths = data[()]['ply_paths']
-
- data = np.load("/userhome/NNCTX-main/train_datasets/data_100/data.npy",allow_pickle=True)
- ctxs2 = data[()]['ctxs']
- counts2 = data[()]['counts']
- ply_paths += data[()]['ply_paths'] #不重要,可以不去重
- print(ply_paths)
-
- all_ctxs = np.concatenate((ctxs1,ctxs2),axis=0)#[all_ctxs ; ctxs];
- all_counts = np.concatenate((counts1,counts2),axis=0)#[all_ctxs ; ctxs];
- nall = all_ctxs.shape[0]
-
- u_ctxs,uinvs = np.unique(all_ctxs, return_inverse=1,axis=0)
- nu_ctxs = u_ctxs.shape[0]
- u_counts = np.zeros((nu_ctxs,2),'int')
-
- for i_actx in range(nall):
- iuctx = uinvs[i_actx]
- u_counts[iuctx,:] = u_counts[iuctx,:]+all_counts[i_actx,:]
- if i_actx%100000==0:
- print(str(i_actx) +'/' + str(nall ))
-
- all_ctxs = np.copy(u_ctxs)
- all_counts = np.copy(u_counts)
- np.save('/userhome/NNCTX-main/train_datasets/data_100/data_all.npy',{'ctxs':all_ctxs,'counts':all_counts,'ply_paths':ply_paths}) #保存一次会覆盖之前的结果,all_ctxs本身包含了之前的结果
|