Learn practical skills, build real-world projects, and advance your career

Autonomous driving - Car detection

Welcome to your week 3 programming assignment. You will learn about object detection using the very powerful YOLO model. Many of the ideas in this notebook are described in the two YOLO papers: Redmon et al., 2016 and Redmon and Farhadi, 2016.

You will learn to:

  • Use object detection on a car detection dataset
  • Deal with bounding boxes

Updates

If you were working on the notebook before this update...
  • The current notebook is version "3a".
  • You can find your original work saved in the notebook with the previous version name ("v3")
  • To view the file directory, go to the menu "File->Open", and this will open a new tab that shows the file directory.
List of updates
  • Clarified "YOLO" instructions preceding the code.
  • Added details about anchor boxes.
  • Added explanation of how score is calculated.
  • yolo_filter_boxes: added additional hints. Clarify syntax for argmax and max.
  • iou: clarify instructions for finding the intersection.
  • iou: give variable names for all 8 box vertices, for clarity. Adds width and height variables for clarity.
  • iou: add test cases to check handling of non-intersecting boxes, intersection at vertices, or intersection at edges.
  • yolo_non_max_suppression: clarify syntax for tf.image.non_max_suppression and keras.gather.
  • "convert output of the model to usable bounding box tensors": Provides a link to the definition of yolo_head.
  • predict: hint on calling sess.run.
  • Spelling, grammar, wording and formatting updates to improve clarity.

Import libraries

Run the following cell to load the packages and dependencies that you will find useful as you build the object detector!

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
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
Using TensorFlow backend.

Important Note: As you can see, we import Keras's backend as K. This means that to use a Keras function in this notebook, you will need to write: K.function(...).