码迷,mamicode.com
首页 > Web开发 > 详细

『MXNet』im2rec脚本使用(待续)

时间:2018-07-26 21:19:04      阅读:823      评论:0      收藏:0      [点我收藏+]

标签:lse   shuff   sse   sig   自动生成   com   ima   二进制文件   rop   

首先看文档:

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脚本使用(待续)

标签:lse   shuff   sse   sig   自动生成   com   ima   二进制文件   rop   

原文地址:https://www.cnblogs.com/hellcat/p/9373890.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!