5
Object Detection Implementation Rene Reyes UTRGV Edinburg, Texas Ryan Luna UTRGV Edinburg, Texas Abstract—This study is aimed at developing an online ser- vice by implementing object detection remotely to surveillance cameras. We propose both real-time and none real-time imple- mentation method of services. Open source code was analyzed, modify and implemented in order to analyze what type of com- plications we can run into when providing the fastest and most accurate service possible. Three convolutions neural networks architectures implementations were analyzed using only a CPU and Python3. Index Terms—component, formatting, style, styling, insert I. I NTRODUCTION There have been many advancements in security systems within the past decade. A major contribution to these advance- ments are recent developments in various subfields of Machine Learning. Object detection is one of these subfields and is also the focus of our project. Security surveillance systems can use object detection to detect suspicious activity, vehicles involved in a crime, dangerous objects, and other security concerning matters. Some difficulties arise when trying to select the right architecture for the job. Deep Learning based surveillance systems use both real-time and non-real-time object detection. Our project explores different methods of Object Detection along with their potential uses and downsides. When it comes to real-time object detection surveillance systems, we want speed. If our network architecture is too complex this increases the amount of time it takes for the network to process a frame in a video. With a low fps (frames per second) rate, the system risks missing crucial parts of a crime or activity. Unfortunately, the downside to using a less complex architecture to increase the fps, is that it decreases the accuracy of detecting objects. While a complex architecture is detrimental to real-time object detection, it serves as a great option for post processing of security footage. For non- real-time object detection applications, high accuracy is most desirable. Our goal for this project is to find an optimal method for real-time object detection. The method we want is one that can achieve decent fps while maintaining high accuracy. In addition, we also aim to create an online application able to run high accuracy object detection. II. OBJECT DETECTION Deep Learning is a branch of Machine Learning which is based on the layers used in artificial neural networks. Deep learning architectures are used in a variety of fields, including computer vision. [9] Object detection is a subfield of computer vision that deals with detecting semantic objects in images or videos and dividing them into their respective classes (human, vehicle, building, etc..). [14] Various types of network architectures are used in objected detection and have their own advantages and disadvantages. Popular architectures include, YOLO (You Only Look Once), Faster R-CNN (Region-based Convolutional Neural Network), Mask R-CNN, and various other RPN (Regional Proposal Network) based networks. Object detection works by running image classification alongside object localization. Image classification simply clas- sifies the image by extracting features and running it through a ConvNet (Convolutional Network). Object localization deals with locating where an object is within a given image. Localization is responsible for generating multiple regions to run image classification on. The differences amongst the architectures weve mentioned lies mostly with the method they use for region proposals. A. R-CNN, Faster R-CNN and Mask R-CNN Choosing when and how to implement region proposals largely affects the speed of object detection. R-CNN, a pre- decessor to Faster R-CNN, uses selective search to generate region proposals before running feature extraction. In doing this, R-CNN is left to run feature extraction and image classification on an excessive number of regions, increasing the time it takes to run both inference and training on the model. [8] Faster R-CNN drastically reduces the run time by changing when the regions are proposed. Feature extraction is done before the RPN proposes its regions. This lets the network run region proposals on a high-level feature map. By doing this, the RPN is able to use the high-level features to more accurately generate the ROIs (Regions Of Interest). Less regions are proposed due to the semantic rich feature map functioning to filter out irrelevant features. [11] Fig. 1. R-CNN flowchart [8]

Object Detection Implementation - UTRGV Faculty WebDeep Learning is a branch of Machine Learning which is based on the layers used in artificial neural networks. Deep learning architectures

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Object Detection Implementation - UTRGV Faculty WebDeep Learning is a branch of Machine Learning which is based on the layers used in artificial neural networks. Deep learning architectures

Object Detection ImplementationRene Reyes

UTRGVEdinburg, Texas

Ryan LunaUTRGV

Edinburg, Texas

Abstract—This study is aimed at developing an online ser-vice by implementing object detection remotely to surveillancecameras. We propose both real-time and none real-time imple-mentation method of services. Open source code was analyzed,modify and implemented in order to analyze what type of com-plications we can run into when providing the fastest and mostaccurate service possible. Three convolutions neural networksarchitectures implementations were analyzed using only a CPUand Python3.

Index Terms—component, formatting, style, styling, insert

I. INTRODUCTION

There have been many advancements in security systemswithin the past decade. A major contribution to these advance-ments are recent developments in various subfields of MachineLearning. Object detection is one of these subfields and is alsothe focus of our project. Security surveillance systems can useobject detection to detect suspicious activity, vehicles involvedin a crime, dangerous objects, and other security concerningmatters.

Some difficulties arise when trying to select the rightarchitecture for the job. Deep Learning based surveillancesystems use both real-time and non-real-time object detection.Our project explores different methods of Object Detectionalong with their potential uses and downsides.

When it comes to real-time object detection surveillancesystems, we want speed. If our network architecture is toocomplex this increases the amount of time it takes for thenetwork to process a frame in a video. With a low fps (framesper second) rate, the system risks missing crucial parts of acrime or activity. Unfortunately, the downside to using a lesscomplex architecture to increase the fps, is that it decreases theaccuracy of detecting objects. While a complex architectureis detrimental to real-time object detection, it serves as agreat option for post processing of security footage. For non-real-time object detection applications, high accuracy is mostdesirable.

Our goal for this project is to find an optimal method forreal-time object detection. The method we want is one thatcan achieve decent fps while maintaining high accuracy. Inaddition, we also aim to create an online application able torun high accuracy object detection.

II. OBJECT DETECTION

Deep Learning is a branch of Machine Learning which isbased on the layers used in artificial neural networks. Deeplearning architectures are used in a variety of fields, including

computer vision. [9] Object detection is a subfield of computervision that deals with detecting semantic objects in imagesor videos and dividing them into their respective classes(human, vehicle, building, etc..). [14] Various types of networkarchitectures are used in objected detection and have their ownadvantages and disadvantages. Popular architectures include,YOLO (You Only Look Once), Faster R-CNN (Region-basedConvolutional Neural Network), Mask R-CNN, and variousother RPN (Regional Proposal Network) based networks.

Object detection works by running image classificationalongside object localization. Image classification simply clas-sifies the image by extracting features and running it througha ConvNet (Convolutional Network). Object localization dealswith locating where an object is within a given image.Localization is responsible for generating multiple regionsto run image classification on. The differences amongst thearchitectures weve mentioned lies mostly with the method theyuse for region proposals.

A. R-CNN, Faster R-CNN and Mask R-CNN

Choosing when and how to implement region proposalslargely affects the speed of object detection. R-CNN, a pre-decessor to Faster R-CNN, uses selective search to generateregion proposals before running feature extraction. In doingthis, R-CNN is left to run feature extraction and imageclassification on an excessive number of regions, increasingthe time it takes to run both inference and training on themodel. [8] Faster R-CNN drastically reduces the run time bychanging when the regions are proposed. Feature extractionis done before the RPN proposes its regions. This lets thenetwork run region proposals on a high-level feature map. Bydoing this, the RPN is able to use the high-level features tomore accurately generate the ROIs (Regions Of Interest). Lessregions are proposed due to the semantic rich feature mapfunctioning to filter out irrelevant features. [11]

Fig. 1. R-CNN flowchart [8]

Page 2: Object Detection Implementation - UTRGV Faculty WebDeep Learning is a branch of Machine Learning which is based on the layers used in artificial neural networks. Deep learning architectures

Fig. 2. R-CNN flowchart [8]

Mask R-CNN is an extension of Faster R-CNN. It adds abranch to generate a mask for an object in parallel with thebranch for bounding box recognition. It also uses the ROIAlignmethod instead of ROI Pooling to more accurately preservespatial locations in an area. [5] Preserving the spatial locationis important when using a FPN (Feature Pyramid Network)because the upscaling and downscaling of an image can causean ROI to encase the wrong region. [13] Mask R-CNN canbe split into two stages. The 1st stage is a light-weightRPN which scans the FPN top-bottom pathway and proposesregions within the image where objects may reside. The 2ndstage is another neural network that takes the proposed regionsand assigns them to specific areas of a feature map level. Thisis done by using the ROIAlign technique to locate the relevantareas in the feature map. After assigning the regions, it scansthose same areas and then generates the object class, boundingbox, and mask. [14]

Fig. 3. Mask R-CNN flowchart [8]

B. YOLO and Tiny-YOLO

YOLOv3 (You Only Look Once) has an architecture similarto that of a FCNN (Fully Connected Neural Network. It

also uses an FPN for high-level feature extraction. RPNs rundetection and prediction on multiple regions. While it doesyield exceptional accuracy, it adds to the time it takes to runinference on the image. [8] YOLO tackles this issue by usinga different technique. It passes the image once through theFCNN which splits the image (n x n) into several (S x S)grid cells. YOLO then generates a class probability map alongwith bounding boxes and confidence scores. Unfortunately,this model only predicts one set of class probabilities per gridcell. For that reason, YOLO runs into an issue with instancesegmentation on smaller objects as well as clusters of objects.[12] Tiny-YOLO is a descendant of YOLO dedicated to runfaster at the sacrifice of its accuracy. This is achieved byscaling down the size of its tensors. Due to the decrease insemantics as a result of a lower resolution, it takes less timeto run detection on an image. [8]

III. NONE REAL-TIME OBJECT DETECTION WEBSITEIMPLEMENTATION

The website design we propose is aimed at providing objectdetection service by allowing users to upload images andvideos to the server, processing it and making the resultsavailable for the user to access. However, to simplify areimplementation we used only images. Two of the of theproblem we will initially be considering are what languageor framework to use, how to processes requests from multipleconsumers, and provide asynchronous communication to showprogress?

A. Django, Celery and RabbitMQ

Since the code we are working with is in python, we willbe using Django. Django is a web framework that is written inpython, most of all it is very secure and scalable. Django alsoallows developers to start developing quickly, by generatingDjango projects and apps quickly command.

Fig. 4. This is how Django generates and organizes files. On the left yougot the main project that takes care of configuring and running the website,and on the right side is an example of a Django application called polls. Asyou can see, the main infrastructure is generated allowing developers to startdevelopment quickly.

Celery is an asynchronous task queue/job queue basedon distributed message passing. It is focused on real-timeoperation, but supports scheduling as well [1]. RabbitMQ isan open source message broker [2].

Page 3: Object Detection Implementation - UTRGV Faculty WebDeep Learning is a branch of Machine Learning which is based on the layers used in artificial neural networks. Deep learning architectures

By combing Django, Celery and RabbitMQ, we can useRabbitMQ to communicate between Django and Celery. Auser on the website will send a task request, RabbitMQforwards the message to Celery’s queue. Once the task isin queue it waits for its turn while other tasks are finishing.Celery has work nodes that processes a task at a time, thusthe number of task we can process at a time is limited tothe number of workers. But increasing the number of workersmeans more CPU usage, thus there must be a balance betweenCPU and number of workers. In our implementation we usedonly one worker. The workers then update their progress toa database, allowing users to check their task progress bychecking the database.

Fig. 5. The diagram shows how Django, RabbitMQ and Celery communicate.Django requests a task to RabbitMQ, RabbitMQ passes down the requests tothe Celery workers and performs the task when ready.

IV. REAL-TIME OBJECT DETECTION IMPLEMENTATION

Our implementation of real-time object detection was im-plemented as simple as possible. The ideal device for this im-plementation would be a camera, that can connect to a networkand allowing us to process the captured frames and displayingthe processed images live. To simplify our implementation,we don’t consider concurrent users or multiple cameras. And,analyze the accuracy and average time to process each frame.

We developed a simple Android application, using Unity,that uses the camera on the phone to capture a frame andupdates an image on some machine through http by overwrit-ing at some time interval. A Google Cloud virtual was usedin this case, and using a VNC (virtual network computing)viewer displayed the results in real-time.

V. RESULTS

For the web application, we decided to go with Mask R-CNN due to its high accuracy. The figure below is a snapshotof the website. Here, we can see the form that is used toupload an image to the site. Once the image is uploaded, theserver uses the pre-trained Mask R-CNN model to run objectdetection and generate a new image. When finished, it saves

Fig. 6. The frames first get processed first on some server before displayingthe frame on the main screen. This could be done through LAN or WAN.

the new image to the database and allows users to view theresults. MaskR-CNN took an average of 7.5 seconds to runinference on the given image and display back to the user.

Fig. 7. Snipping of the website.

For our real-time implementation, we worked with YOLOv3and Tiny-YOLOv3. YOLOv3 took an average of 0.75 secondsper image. Tiny-YOLOv3 took an average of 0.65 seconds perimage, but was far less accurate than the YOLOv3.

VI. FUTURE WORK

The work we did gave us a lot of ideas for softwareproducts, the problems that we would be running into andideas on how to solve them. One of these problems washow to deal with the multiple users, if many users are it canmake are servers very slow. In the case of the website thatwe implemented, finding a balance in the amount of celeryworkers and how many pool process is the key for makingthe website efficient.

For real time object detection, we need in to insure toprocess images faster at the expense of less accuracy. In realtime object detection we find that it’s not too bad if the objectis not detected at exactly every frame. A miss per frame ratecould be evaluated to satisfy some guaranteed value. In thecase of providing real time object detection to multiple users,GPU would have to be utilized in order to process the imagesfaster. For large number of users we have consider to use a

Page 4: Object Detection Implementation - UTRGV Faculty WebDeep Learning is a branch of Machine Learning which is based on the layers used in artificial neural networks. Deep learning architectures

Fig. 8. Top is using YOLOv3 and the bottom is using Tiny-YOLOv3.

file distribution system, like Hadoop, in order to process manyframes from many users as evenly as possible among manyservers and GPUs.

A. Surveillance

One of the many motivation for this project was securityby applying object detection to surveillance camera in realtime. Surveillance camera are useful for keeping watch andrecording criminal activity. However, not all cameras are beingmonitored by people, and motion detectors can be used to alertif anything moves, but does not specify what it could be. Byapplying YOLOv3 with a GPU, we could implement objectdetection to surveillance cameras in real time, and it wouldbe fast and accurate. Number of people and facial detectioncould also be implemented in order to find out who and howmany people are present at the moment. This would be usefulnot only to notify someone remotely if someone is or isn’t ina the area, but also to detect if someone that is not allowed inthe area is present.

Fig. 9. Object detection can be used in surveillance cameras to detect whois or who isn’t in an indicated area, as well as, how many people are in thearea.

B. Search In a Vast or Overcrowded Areas

We find that object detect is very useful for finding objectsin vast or overcrowded area, because it could be overwhelmingfor any person to have to perform such search, especially forobjects that are small or far away. What it could take a personhours to search through, it would take a machine only thetime it takes to process the image, which could be minutesor seconds. However, object detection is still not perfect atdetecting everything, it depends a lot on the images as well.Objects that are small or/and far away could be hard to detectbecause it would have a very low resolution, and features ofthe object might be to vague for the machine to detect.

A solution problem had been proposed by [3], using aGenerative Adversarial Network to super-resolved small ob-jects, called Perceptual Generative Adversarial Network. Thisis done by feeding the low resolution representation of theobject, and creating a super-resolved representation of theobject and testing it against the discriminator.

Fig. 10. A diagram depicting how a Perceptual Generative AdversarialNetwork works. As you can see the Perceptual GAN can give a close isit estimation of a high resolution representation of the object.

By implementing this method to super-resolved objects thatare too small or too far a way to detect, we can developsoftware for assisting people to search for objects. An Androidapp can be used to, to assist people in searching for objectsor people in crowded areas. Implementing this into a drone orsatellite images can be utilized for searching and pin pointingwhere people lost in large areas are located.

REFERENCES

[1] Distributed Task Queue. (n.d.). Retrieved fromhttp://www.celeryproject.org/

[2] RabbitMQ Summit 2019Call for papers! (n.d.). Retrieved fromhttps://www.rabbitmq.com/

[3] Li, J., Liang, X., Wei, Y., Xu, T., Feng, J., and Yan, S. (2017). PerceptualGenerative Adversarial Networks for Small Object Detection. 2017 IEEEConference on Computer Vision and Pattern Recognition (CVPR).

[4] Matterport. (2019, March 09). Matterport/Mask RCNN. Retrieved fromhttps://github.com/matterport/Mask RCNN

[5] He, K., Gkioxari, G., Dollar, P., and Girshick, R. (2018). Mask R-CNN.IEEE Transactions on Pattern Analysis and Machine Intelligence, 1-1.doi:10.1109/tpami.2018.2844175

[6] YOLO object detection with OpenCV. (2019, February 04). Re-trieved from https://www.pyimagesearch.com/2018/11/12/yolo-object-detection-with-opencv/

[7] Object detection. (2019, January 16). Retrieved fromhttps://en.wikipedia.org/wiki/Object detection

Page 5: Object Detection Implementation - UTRGV Faculty WebDeep Learning is a branch of Machine Learning which is based on the layers used in artificial neural networks. Deep learning architectures

[8] Hui, J. (2018, March 18). Real-time Object Detectionwith YOLO, YOLOv2 and now YOLOv3. Retrieved fromhttps://medium.com/@jonathan hui/real-time-object-detection-with-yolo-yolov2-28b1b93e2088

[9] Deep learning. (2019, April 28). Retrieved fromhttps://en.wikipedia.org/wiki/Deep learning

[10] Agarwal, R. (2018, September 22). Object Detection using DeepLearning Approaches: An End to End Theoretical Perspective.Retrieved from https://towardsdatascience.com/object-detection-using-deep-learning-approaches-an-end-to-end- theoretical-perspective-4ca27eee8a9a

[11] Ren, S., He, K., Girshick, R., and Sun, J. (2016, January 6).Faster R-CNN: Towards Real-Time Object Detection with RegionProposal Networks [Scholarly project]. In Arvix. Retrieved fromhttps://arxiv.org/abs/1506.01497

[12] Redmon, J., Farhadi, A. (2018, April 8). YOLOv3: An Incre-mental Improvement [Scholarly project]. In Arxiv. Retrieved fromhttps:/Aarxiv.org/abs/1804.02767

[13] Hui, J. (2018, March 27). Understanding Feature PyramidNetworks for object detection (FPN). Retrieved fromhttps://medium.com/@jonathanhui/understanding − feature −pyramid − networks − for − object − detection − fpn −45b227b9106c

[14] Zhang, X. (2018, April 22). Simple Understanding of Mask RCNN.Retrieved from https://medium.com/@alittlepain833/simple-understanding-of-mask-rcnn-134b5b330e95