start using pytables
This commit is contained in:
+32
-1
@@ -3,11 +3,16 @@ import sys
|
||||
|
||||
import math
|
||||
import shutil
|
||||
import warnings
|
||||
import tables as tb
|
||||
import numpy as np
|
||||
import scipy.io as sio
|
||||
|
||||
from tqdm import tqdm
|
||||
|
||||
from tables import NaturalNameWarning
|
||||
warnings.filterwarnings('ignore', category=NaturalNameWarning)
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..')
|
||||
from data.cloth3d_io import readPC2, loadInfo
|
||||
from data.utils import Frame
|
||||
@@ -102,6 +107,31 @@ def genereated_registered_and_mask(folder, is_skirt = False):
|
||||
np.save(os.path.join(garment_dir, garment + '_mask.npy'), mask)
|
||||
|
||||
|
||||
def create_extras_file(folder):
|
||||
# create a new pytables file
|
||||
root = '/'.join(folder.split('/')[:-1])
|
||||
type = folder.split('/')[-1]
|
||||
h5file = tb.open_file(os.path.join(root, f'{type}_extras.h5'), mode='w', title='Extras')
|
||||
|
||||
frames = []
|
||||
with open(os.path.join(folder, 'frames_all.txt'), 'r') as f:
|
||||
lines = f.readlines()
|
||||
lines = [line.strip() for line in lines]
|
||||
frames = lines
|
||||
|
||||
for frame in tqdm(frames):
|
||||
# add a new empty group to the root group for each frame
|
||||
id, frame_nr, garment = frame.split()
|
||||
if not id in h5file.root:
|
||||
h5file.create_group('/', id)
|
||||
if not frame_nr in h5file.root[id]:
|
||||
h5file.create_group(f'/{id}', frame_nr)
|
||||
h5file.create_group(f'/{id}/{frame_nr}', f'{garment}')
|
||||
|
||||
|
||||
h5file.close()
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -109,4 +139,5 @@ if __name__ == '__main__':
|
||||
|
||||
# clean_dataset(folder)
|
||||
# generate_frames_file(folder, 'frames_all.txt')
|
||||
split_data(folder, 0.9)
|
||||
# split_data(folder, 0.9)
|
||||
create_extras_file(folder)
|
||||
Reference in New Issue
Block a user