2017-12-18 368 views
0

在我用tensorflow對目標檢測API進行一些研究的那一刻。爲此,我跟着這個教程:TF - 帶有地面真值盒的物體檢測

https://www.oreilly.com/ideas/object-detection-with-tensorflow

本教程介紹瞭如何從圖像也PASCAL VOC XML標籤文件tfrecord。以及開始使用對象檢測API。

要生成我修改了一些代碼,從引用的浣熊庫在GitHub上那些tfrecords:

https://github.com/datitran/raccoon_dataset

我標記我的圖片與LabelImg(https://github.com/tzutalin/labelImg)有你有在PASCAL VOC格式保存的可能性。

所以現在我按照教程做了60個圖像的第一次測試(訓練),一小時後(574步)我做了一箇中斷來保存檢查點。在此之後,我做了一個導出「inference.py圖」並保存了冷凍模型(糾正我,如果我說一些愚蠢的東西,這東西也是我的新東西...)

而之後,我修改了jupyter筆記本從我的慾望和tada的教程中有一些在測試圖像中的識別。

到目前爲止這麼好,但現在我想看看對象檢測有多好(爲此),爲此我想從我的測試PASCAL VOC數據集中添加一些地面實況框。但我有一些麻煩來實現我的目標。

我做的第一件事是手動添加這是我從我的VOC數據集讀取箱子,並將它們添加到圖像,我與https://matplotlib.org/devdocs/api/_as_gen/matplotlib.patches.Rectangle.html

但在我的解決方案,這是獲得不同的地塊/附圖。 ...

所以,然後我想也許對象檢測API提供了一些功能來添加盒子/地面真值盒並評估我的檢測與我的測試VOC數據集的準確性。

所以我想我看看https://github.com/tensorflow/models/tree/master/research/object_detection/utils,我以爲我找到了一個函數(DEF draw_bounding_box_on_image_array),使一些箱子到我的image_np,但沒有任何事情發生,所以這是什麼API用來做一些可視化:

vis_util.visualize_boxes_and_labels_on_image_array(
     image_np, 
     np.squeeze(boxes), 
     np.squeeze(classes).astype(np.int32), 
     np.squeeze(scores), 
     category_index, 
     use_normalized_coordinates=True, 
     line_thickness=2) 

,這是我曾嘗試使用:

vis_util.draw_bounding_box_on_image(
     image_np, 
     bndbox_coordinates[0][1], 
     bndbox_coordinates[0][0], 
     bndbox_coordinates[0][3], 
     bndbox_coordinates[0][2]) 

但有箱子的arent如果我嘗試繪圖這個numpy的陣列圖像

我錯過了什麼嗎?問題2是否有API中的某些類正在進行準確性評估?我沒有看到我的乾眼......如果此類/功能使用PASCAL VOC來確定? Mybe我可以使用這個:https://github.com/tensorflow/models/blob/master/research/object_detection/utils/object_detection_evaluation.py,但我沒有信心,因爲我也是新的python和一些代碼/評論很難讓我明白...

也許你職業的球員,有可以幫助我

在此先感謝

編輯: https://www.pyimagesearch.com/2016/11/07/intersection-over-union-iou-for-object-detection/

現在:

我從這篇文章中讀出一點點我知道我需要一個IoU(聯合交集) - 所以有人知道對象檢測API是否爲此提供了一個函數?我會重新考慮的API ...

回答

0

我覺得你沒有經過完整的參數

vis_util.visualize_boxes_and_labels_on_image_array(
    image_np, 
    np.squeeze(boxes), 
    np.squeeze(classes).astype(np.int32), 
    np.squeeze(scores), 
    category_index, 
    use_normalized_coordinates=True, 
    line_thickness=2) 

你需要傳遞 image_np=ImageIDnp.squeeze(boxes)=bounding box coordinatesnp.squeeze(classes).astype(np.int32)=to which class this object belongs tonp.squeeze(scores)=confidence score that will always be 1