0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

IOUで評価しよう

Last updated at Posted at 2021-12-21

#IOUで評価しよう
メモがわりに書き残しておきます
##IOUって何なん

領域の共通部分/領域の和集合 らしい。
領域の重なり度合いです。
よく物体検出でiouの閾値を設定するところがあるのでそれですね。

##とりま実装

iou.py
def IOU(box1,box2):
    X = box1[0]
    Y = box1[1]
    X1 = box1[2]
    Y1 = box1[3]
    _X = box2[0]
    _Y = box2[1]
    _X1 = box2[2]
    _Y1 = box2[3]

    ls = int((X1 - X) * (Y1 - Y))
    ms = int((_X1 - _X) * (_Y1 - _Y))
    lx_line = range(X,X1)
    mx_line = range(_X,_X1)
    ly_line = range(Y,Y1)
    my_line = range(_Y,_Y1)
    lmx = len(list(set(lx_line) & set(mx_line)))
    lmy = len(list(set(ly_line) & set(my_line)))
    TP= int(lmx) * int(lmy)
    Iou = TP / (ls+ms-TP)

    return Iou

入力は左上と右下のxy座標をリストで渡せば良い

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?