《深度学习——Andrew Ng》第四课第三周编程作业

第三周的课程是目标检测 ,编程作业是以yolo网络为主。编程作业的主要部分是对yolo网络输出进行
anchor boxes过滤IOU过滤非极大抑制处理

理论知识

交并比(Intersection-over-Union,IoU),目标检测中使用的一个概念,是产生的候选框(candidate bound)与原标记框(ground truth bound)的交叠率,即它们的交集与并集的比值。IOU值越大,说明得到的候选框越准确,最理想情况是完全重叠,即比值为1。

IOU

这里写图片描述

anchor boxes

anchor boxes(候选区域)
这里写图片描述

anchor box 的解释

非极大抑制

非极大抑制,在检测的时候可能存在重叠的备选框,对于非极大可能性的被选框进行抛弃。
如果是多目标检测,就进行多次非极大抑制。
这里写图片描述
从算法中可以看到,做了两步discard:
第一步是对Pc <=0.6 的格子进行discard
第二步是对剩下的格子中,重叠区域 IOU>0.5 的进行非极大discard
这里写图片描述

程序

pycharm版

原本编程作业是 jupyter notebook ,但是环境没配好,所以这里使用pycharm将程序进行整合、调试。

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

from keras.utils import plot_model


def yolo_filter_boxes(box_confidence, boxes, box_class_probs, threshold=.6):
    """Filters YOLO boxes by thresholding on object and class confidence.

    Arguments:
    box_confidence -- tensor of shape (19, 19, 5, 1)
    boxes -- tensor of shape (19, 19, 5, 4)
    box_class_probs -- tensor of shape (19, 19, 5, 80)
    threshold -- real value, if [ highest class probability score < threshold], then get rid of the corresponding box

    Returns:
    scores -- tensor of shape (None,), containing the class probability score for selected boxes
    boxes -- tensor of shape (None, 4), containing (b_x, b_y, b_h, b_w) coo
  • 5
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 23
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 23
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值