找不到中文文檔,全是生肉。。沒辦法只能自己翻譯了
MXNet -python API
Image API(圖像)
概覽
本文總結了用於讀取和處理其中提供的圖像的支持函數和迭代器
mxnet.imge 圖像迭代和圖像增加函數
圖像處理函數
image.imdecode 將圖像解碼為NDArray。(NDArray 多維數組對象)
imgage.scale_down 如果尺寸大於圖像尺寸,縮小裁剪尺寸。
image.resize_short 將較短邊調整到合適尺寸
image.fixed_crop 在固定的位置修剪src,並(可選地)調整它的大小。
image.random_crop 按照尺寸隨機修剪src(寬,高)
image.center_crop 通過在所有的四邊進行修剪將圖像src裁剪到給定的大小,並保留圖像的中心。
image.color_normalize 用mean和std對src進行歸一化。
image.random_size_crop 按照尺寸隨機修剪src
圖像迭代器
迭代器支持從二進制記錄IO和原始圖像文件加載圖像。
image.ImageIter 有大量增加圖片的圖像迭代器
1 data_iter = mx.image.ImageIter(batch_size=4, data_shape=(3, 224, 224), label_width=1, 2 data_iter.reset() 3 for data in data_iter: 4 d = data.data[0] 5 print(d.shape) 6 # we can apply lots of augmentations as well我們也能夠擴展到很多圖片 7 data_iter = mx.image.ImageIter(4, (3, 224, 224), path_imglist='data/custom.lst', 8 data = data_iter.next() 9 # specify augmenters manually is also supported手動指定增量也是支持的 10 data_iter = mx.image.ImageIter(32, (3, 224, 224), path_rec='data/caltech.rec',
我們使用助手函數來初始化增加器
image.CreateAugmenter 創建一個增加器列表
一個支持增加器的列表
image.Augmenter 圖像增強基類
image.SequentialAug 組成一個連續的增強列表。
image.RandomOrderAug 將增量表隨機打亂
image.ResizeAug 使短邊調整到增量大小
。。。中間省略先
通常由 tools/im2rec.py生成的 lst 文件是一個列表,如下:
index_0 label_0 image_path_0
index_1 label_1 image_path_1
label_N是一個定寬的向量數,目標檢測的標簽類型是一個長的可變向量
A B [extra header] [(object0),(object1).....(objectN)]
A 是header 的寬度(2+ extra header的長度),B是每個物體的寬度,extra header是可選的,用於插入助手信息,如(寬度,高度)。每個object通常是描述目標屬性的5或6個數字.例如: [id, xmin, ymin, xmax, ymax, difficulty],把所有的進行合成,我們得到目標檢測的lst文件。
我總算找到了生成lst的文檔了。。。。蒼天啊
現在讓我們使用im2rec.py腳本工具將它們轉換為record io格式。首先,我們需要制作一個包含所有圖像文件及其類別的列表: