1. 程式人生 > >tensorflow 中的object-detction API 使用指南

tensorflow 中的object-detction API 使用指南

熟悉TensorFlow的人都知道,tf在Github上的主頁是:tensorflow,然後這個主頁下又有兩個比較重要的repo(看star數就知道了),分別是TensorFlow的原始碼repo:tensorflow/tensorflow,還有一個tensorflow/models。後者tensorflow/models是Google官方用TensorFlow做的各種各樣的模型,相當於示例程式碼,比如用於影象分類的Slim,深度文字OCR,以及用於NLP任務的句法分析模型syntaxnet,Seq2Seq with Attention等等等等。這次公佈的Object Detection API同樣是放在了tensorflow/models裡。

再來說下這次公佈的程式碼的實現方式。首先,對於目標檢測這個任務來說,前面必須有一個像樣的ImageNet影象分類模型來充當所謂的特徵提取(Feature Extraction)層,比如VGG16、ResNet等網路結構。TensorFlow官方實現這些網路結構的專案是TensorFlow Slim,而這次公佈的Object Detection API正是基於Slim的。Slim這個庫公佈的時間較早,不僅收錄了AlexNet、VGG16、VGG19、Inception、ResNet這些比較經典的耳熟能詳的卷積網路模型,還有Google自己搞的Inception-Resnet,MobileNet等。我們在TensorFlow Object Detection API的官方安裝指南(地址:tensorflow/models)中,可以看到這樣一句程式碼:
From tensorflow/models/
export PYTHONPATH=$PYTHONPATH:pwd

:pwd/slim

很顯然,這就是欽點用Slim作特徵抽取了。另外,以Faster RCNN為例,之前在github上,可以找到各種各樣非官方的TensorFlow實現,但是這些實現使用的特徵抽取層都不是Slim,而是五花八門的什麼都有,另外一方面實現程式碼大量copy自原始的caffe的實現:rbgirshick/py-faster-rcnn,這次公佈的程式碼裡已經一點也找不到原始caffe實現的痕跡了。最後,原來非官方的Object Detection實現的質量參差不齊,去年我調過一個Faster RCNN,過程比較痛苦,在執行之前瘋狂debug了三天才勉強跑了起來。這次Google官方公佈的Object Detection API別的不說,程式碼質量肯定是過的去的,因此以後應該不會有人再造TensorFlow下Faster RCNN、R-FCN、SSD的輪子了。

說完了程式碼,再簡單來說下公佈的模型。主要公佈了5個在COCO上訓練的網路。網路結構分別是SSD+MobileNet、SSD+Inception、R-FCN+ResNet101、Faster RCNN+ResNet101、Faster RCNN+Inception_ResNet。後期應該還會有更多的模型加入進來。

這裡寫圖片描述

————————————–分割線——————————————————————
最後,給新手朋友提供一個可以跑出官方Demo效果的小教程,非常簡單,用5分鐘的時間就可以跑一遍感受一下,只要安裝了TensorFlow就可以,有沒有GPU都無所謂。1. 安裝或升級protoc首先需要安裝或升級protoc,不然在後面會無法編譯。安裝/升級的方法是去protobuf的Release介面:google/protobuf,下載對應的已經編譯好的protoc。
這裡寫圖片描述

比如我是64位的ubuntu,那麼就下載protoc-3.3.0-linux-x86_64.zip。下載解壓後會有一個protoc二進位制檔案,覆蓋到對應目錄即可(如果不放心的可以用cp /usr/bin/protoc ~/protoc_bak先備份一下):
sudo cp bin/protoc /usr/bin/protoc
2. 下載程式碼並編譯下載tensorflow/models的程式碼:
git clone https://github.com/tensorflow/models.git
進入到models資料夾,編譯Object Detection API的程式碼:# From tensorflow/models/
protoc object_detection/protos/*.proto –python_out=.
3. 執行notebook demo在models資料夾下執行:jupyter-notebook
訪問資料夾object_detection,執行object_detection_tutorial.ipynb:

這裡寫圖片描述

依次shift+enter執行到底就行了。這個Demo會自動下載並執行最小最快的模型ssd+mobilenet。

最後的檢測效果,一張是汪星人圖片:
這裡寫圖片描述
這裡寫圖片描述

debug 時可能出現的問題:
1當執行“ protoc object_detection/protos/*.proto –python_out=.”,

出現 No such File or directory
解決方法:檢視自己的路徑是否完全按照tensorflow/model/research/object-detction/protocs 進行轉換的。
2 ImportError: cannot import name _imaging
重新 install Pillow 下:
conda install pillow

相關推薦

tensorflow object-detction API 使用指南

熟悉TensorFlow的人都知道,tf在Github上的主頁是:tensorflow,然後這個主頁下又有兩個比較重要的repo(看star數就知道了),分別是TensorFlow的原始碼repo:tensorflow/tensorflow,還有一個tensor

tensorflowslim模組api介紹

github:https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/slim TensorFlow-Slim TF-Slim is a lightweight library for definin

Tensorflow Object Detection API 詳細實踐指南

最近由於研究方向的更換,接觸到了目標檢測(Object Detection)領域,覺得很有意思,並且閱讀了該方向的相關經典文獻,包括Fast-RCNN、Faster-RCNN、SSD、YOLO以及RetinaNet等。但是對於讀研狗或者讀博狗的我們來說,復現別人

TensorFlow Object Detection API的Faster R-CNN /SSD模型引數調整

關於TensorFlow Object Detection API配置,可以參考之前的文章https://becominghuman.ai/tensorflow-object-detection-api-tutorial-training-and-evaluating-custom-object-detec

配置tensorflow object detection api

could ror blog test creat not pre setup.py python 3:安裝tensorflow model 以及slim 版本號為1.4以上的,model和slim均在research 文件夾下 打開research文件目錄 python

谷歌開源的TensorFlow Object Detection API視頻物體識別系統實現教程

cti blog tail xiaoxiao pan clas post ont 谷歌 教程:http://blog.csdn.net/xiaoxiao123jun/article/details/76605928 全部代碼:https://github.com/lyj83

#tensorflow object detection api 源碼分析

clas fas mask api 錯誤 眼界 沒有 lan 入門深度學習 前言 Tensorflow 推出的 Object Detection API是一套抽象程度極高的目標檢測框架,可以快速用於生產部署。但網絡上大多數相關的中英文文章均只局限於應用層面的分析,對於該套

TensorFlow object detection API

storage 系統 pipeline -s doc 直接下載 and 獲取數據 ons https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/running_pet

TensorFlow object detection API應用一

ofo ash png figure lin 調用 安裝包 pat eight 目標檢測在圖形識別的基礎上有了更進一步的應用,但是代碼也更加繁瑣,TensorFlow專門為此開設了一個object detection API,接下來看看怎麽使用它。 一、object det

Ubuntu 16.04 安裝Tensorflow Object Detection API遇到的問題解決

** Ubuntu 16.04 安裝Tensorflow Object Detection API ** 本篇的內容主要參考以下連結:https://blog.csdn.net/pkokocl/article/details/82596089, 該博主描述的比較清楚,對於解決實際

Tensorflow Object Detection API之MaskRCNN-資料處理篇

TensorFlow官網介紹:Run an Instance Segmentation Model 要求將資料處理為PNG Instance Segmentation Masks格式 以下部分為處理單張Mask圖片的方式: from PIL import Image, ImageDr

Tensorflow object detection API--修改visualization_utils檔案,裁剪並儲存bounding box部分

任務描述:用Tensorflow object detection API檢測出來的結果是一整張圖片,想要把檢測出的bounding box部分單獨截取出來並儲存 執行環境:spyder 效果展示: 測試圖片:test_images --> 檢測圖片:testsave_images -

【CV】如何使用Tensorflow提供的Object Detection API--3--手工標註資料

前面兩篇看完,我們已經知道如何選用預訓練模型以及將現存的其他資料集變成TFRecord格式的資料了。 但是如果需要用你自己的資料集,該怎麼辦呢? 本篇主要講如何建立自己的資料集,並用object_detection提供的模型來進行訓練,識別。 首先需要的是標記資料。 La

【CV】如何使用Tensorflow提供的Object Detection API --2--資料轉換為TFRecord格式

本篇主要講的是如何將現存的資料變成Tensorflow記錄格式,然後我們就可以用這些資料來進行微調模型,以解決我們關心的問題了。 什麼是TFRecord格式 一般使用TF讀取資料有四種方式: 預先把所有資料載入進記憶體 在每輪訓練中使用原生Python程式碼讀取

基於TensorFlow Object Detection API進行相關開發的步驟

1/安裝或升級protoc 2/編譯proto檔案 protoc object_detection/protos/*.proto --python_out=. 3將slim加入PYTHONPATH export PYTHONPATH="$PYTHONPATH:/home/user/DL

Tensorflow Object Detection API安裝與使用

一、簡介 《21個專案玩轉深度學習:基於Tensorflow的實踐詳解》第五章實踐 win10、jupyter notebook、python3.6, Tensorflow Object Detection API專案地址:https://github.com/tensorflow/mo

Tensorflow object detection API(1)---環境搭建與測試

    參考: https://blog.csdn.net/dy_guox/article/details/79081499 https://blog.csdn.net/u010103202/article/details/79899293 https://blog.csdn.n

windows+tensorflow object detection api 深度學習目標檢測實踐

1、在github上下載tensorflow/model專案 1. 首先把protoc-win32資料夾下面的protoc.exe移至protobuf-python/src目錄下。 2. 在cmd中進入protobuf-python/python目錄,先執行a

TensorFlow Object Detection API 超詳細教程和踩坑過程(安裝)

目錄     cuda安裝     cudnn安裝     anaconda安裝並建立環境     tensorflow環境     Tensorflow.models下載     Protobuf配置與測試 1.配置環境       首先說一下我

TensorFlow Object Detection API 超詳細教程和踩坑過程(資料準備和訓練)

1.準備資料     object detection的資料是需要tfrecord格式的,但是一般我們還是先製作voc格式的資料更加方便。     1.voc格式資料的準備:github上下載一個label-img:    然後選擇VOC格式,開始漫長的資料