Wunda deeplearning Automatic driving target detection

Source: Internet
Author: User
Tags abs keras

Wunda Automatic driving target detection data set: Automatic driving target detection autonomous Driving-car detection

Welcome to your Week 3 programming assignment. You'll learn about object detection using the very powerful YOLO model. Many of the ideas in this notebook is described in the YOLO Papers:redmon et al., (https://arxiv.org/abs/1506.0 2640) and Redmon and Farhadi, (https://arxiv.org/abs/1612.08242).

You'll learnto:
-use object detection on a car detection dataset
-Deal with bounding boxes

Run the following cell to load the packages and dependencies that is going to being useful for your journey!

Import argparse
import OS
import Matplotlib.pyplot as plt from
matplotlib.pyplot import imshow
Import Scipy.io
Import scipy.misc
import numpy as NP
import pandas as PD
import PIL
import TensorFlow as tf< C9/>from Keras Import backend as K from
keras.layers import Input, Lambda, conv2d from
keras.models import Load_ Model, model from
yolo_utils import read_classes, read_anchors, Generate_colors, Preprocess_image, Draw_boxes, Scale_boxes from
yad2k.models.keras_yolo import Yolo_head, Yolo_boxes_to_corners, Preprocess_true_boxes, Yolo_ Loss, Yolo_body

%matplotlib Inline

Important Note: As can see, we import Keras ' s backend as K. This means is Keras function in this notebook and you'll need to write:k.function (...). 1-problem Statement

You is working on a self-driving car. As a critical component of this project, you ' d like to first build a car detection system. To collect data, your ' ve mounted a camera to the hood (meaning the front) of the car, which takes pictures of the road Ahea D Every few seconds while you drive around.




Pictures taken from a car-mounted camera while driving around Silicon Valley.
We would like to especially thank Drive.ai for providing this dataset! Drive.ai is a company building the brains of self-driving vehicles.

You ' ve gathered all these images into a folder and has labelled them by drawing bounding boxes around every car you found . Here's a example of what your bounding boxes look like.


If you have the classes so want YOLO to recognize, you can represent the class label C c either as a integer from 1 To-80-dimensional vector (with numbers) one component of which was 1 and the rest of which are 0. The video lectures had used the latter representation; In this notebook, we'll use the both representations, depending on which are more convenient for a particular step.

In this exercise, you'll learn how YOLO works and then apply it to car detection. Because The YOLO model is very computationally expensive to train, we'll load pre-trained weights for your use. 2-yolo

YOLO ("Once") is a popular algoritm because it achieves high accuracy while also being able to run in Real-t Ime. This algorithm ' only looks once ' at the ' in the ' sense ' it requires only one forward propagation pass through the Network to make predictions. After Non-max suppression, it then outputs recognized objects together with the bounding boxes. 2.1-model Details

First things to know:
-The input is a batch of images of shape (m, 608, 608, 3)
-The output is a list of bounding boxes along with the recognized classes. Each bounding box was represented by 6 numbers (Pc,bx,by,bh,bw,c) (P_c, b_x, b_y, B_h, B_w, c) as explained above. If you expand C to an 80-dimensional vector, each bounding box was then represented by numbers.

We'll use 5 anchor boxes. So you can think of the YOLO architecture as the Following:image (M, 608, 608, 3) and deep CNN, ENCODING (M, 19, 1 9, 5, 85).

Lets Look in greater detail @ What's this encoding represents.

If the Center/midpoint of an object falls to a grid cell, that grid cell was responsible for detecting that object.

Since we is using 5 anchor boxes, each of the x19 cells thus encodes information about 5 boxes. Anchor boxes is defined only by their width and height.

For simplicity, we'll flatten the last of dimensions of the shape (5, $) encoding. The output of the deep CNN is (19, 19, 425).

Now, for each box (of each cell) we'll compute the following elementwise product and extract a probability that the box Contains a certain class.


Here's one-to-visualize-what-YOLO is predicting in an image:
-For each of the 19x19 grid cells, find the maximum of the probability scores (taking a max across both the 5 anchor Boxe s and across different classes).
-Color that grid cell according to what object, the grid cell considers the most likely.

Doing This results in the picture:

Note that this visualization isn ' t a core part of the YOLO algorithm itself for making predictions; It's just a nice to visualizing an intermediate result of the algorithm.

Another to visualize YOLO's output is to plot the bounding boxes that it outputs. Doing that results in a visualization like this:


In the figure above, we plotted only boxes and the model had assigned a high probability to, it is still too many B Oxes. You ' d like to filter the algorithm's output to a much smaller number of detected objects. You'll use the Non-max suppression. Specifically, you'll carry out these steps:
-Get rid of boxes with a low score (meaning, the box isn't very confident about detecting a class)
-Select Only one box is several boxes overlap with each other and detect the same object. 2.2-filtering with a threshold on class scores

You is going to the apply a first filter by thresholding. You would like to get rid of any box for which the class "score" is less than a chosen threshold.

The model gives you a total of 19x19x5x85 numbers, with each box described by numbers. It ' ll be convenient to rearrange the (19,19,5,85) (or (19,19,425)) dimensional tensor into the following variables:
-Box_confidence:tensor of Shape (19x19,5,1) (\times, 5, 1) containing PC P_c (confidence probability that there ' s Some object) for each of the 5 boxes predicted in each of the 19x19 cells.
-Boxes:tensor of Shape (19x19,5,4) (\times, 5, 4) containing (BX,BY,BH,BW) (b_x, b_y, B_h, B_w) for each of the 5 Boxes per cell.
-Box_class_probs:tensor of Shape (19x19,5,80) (\times, 5,) containing the detection probabilities (C1,C2,... C80 ) (C_1, c_2, ... c_{80}) for each of the 5 boxes per cell.

Exercise: Implement yolo_filter_boxes ().
1. Compute box scores by doing the Elementwise product as described in Figure 4. The following code may and choose the right operator:

A = Np.random.randn (19*19, 5, 1)
B = Np.random.randn (19*19, 5, D)
C = A * b # shape of C would be (19*19, 5, 80)
For each box, find:
The index of the class with the Maximum box score (Hint) (being careful with what axis you choose; consider using axis=-1) th e corresponding box score (Hint) (Be careful with what axis you choose; consider using axis=-1) Create a mask by using a T Hreshold. As a reminder: ([0.9, 0.3, 0.4, 0.5, 0.1] < 0.4) returns: [False, True, False, False, true]. The mask should BES is True for the boxes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.