fix remove rearrange_OUMVLP & pretreatment bug
This commit is contained in:
@@ -46,8 +46,8 @@ def imgs2pickle(img_groups: Tuple, output_path: Path, img_size: int = 64, verbos
|
|||||||
|
|
||||||
# As the height of a person is larger than the width,
|
# As the height of a person is larger than the width,
|
||||||
# use the height to calculate resize ratio.
|
# use the height to calculate resize ratio.
|
||||||
ratio = img.shape[1] // img.shape[0]
|
ratio = img.shape[1] / img.shape[0]
|
||||||
img = cv2.resize(img, (img_size * ratio, img_size), interpolation=cv2.INTER_CUBIC)
|
img = cv2.resize(img, (int(img_size * ratio), img_size), interpolation=cv2.INTER_CUBIC)
|
||||||
|
|
||||||
# Get the median of the x-axis and take it as the person's x-center.
|
# Get the median of the x-axis and take it as the person's x-center.
|
||||||
x_csum = img.sum(axis=0).cumsum()
|
x_csum = img.sum(axis=0).cumsum()
|
||||||
@@ -81,11 +81,12 @@ def imgs2pickle(img_groups: Tuple, output_path: Path, img_size: int = 64, verbos
|
|||||||
if verbose:
|
if verbose:
|
||||||
logging.debug(f'Saving {pkl_path}...')
|
logging.debug(f'Saving {pkl_path}...')
|
||||||
pickle.dump(to_pickle, open(pkl_path, 'wb'))
|
pickle.dump(to_pickle, open(pkl_path, 'wb'))
|
||||||
|
logging.info(f'Saved {len(to_pickle)} valid frames to {pkl_path}.')
|
||||||
|
|
||||||
|
|
||||||
if len(to_pickle) < 5:
|
if len(to_pickle) < 5:
|
||||||
logging.warning(f'{sinfo} has less than 5 valid data.')
|
logging.warning(f'{sinfo} has less than 5 valid data.')
|
||||||
|
|
||||||
logging.info(f'Saved {len(to_pickle)} valid frames to {pkl_path}.')
|
|
||||||
|
|
||||||
|
|
||||||
def pretreat(input_path: Path, output_path: Path, img_size: int = 64, workers: int = 4, verbose: bool = False) -> None:
|
def pretreat(input_path: Path, output_path: Path, img_size: int = 64, workers: int = 4, verbose: bool = False) -> None:
|
||||||
@@ -121,7 +122,7 @@ def pretreat(input_path: Path, output_path: Path, img_size: int = 64, workers: i
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser(description='OpenGait dataset pretreatment module.')
|
parser = argparse.ArgumentParser(description='OpenGait dataset pretreatment module.')
|
||||||
parser.add_argument('-r', '--root_path', default='', type=str, help='Root path of raw dataset.')
|
parser.add_argument('-r', '--input_path', default='', type=str, help='Root path of raw dataset.')
|
||||||
parser.add_argument('-o', '--output_path', default='', type=str, help='Output path of pickled dataset.')
|
parser.add_argument('-o', '--output_path', default='', type=str, help='Output path of pickled dataset.')
|
||||||
parser.add_argument('-l', '--log_file', default='./pretreatment.log', type=str, help='Log file path. Default: ./pretreatment.log')
|
parser.add_argument('-l', '--log_file', default='./pretreatment.log', type=str, help='Log file path. Default: ./pretreatment.log')
|
||||||
parser.add_argument('-n', '--n_workers', default=4, type=int, help='Number of thread workers. Default: 4')
|
parser.add_argument('-n', '--n_workers', default=4, type=int, help='Number of thread workers. Default: 4')
|
||||||
@@ -137,4 +138,4 @@ if __name__ == '__main__':
|
|||||||
for k, v in args.__dict__.items():
|
for k, v in args.__dict__.items():
|
||||||
logging.debug(f'{k}: {v}')
|
logging.debug(f'{k}: {v}')
|
||||||
|
|
||||||
pretreat(Path(args.root_path), Path(args.output_path), args.n_workers, args.img_size, args.verbose)
|
pretreat(input_path=Path(args.root_path), output_path=Path(args.output_path), img_size=args.img_size, workers=args.n_workers, verbose=args.verbose)
|
||||||
|
|||||||
@@ -25,11 +25,11 @@ def rearrange(input_path: Path, output_path: Path) -> None:
|
|||||||
dst = os.path.join(output_path, sid.name, seq, view)
|
dst = os.path.join(output_path, sid.name, seq, view)
|
||||||
os.makedirs(dst, exist_ok=True)
|
os.makedirs(dst, exist_ok=True)
|
||||||
for subfile in os.listdir(src):
|
for subfile in os.listdir(src):
|
||||||
if subfile.endswith('.png'):
|
if subfile not in os.listdir(dst) and subfile.endswith('.png'):
|
||||||
os.symlink(os.path.join(src, subfile),
|
os.symlink(os.path.join(src, subfile),
|
||||||
os.path.join(dst, subfile))
|
os.path.join(dst, subfile))
|
||||||
else:
|
# else:
|
||||||
os.remove(os.path.join(src, subfile))
|
# os.remove(os.path.join(src, subfile))
|
||||||
progress.update(1)
|
progress.update(1)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user