『MXNet』im2rec腳本使用(待續)
阿新 • • 發佈:2018-07-26
nco sts chunk cor any mes ren 圖像 ons
首先看文檔:
usage: im2rec.py [-h] [--list] [--exts EXTS [EXTS ...]] [--chunks CHUNKS] [--train-ratio TRAIN_RATIO] [--test-ratio TEST_RATIO] [--recursive] [--no-shuffle] [--pass-through] [--resize RESIZE] [--center-crop] [--quality QUALITY] [--num-thread NUM_THREAD] [--color {-1,0,1}] [--encoding {.jpg,.png}] [--pack-label] prefix root Create an image list or make a record database by reading from an image list positional arguments: prefix prefix of input/output lst and rec files. root path to folder containing images. optional arguments: -h, --help show this help message and exit Options for creating image lists: --list If this is set im2rec will create image list(s) by traversing root folder and output to <prefix>.lst. Otherwise im2rec will read <prefix>.lst and create a database at <prefix>.rec (default: False) --exts EXTS [EXTS ...] list of acceptable image extensions. (default: [‘.jpeg‘, ‘.jpg‘, ‘.png‘]) --chunks CHUNKS number of chunks. (default: 1) --train-ratio TRAIN_RATIO Ratio of images to use for training. (default: 1.0) --test-ratio TEST_RATIO Ratio of images to use for testing. (default: 0) --recursive If true recursively walk through subdirs and assign an unique label to images in each folder. Otherwise only include images in the root folder and give them label 0. (default: False) --no-shuffle If this is passed, im2rec will not randomize the image order in <prefix>.lst (default: True) Options for creating database: --pass-through whether to skip transformation and save image as is (default: False) --resize RESIZE resize the shorter edge of image to the newsize, original images will be packed by default. (default: 0) --center-crop specify whether to crop the center image to make it rectangular. (default: False) --quality QUALITY JPEG quality for encoding, 1-100; or PNG compression for encoding, 1-9 (default: 95) --num-thread NUM_THREAD number of thread to use for encoding. order of images will be different from the input list if >1. the input list will be modified to match the resulting order. (default: 1) --color {-1,0,1} specify the color mode of the loaded image. 1: Loads a color image. Any transparency of image will be neglected. It is the default flag. 0: Loads image in grayscale mode. -1:Loads image as such including alpha channel. (default: 1) --encoding {.jpg,.png} specify the encoding of the images. (default: .jpg) --pack-label Whether to also pack multi dimensional label in the record file (default: False)
必須要填寫的參數有prefix、和root兩個路徑參數,
prefix:生成文件文件夾目錄
可以指定為.lst的路徑,這樣生成文件會和.lst同一級別,且會根據.lst中的條目生成二進制文件
root:圖片文件目錄,默認的話裏面是類別文件夾,類別名做label,每個文件夾存儲圖像
如果指定了.lst,則每個圖片路徑變為root路徑+.lst中每個圖片的路徑
--pack-label:在指定了.lst後很有用,此時允許label為高維度(主要是label可以設置為數組)
實際上我們之前也介紹過,.lst文件並不是必須的,僅有.rec和.idx就可以滿足需要(標簽存儲在.rec中),它是一個輔助(人工生成.lst指導.rec生成),或者作為一個結果展示(自動生成.rec時選擇同時生成.lst)。
『MXNet』im2rec腳本使用(待續)