目標檢測coco數據集點滴介紹


目標檢測coco數據集點滴介紹

1.  COCO數據集介紹

MS COCO 是google 開源的大型數據集, 分為目標檢測、分割、關鍵點檢測三大任務, 數據集主要由圖片和json 標簽文件組成。 coco數據集有自帶COCO API,方便對json文件進行信息讀取。本博客介紹是目標檢測數據集格式的制作。

COCO通過大量使用Amazon Mechanical Turk來收集數據。COCO數據集現在有3種標注類型:object instances(目標實例), object keypoints(目標上的關鍵點), 和image captions(看圖說話),使用JSON文件存儲。

2.  MSCOCO數據集數據結構{

"images":

[

{"file_name":"cat.jpg","id":1,"height":1000,"width":1000},

{"file_name":"dog.jpg","id":2,"height":1000,"width":1000},

...

]

"annotations":

 [

{"image_id":1,"bbox":[100.00,200.00,10.00,10.00],"category_id":1}

{"image_id":2,"bbox":[150.00,250.00,20.00,20.00],"category_id":2}

...

]

"categories":

 [

{"id":0,"name":"bg"}

{"id":1,"name":"cat"}

{"id":1,"name":"dog"}

...

]

}

標注文件中,"images" 關鍵字對應圖片信息,"annotations" 關鍵字對應標注信息,"categories" 對應類別信息: "images": 該關鍵字對應的數據中,每一項對應一張圖片,"file_name"對應圖片名稱,"id"對應圖片序號,"height"和"width"分別對應圖像的高和寬。 "annotations": 該關鍵字對應的數據中,每一項對應一條標注,"image_id"對應圖片序號,"bbox"對應標注矩形框,順序為[x, y, w, h],分別為該矩形框的起始點x坐標,起始點y坐標,寬、高。"category_id"對應類別序號。 "categories": 該關鍵字對應的數據中,每一項對應一個類別,"id"對應類別序號,"name"對應類別名稱。

關鍵字關聯說明: 1."annotations"中的元素通過"image_id"關聯圖像,比如"image_id":2,該條標注信息對應"images"中"id"為2的圖像。 2."annotations"中的元素通過"category_id"關聯類別,比如"category_id":2,該條標注信息對應"categories"中"id"為2的類別。

例: 在上面列出的數據結構中

這條標注信息通過"image_id"可以找到對應的圖像為"cat.jpg",通過"category_id"可以找到對應的類別為"cat"

背景圖片說明:
"annotations"中的元素,"category_id":0對應的是背景。當且僅當一張圖片對應的所有annotations中,"category_id"都為0,該圖片為背景圖片。

3.  COCO數據集json文件,分類和id

coco目標檢測數據集標注目標信息采用的是數據格式是json,其內容本質是一種字典結構,字典堆棧和列表信息內容維護。

coco里面的id和類名字對應:總共80類,但id號到90!

 

coco_id_name_map={1: 'person', 2: 'bicycle', 3: 'car', 4: 'motorcycle', 5: 'airplane',                   6: 'bus', 7: 'train', 8: 'truck', 9: 'boat', 10: 'traffic light', 11: 'fire hydrant', 13: 'stop sign', 14: 'parking meter', 15: 'bench', 16: 'bird', 17: 'cat', 18: 'dog', 19: 'horse', 20: 'sheep', 21: 'cow', 22: 'elephant', 23: 'bear', 24: 'zebra', 25: 'giraffe', 27: 'backpack', 28: 'umbrella', 31: 'handbag', 32: 'tie', 33: 'suitcase', 34: 'frisbee', 35: 'skis', 36: 'snowboard', 37: 'sports ball', 38: 'kite', 39: 'baseball bat', 40: 'baseball glove', 41: 'skateboard', 42: 'surfboard', 43: 'tennis racket', 44: 'bottle', 46: 'wine glass', 47: 'cup', 48: 'fork', 49: 'knife', 50: 'spoon', 51: 'bowl', 52: 'banana', 53: 'apple', 54: 'sandwich', 55: 'orange', 56: 'broccoli', 57: 'carrot', 58: 'hot dog', 59: 'pizza', 60: 'donut', 61: 'cake', 62: 'chair', 63: 'couch', 64: 'potted plant', 65: 'bed', 67: 'dining table', 70: 'toilet', 72: 'tv', 73: 'laptop', 74: 'mouse', 75: 'remote', 76: 'keyboard', 77: 'cell phone', 78: 'microwave', 79: 'oven', 80: 'toaster', 81: 'sink', 82: 'refrigerator', 84: 'book', 85: 'clock', 86: 'vase', 87: 'scissors', 88: 'teddy bear', 89: 'hair drier', 90: 'toothbrush'}

 

打開json文件:

 with open(json_path,'r') as load_f:

    load_dict = json.load(load_f)

里面協議是這樣的,annotations下面是每一個box的標注信息,包括分割的,當前框使用目標框,image_id,categogy_id。

因此要想獲得整個數據集信息,必須遍歷整個box信息,將其進行統計分配。

4.  COCO數據集性能指標

COCO 提供了 12 種用於衡量目標檢測器性能的評價指標.

Recall   召回率(查全率)。表示正確識別物體A的個數占測試集中物體A的總個數的百分數Recall = TP / (TP+FN)

 

Precision 精確率(查准率)。表示正確識別物體A的個數占總識別出的物體個數n的百分數Precision = TP / (TP+FP)

fp :false positive誤報,即預測錯誤

fn :false negative漏報,即沒有預測到

tp:true positive

tn:true negative

iou:intersection-over-union

Accuracy  准確率。正確分類的樣本數除以所有的樣本數,正確率越高,分類器越好。Accuracy=(TP+TN)/ (TP+TN+FP+FN)

以上介紹都是基於2分類的,並不是多分類的

 

 以下12個指標用於表征COCO上物體檢測器的性能:

 Average Precision (AP):

AP                              % AP at IoU=0.50:0.05:0.95 (primary challenge metric)

 

APIoU=.50                   % AP at IoU=0.50 (PASCAL VOC metric)

 

APIoU=.75                   % AP at IoU=0.75 (strict metric)

 

AP Across Scales:

 

APsmall                       % AP for small objects: area < 322

 

APmedium                   % AP for medium objects: 322 < area < 962

 

APlarge                        % AP for large objects: area > 962

 

Average Recall (AR):

 

ARmax=1                     % AR given 1 detection per image

 

ARmax=10                   % AR given 10 detections per image

 

ARmax=100                 % AR given 100 detections per image

 

AR Across Scales:

 

ARsmall                       % AR for small objects: area < 322

 

ARmedium                   % AR for medium objects: 322 < area < 962

 

ARlarge                        % AR for large objects: area > 962

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM