You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by gi...@git.apache.org on 2017/08/08 03:22:22 UTC

[GitHub] Lyken17 opened a new issue #7376: MXbox -- a simple and flexible vision toolbox for mxnet framework.

Lyken17 opened a new issue #7376: MXbox -- a simple and flexible vision toolbox for mxnet framework.
URL: https://github.com/apache/incubator-mxnet/issues/7376
 
 
   Thanks for DMLC generous sharing, we can use mxnet -- a great framework efficient  in both memory and speed. However, after using mxnet for months, I found mxnet still has some inconvenience in developing.
   
   For example, mxnet recommends using `im2rec` for loading dataset, but sometimes we need to handle a dataset where new data comes every day. Then generating `im2rec` becomes a time consuming job since incremental adding is not supported. Also, `rec` seems to originally designed for classification tasks, when handling other tasks like semantic segmentation and nlp machine translation, designing a correct `rec` with proper argumentations can be difficult. So I hope there to be a simple and efficient data loader for various tasks.
   
   Another thing is pretrained models. No matter you are a researcher or engineer, a good baseline is always a good start. Unfortunately, many state-of-art models are not originally implemented in mxnet. And their definition files and pretrained weights are scatted among sites. Let alone sometimes they do not provide a detailed description of the important parameters such as normalization mean and std. It would be great if there is a model zoo providing popular networks together with their pretrained weights and hyper parameters. 
   
   Inspired by [pytorch](https://github.com/pytorch/pytorch) and [torchvision](https://github.com/pytorch/vision),  which give a great flexibility to developing, I write [mxbox](https://github.com/Lyken17/mxbox), -- a simple and flexible vision toolbox for mxnet framework. You can download it by 
   ```bash
   pip install mxbox
   ```
   
   Now [mxbox](https://github.com/Lyken17/mxbox) provides following features
   
   1. Define **preprocess** as a flow (several backends are supported, so no longer to worry about opencv2 / 3 compatibility)
   
   ```python
   transform = transforms.Compose([
       transforms.RandomSizedCrop(224),
       transforms.RandomHorizontalFlip(),
       transforms.mx.ToNdArray(),
       transforms.mx.Normalize(mean = [123.68,116.779,103.939 ]),
   ])
   ```
   
   2) Build an efficient multi-thread **DataLoader** in few lines
   
   Common datasets such as `cifar10`, `cifar100`, `SVHN`, `MNIST` are out-of-the-box. You can simply load them from `mxbox.datasets`.
   
   ```python
   from mxbox import transforms, datasets, DataLoader
   trans = transforms.Compose([
           transforms.mx.ToNdArray(), 
           transforms.mx.Normalize(mean = [ 0.485, 0.456, 0.406 ],
                                   std  = [ 0.229, 0.224, 0.225 ]),
   ])
   dataset = datasets.CIFAR10('~/.mxbox/cifar10', transform=trans, download=True)
   
   batch_size = 32
   feedin_shapes = {
       'batch_size': batch_size,
       'data': [mx.io.DataDesc(name='data', shape=(batch_size, 3, 32, 32), layout='NCHW')],
       'label': [mx.io.DataDesc(name='softmax_label', shape=(batch_size, ), layout='N')]
   }
   loader = DataLoader(dataset, feedin_shapes, threads=8, shuffle=True)
   ```  
   3) Load popular model with pretrained weights
   ```python
   alexnet = mxbox.models.alexnet(num_classes=1000, pretrained=True)
   vgg16 = mxbox.models.vgg16(num_classes=1000, pretrained=True)
   resnet_diy = mxbox.models.resnet(num_classes=1000, num_units=[6,14,32,64], pretrained=True)
   densenet169 = mxbox.models.densenet169(num_classes=1000, pretrained=True)
   ```
   
   Now most parts have finished construction except `models`. Models provided in [mxnet model zoo](https://github.com/dmlc/mxnet-model-gallery) do not come with definition files. And recent popular models like [resnet](https://arxiv.org/abs/1512.03385) and [densenet](https://github.com/liuzhuang13/DenseNet) are not included. I would appreciate if someone can help on this.
   
   Any questions, comments or suggestions are welcome!
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services