Blame view
egs/cifar/v1/image/select_image_in_egs.py
1.13 KB
8dcb6dfcb first commit |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
#!/usr/bin/env python # You can use this to select an image in an egs file: # e.g.: # nnet3-copy-egs ark:exp/cifar10_egs/egs.1.ark ark,t:- | \ # image/select_image_in_egs.py 00001 | image/matrix_to_image.py --color 3 > 00001.bmp # e.g.: # id=00002; nnet3-egs-augment-image --horizontal-flip-prob=0.2 --horizontal-shift=0.3 \ # --vertical-shift=0.3 --srand=27 --num-channels=3 ark:exp/cifar10_egs/egs.1.ark ark,t:- | \ # image/select_image_in_egs.py $id | image/matrix_to_image.py --color 3 > $id.bmp from __future__ import print_function import argparse import sys parser = argparse.ArgumentParser(description="""Select the image matrix for the eg specified by img_id. For purposes of viewing/debugging.""") parser.add_argument('img_id', type=str, default=None, help='image id') args = parser.parse_args() found = False while True: line = sys.stdin.readline().strip() if not line: break if line.find(args.img_id + ' <Nnet3Eg>') != -1: found=True print('[') continue if found and line.find('</NnetIo>') != -1: break if found: print(line) |