chainercv: a library for deep learning in computer vision · chainercv: a library for deep learning...

4
ChainerCV: a Library for Deep Learning in Computer Vision Yusuke Niitani The University of Tokyo [email protected] Toru Ogawa The University of Tokyo [email protected] Shunta Saito Preferred Networks [email protected] Masaki Saito Preferred Networks [email protected] ABSTRACT Despite significant progress of deep learning in the field of com- puter vision, there has not been a software library that covers these methods in a unifying manner. We introduce ChainerCV, a software library that is intended to fill this gap. ChainerCV supports numer- ous neural network models as well as software components needed to conduct research in computer vision. These implementations emphasize simplicity, flexibility and good software engineering practices. The library is designed to perform on par with the results reported in published papers and its tools can be used as a baseline for future research in computer vision. Our implementation in- cludes sophisticated models like Faster R-CNN and SSD, and covers tasks such as object detection and semantic segmentation. CCS CONCEPTS Information systems Open source software; Comput- ing methodologies Image segmentation; Object detection; KEYWORDS Open Source; Computer Vision; Machine Learning; Deep Learning ACM Reference format: Yusuke Niitani, Toru Ogawa, Shunta Saito, and Masaki Saito. 2017. Chain- erCV: a Library for Deep Learning in Computer Vision. In Proceedings of MM ’17, Mountain View, CA, USA, October 23–27, 2017, 4 pages. https://doi.org/10.1145/3123266.3129395 1 INTRODUCTION In recent years, the computer vision community has witnessed rapid progress thanks to deep learning methods in areas including image classification [2], object detection [13] and semantic segmen- tation [3]. High quality software tools are essential to keep up the rapid pace of innovation in deep learning research. The quality of a software library is hugely influenced by traditional software quality metrics such as consistent coding conventions and coverage of tests and documentation. In addition to that, a deep learning library, specifically a library that hosts implementations of deep Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]. MM ’17, October 23–27, 2017, Mountain View, CA, USA © 2017 Association for Computing Machinery. ACM ISBN 978-1-4503-4906-2/17/10. . . $15.00 https://doi.org/10.1145/3123266.3129395 learning models, needs to guarantee quality during the training phase. Training a machine learning model to have a good perfor- mance is difficult due to numerous details that can hinder it from achieving its full potential. This makes it all the more important that a library hosts implementations of high performance training code so that it can give guidance to developers and researchers who want to extend and develop further from these implementations. We think that training code should perform on par with the per- formance reported by the paper that the implementation is based on. On top of providing a high quality implementation for training a model, we also aim at making it more accessible, especially for users with limited experience, to run inference on sophisticated computer vision models such as Faster R-CNN [13]. The rapid progress of deep learning research has been enabled by a number of frameworks including Chainer [15], TensorFlow [1] and PyTorch 1 . These frameworks have supported fundamental components of deep learning software such as automatic differ- entiation and effective parallelization using GPUs. However, they are intended to target general usage, and do not aim to provide complete implementations of vision algorithms. Our software, ChainerCV, supports algorithms to solve tasks in the computer vision field such as object detection, while consider- ing usability and predictable performance as the top priorities. This makes it perfect to be used as a building block in larger software projects such as robotic software systems even by developers who are not computer vision experts. Recently there has been a growing trend of building new neural network models using existing archi- tectures as building blocks. Examples can be seen in tasks such as instance segmentation [8] and scene graph generation [16], which depend on object detection algorithms to localize objects in images. ChainerCV’s algorithms can be used as components to construct software that can solve complex computer vision problems. Training a network is a critical part of a machine learning al- gorithm, and ChainerCV is designed to make this process easy. In many use cases, users need a machine learning model to perform well on a particular dataset they have. Often a pretrained model is not sufficient for the users’ tasks, and so they must re-train the model using their datasets. To make training a model easier in such cases, ChainerCV provides reference implementations to train mod- els, which can be used as a baseline to write new training code. In addition to that, pretrained models can be used together with the users dataset to fine-tune the model. ChainerCV also provides set of tools for training a model including dataset loader, prediction evaluator and visualization tools. 1 http://pytorch.org arXiv:1708.08169v1 [cs.CV] 28 Aug 2017

Upload: buiduong

Post on 12-Mar-2019

234 views

Category:

Documents


0 download

TRANSCRIPT

ChainerCV: a Library for Deep Learning in Computer VisionYusuke Niitani

The University of [email protected]

Toru OgawaThe University of Tokyo

[email protected]

Shunta SaitoPreferred [email protected]

Masaki SaitoPreferred [email protected]

ABSTRACTDespite significant progress of deep learning in the field of com-puter vision, there has not been a software library that covers thesemethods in a unifying manner. We introduce ChainerCV, a softwarelibrary that is intended to fill this gap. ChainerCV supports numer-ous neural network models as well as software components neededto conduct research in computer vision. These implementationsemphasize simplicity, flexibility and good software engineeringpractices. The library is designed to perform on par with the resultsreported in published papers and its tools can be used as a baselinefor future research in computer vision. Our implementation in-cludes sophisticated models like Faster R-CNN and SSD, and coverstasks such as object detection and semantic segmentation.

CCS CONCEPTS• Information systems → Open source software; • Comput-ing methodologies → Image segmentation; Object detection;

KEYWORDSOpen Source; Computer Vision; Machine Learning; Deep LearningACM Reference format:Yusuke Niitani, Toru Ogawa, Shunta Saito, and Masaki Saito. 2017. Chain-erCV: a Library for Deep Learning in Computer Vision. In Proceedings ofMM ’17, Mountain View, CA, USA, October 23–27, 2017, 4 pages.https://doi.org/10.1145/3123266.3129395

1 INTRODUCTIONIn recent years, the computer vision community has witnessedrapid progress thanks to deep learning methods in areas includingimage classification [2], object detection [13] and semantic segmen-tation [3]. High quality software tools are essential to keep up therapid pace of innovation in deep learning research. The qualityof a software library is hugely influenced by traditional softwarequality metrics such as consistent coding conventions and coverageof tests and documentation. In addition to that, a deep learninglibrary, specifically a library that hosts implementations of deep

Permission to make digital or hard copies of all or part of this work for personal orclassroom use is granted without fee provided that copies are not made or distributedfor profit or commercial advantage and that copies bear this notice and the full citationon the first page. Copyrights for components of this work owned by others than ACMmust be honored. Abstracting with credit is permitted. To copy otherwise, or republish,to post on servers or to redistribute to lists, requires prior specific permission and/or afee. Request permissions from [email protected] ’17, October 23–27, 2017, Mountain View, CA, USA© 2017 Association for Computing Machinery.ACM ISBN 978-1-4503-4906-2/17/10. . . $15.00https://doi.org/10.1145/3123266.3129395

learning models, needs to guarantee quality during the trainingphase. Training a machine learning model to have a good perfor-mance is difficult due to numerous details that can hinder it fromachieving its full potential. This makes it all the more importantthat a library hosts implementations of high performance trainingcode so that it can give guidance to developers and researchers whowant to extend and develop further from these implementations.We think that training code should perform on par with the per-formance reported by the paper that the implementation is basedon. On top of providing a high quality implementation for traininga model, we also aim at making it more accessible, especially forusers with limited experience, to run inference on sophisticatedcomputer vision models such as Faster R-CNN [13].

The rapid progress of deep learning research has been enabledby a number of frameworks including Chainer [15], TensorFlow [1]and PyTorch 1. These frameworks have supported fundamentalcomponents of deep learning software such as automatic differ-entiation and effective parallelization using GPUs. However, theyare intended to target general usage, and do not aim to providecomplete implementations of vision algorithms.

Our software, ChainerCV, supports algorithms to solve tasks inthe computer vision field such as object detection, while consider-ing usability and predictable performance as the top priorities. Thismakes it perfect to be used as a building block in larger softwareprojects such as robotic software systems even by developers whoare not computer vision experts. Recently there has been a growingtrend of building new neural network models using existing archi-tectures as building blocks. Examples can be seen in tasks such asinstance segmentation [8] and scene graph generation [16], whichdepend on object detection algorithms to localize objects in images.ChainerCV’s algorithms can be used as components to constructsoftware that can solve complex computer vision problems.

Training a network is a critical part of a machine learning al-gorithm, and ChainerCV is designed to make this process easy. Inmany use cases, users need a machine learning model to performwell on a particular dataset they have. Often a pretrained modelis not sufficient for the users’ tasks, and so they must re-train themodel using their datasets. To make training a model easier in suchcases, ChainerCV provides reference implementations to train mod-els, which can be used as a baseline to write new training code. Inaddition to that, pretrained models can be used together with theusers dataset to fine-tune the model. ChainerCV also provides setof tools for training a model including dataset loader, predictionevaluator and visualization tools.

1http://pytorch.org

arX

iv:1

708.

0816

9v1

[cs

.CV

] 2

8 A

ug 2

017

Reproducibility in machine learning and computer vision is oneof the most important factors affecting the quality of the research.ChainerCV aims at easing the process of reproducing the publishedresults by providing training code that is guaranteed to performon par with them. These algorithms would serve as baselines tofind a new idea through refinement and as a tool to compare a newapproach against existing approaches.

To summarize, ChainerCV offers the following two contribu-tions:

• High quality implementations of deep learning-based com-puter vision algorithms to solve problems with emphasison usability.

• Reference code and tools to train models, which is guaran-teed to perform on par with the published results.

Our code is released at https://github.com/pfnet/chainercv.

2 RELATEDWORKDeep learning frameworks such as Chainer [15] and TensorFlow [1]play a fundamental role in deep learning software. However, thesesoftware packages focus on fundamental components such as au-tomatic differentiation and GPU support. Keras [6] is a high-leveldeep learning API that is intended to enable fast experimentation.While ChainerCV shares a similar goal with Keras to enable fastprototyping, our software provides more thorough coverage ofsoftware components for the computer vision tasks. In addition tothat, Keras does not provide high performance training code forsophisticated vision models like Faster R-CNN [13].

OpenCV [10] is a prominent example of computer vision soft-ware libraries supporting numerous highly tuned implementations.The library supports wide range of algorithms including somedeep learning-based algorithms, which emphasize on running in-ference on a cross platform environment. Different from their work,ChainerCV aims at acceralating research in this field in a morecomprehensive manner by providing high quality training code ontop of implementations to conduct inference.

Orthogonal to our open source work, there are several propri-etary software solutions that support computer vision algorithmsbased on deep learning. These include Computer Vision SystemToolbox by MATLAB and Google Cloud Vision API by GoogleCloud Platform.

Model Zoo hosts a number of open source implementationsand their trained models. Algorithms for a wide range of tasksare hosted on their website, but they are not provided as a librarythat organizes code in some standardized manner. There are opensource implementations released by the authors of papers and third-party implementations released by open source developers. Theprimarily aim of these works is to make a prototype of a researchidea. Unlike them, one of our goals is to develop an implementationthat follows a good software engineering practices so that it isreadable and easily extendable to other projects. We assure thequality by developing through peer review process, and thoroughcoverage of documentations and tests.

More closely related to our work is pytorch/vision, which is acomputer vision library that uses PyTorch as its backend. Similarto our work, it hosts pretrained models to let users use high perfor-mance convolutional neural networks off-the-shelf. At the time of

.

chainercv

datasets: Dataset loaders

evaluations: Evaluation metrics

links: Neural network models

transforms: Transform functions

visualizations: Visualization functions

examples: Training and demo codes for networks

Figure 1: Directory structure of ChainerCV

writing, its support for pretrained model and data preparation arelimited only to classification tasks.

3 IMPLEMENTATION3.1 Task Specific ModelsCurrently, ChainerCV supports networks for object detection andsemantic segmentation (Figure 1). Object detection is the task offinding objects in an image and classifying them. Semantic segmen-tation is the task of segmenting an image into pieces and assigningobject labels to them.

We implemented our detection algorithms in a unifying man-ner by exploiting the fact that many of the leading state of theart architectures have converged on a similar structure [9]. All ofthese architectures use convolutional neural networks to extractfeatures and use sliding windows to predict localization and clas-sification. Our implementation includes architectures that can begrouped by Faster R-CNN [13] and Single Shot Multibox Detector(SSD) [11] meta-architectures. Faster R-CNN takes a crop proposedby an external neural network called Region Proposal Networksand carry out classification on the crop of the input image. SSD triesto alleviate the extra time running Region Proposal Networks by di-rectly predicting classes and coordinates of bounding boxes. Thesemeta-architectures are instantiated into more concrete networksthat have different feature extractors or different head architectures.These different implementations inherit from the base class for eachmeta-architecture using our flexible class design.

Our implementation of semantic segmentation models includesSegNet [3]. The architecture follows an encoder-decoder style. Wehave separated a module to calculate loss from a network thatpredicts a probability map. This design makes the loss reusable inother implementation of semantic segmentation models, which weare planning to add in the future.

Models for a certain task are designed to have a common inter-face. For example, detection models support a predictmethod thattakes images and outputs bounding boxes around regions whereobjects are predicted to be located. The common interface allowsusers to swap different models easily inside their code. On top ofthat, the common interface is necessary to build functions thatinteract with neural network models by passing input images andreceiving predictions. For instance, thanks to this interface, we

from ch a i n e r c v . d a t a s e t s import ∗from ch a i n e r c v . t r an s f o rms import ∗

d a t a s e t = VOCDetec t ionDatase t ( )

def f l i p _ t r a n s f o rm ( i n _d a t a ) :img , bbox , l a b e l = i n _d a t aimg , param = random_ f l i p (

img , x _ f l i p =True ,re turn_param=True )

bbox = f l i p _ b b o x (bbox , x _ f l i p =param [ ' x _ f l i p ' ] )

return img , bbox , l a b e l

new_da ta se t = Trans fo rmData se t (d a t a s e t , f l i p _ t r a n s f o rm )

Figure 2: Code to preprocess data using TransformDataset

can write a function that iterates over a dataset and visualizes thepredictions of all the samples.

3.2 DatasetsIn order to train and evaluate deep learning models, datasets areneeded. ChainerCV provides an interface to datasets commonlyused in computer vision tasks, such as datasets from the PascalVOC Challenge [7]. The datasets object downloads data from theInternet if necessary, and returns requested contents with an array-like interface.

3.3 TransformsA transform is a function that takes an image and annotationsas inputs and applies a modification to the inputs such as imageresizing. These functions are composed together to create a customdata preprocessing pipeline.

ChainerCV uses TransformDataset to compose different trans-forms. This is a class that wraps around a dataset by applying afunction to a sample retrieved from the underlying dataset, whichis often prepared to simply load data from a file system withoutany modifications.

We found that extending a dataset with an arbitrary function iseffective especially in the case where multiple objects are processedin an interdependent manner. Such interdependence of transformshappen in a scenario when an image is randomly flipped horizon-tally to augment a dataset and coordinates of bounding boxes arealtered depending on whether the image is flipped or not. See Fig-ure 2 for the code to carry out the data preprocessing pipeline.

3.4 Visualizations and Evaluation MetricsChainerCV supports a set of functions for visualization and eval-uation, which are important for conducting research in computervision. These functions can be used across different models by en-forcing a consistent data representation for each type of data. Forexample, an image array is assumed to be RGB and shaped as (C,H, W), where the elements of the tuple are channel size, height andwidth of the image. The evaluations and visualizations in Section 4are carried out using the functions in ChainerCV.

Table 1: Object detection mean average precision (%).

Implementations Faster R-CNN SSD300 SSD512Original 69.9 [13] 77.5 [5] 79.5 [5]

ChainerCV 70.5 77.5 80.1

3.5 GPU ArraysAs done in Chainer [15], ChainerCV uses cupy.ndarray to repre-sent arrays stored in GPU memory and numpy.ndarray to repre-sent arrays stored in CPU memory. CuPy 2 is a NumPy like multi-dimensional array library with GPU acceleration. Many functionsin ChainerCV support both types as arguments, and returns theoutput with the same type as the input. These functions includenon-maximum suppression [12], which is efficiently implementedusing CUDA parallelization. It is often complicated to set up a li-brary to call CUDA kernels from a python module because theinstallation needs to consider a variety of machine configurations.ChainerCV relies on CuPy when calling CUDA kernels, and itsinstallation procedure is quite simple.

4 EXPERIMENTSWe report performance of the implemented training code, and verifythat the scores are on par with the ones reported in the originalpapers. Note that due to randomness in training, it is inevitable toproduce slightly different scores from the original papers.

4.1 Faster R-CNNWe evaluated the performance of our implementation of FasterR-CNN, and compared it to the performance reported in the orig-inal paper [13]. We experimented with a model that uses VGG-16 model [14] as a feature extractor. The model is trained on thePASCAL VOC detection dataset. The model is trained on the 2007trainval and evaluated on 2007 test using our training code.Some detection results of this trained model are shown in Figure 3a.The performance is compared against the original implementationusing mean average precision in Table 1. Due to the stochastic train-ing process, it is known that the final performance fluctuates [4].

4.2 Single Shot Multibox Detector (SSD)We evaluated the performance of our implementations of SSD300and SSD512, and compared them to the performance reported in [5].We trained these models with the trainval splits of PASCAL VOC2007 and 2012 for training. The performance is compared against theoriginal implementation using mean average precision in Table 1.Note that we changed the train batchsize of SSD512 from 32 to 24due to the GPU memory limitation. We also show some detectionresults of SSD512 in Figure 3b.

4.3 SegNetWe evaluated the performance of our SegNet implementation, andcompared it to the performance reported in the journal version ofthe original paper [3]. It is trained on the train split of CamVid [3],and evaluated on the test split. The performance is measured by2https://github.com/cupy/cupy

(a) Faster R-CNN (b) SSD512 (c) SegNet (top: input, bottom: output)

Figure 3: Example visualizations. (a, b) Visualizations of object detection and (c) visualizations of semantic segmentation.

Table 2: Semantic segmentation performance of SegNet.

pixel accuracy mean pixel accuracy mIoUOriginal [3] 82.7 62.3 46.3ChainerCV 82.8 67.1 47.2

pixel accuracy, mean pixel accuracy and mean IoU, which are themetrics used in [3]. The score is shown in Table 2 and an exampleresult is shown in Figure 3c.

5 CONCLUSIONIn this article we have introduced a new computer vision softwarelibrary that focuses on deep learning-based methods. Our softwarelowers the barrier of entry to use deep learning-based computervision algorithms by providing a convenient and unified interface. Italso provides evaluation and visualization tools to aid research anddevelopment in the field. Our implementation achieves performanceon par with the reported results, and we expect it to be used as abaseline to be extended with new ideas.

ACKNOWLEDGEMENTWe would like to thank Richard Calland for helpful discussion.

REFERENCES[1] Martín Abadi, Ashish Agarwal, Paul Barham, Eugene Brevdo, Zhifeng Chen,

Craig Citro, Greg S. Corrado, Andy Davis, Jeffrey Dean, Matthieu Devin, San-jay Ghemawat, Ian Goodfellow, Andrew Harp, Geoffrey Irving, Michael Isard,Yangqing Jia, Rafal Jozefowicz, Lukasz Kaiser, Manjunath Kudlur, Josh Leven-berg, Dan Mané, Rajat Monga, Sherry Moore, Derek Murray, Chris Olah, MikeSchuster, Jonathon Shlens, Benoit Steiner, Ilya Sutskever, Kunal Talwar, Paul

Tucker, Vincent Vanhoucke, Vijay Vasudevan, Fernanda Viégas, Oriol Vinyals,Pete Warden, Martin Wattenberg, Martin Wicke, Yuan Yu, and Xiaoqiang Zheng.2015. TensorFlow: Large-Scale Machine Learning on Heterogeneous Systems.(2015). tensorflow.org

[2] Ilya Sutskever Alex Krizhevsky and Geoffrey E Hinton. 2012. ImageNet Classifi-cation with Deep Convolutional Neural Networks. In NIPS. 1097–1105.

[3] Vijay Badrinarayanan, Alex Kendall, and Roberto Cipolla. 2017. SegNet: A DeepConvolutional Encoder-Decoder Architecture for Image Segmentation. PAMI(2017).

[4] Xinlei Chen and Abhinav Gupta. 2017. An Implementation of Faster RCNN withStudy for Region Sampling. arXiv preprint arXiv:1702.02138 (2017).

[5] Ananth Ranga Ambrish Tyagi Cheng-Yang Fu, Wei Liu and Alexander C.Berg. 2017. DSSD : Deconvolutional Single Shot Detector. arXiv preprintarXiv:1701.06659 (2017).

[6] François Chollet and others. 2015. Keras. github.com/fchollet/keras. (2015).[7] M. Everingham, L. Van Gool, C. K. I. Williams, J. Winn, and A. Zisserman. 2010.

The Pascal Visual Object Classes (VOC) Challenge. IJCV 88, 2 (June 2010),303–338.

[8] Kaiming He, Georgia Gkioxari, Piotr DollÃąr, and Ross Girshick. 2017. MaskR-CNN. arXiv preprint arXiv:1703.06870 (2017).

[9] Jonathan Huang, Vivek Rathod, Chen Sun, Menglong Zhu, Anoop Korattikara,Alireza Fathi, Ian Fischer, ZbigniewWojna, Yang Song, Sergio Guadarrama, KevinMurphy, and Google Research. 2016. Speed/accuracy trade-offs for modernconvolutional object detectors. arXiv preprint arXiv:1611.10012 (2016).

[10] Itseez. 2015. OpenCV. (2015). github.com/itseez/opencv[11] Wei Liu, Dragomir Anguelov, Dumitru Erhan, Christian Szegedy, Scott Reed,

Cheng-yang Fu, and Alexander C Berg. 2016. SSD: Single Shot MultiBox Detector.arXiv preprint arXiv:1512.02325v2 (2016).

[12] D. Oro, C. FernÃąndez, X. Martorell, and J. Hernando. 2016. Work-efficientparallel non-maximum suppression for embedded GPU architectures. In ICASSP.

[13] Shaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun. 2015. Faster R-CNN:Towards Real-Time Object Detection with Region Proposal Networks. arXivpreprint arXiv:1506.01497v1 (2015).

[14] K. Simonyan and A. Zisserman. 2015. Very Deep Convolutional Networks forLarge-Scale Image Recognition. In ICLR.

[15] Seiya Tokui, Kenta Oono, Shohei Hido, and Justin Clayton. 2015. Chainer: aNext-Generation Open Source Framework for Deep Learning. In Proceedings ofWorkshop on Machine Learning Systems in NIPS.

[16] Danfei Xu, Yuke Zhu, Christopher Choy, and Li Fei-Fei. 2017. Scene GraphGeneration by Iterative Message Passing. In CVPR.