Eyewitness: a wrapper for object detection/object tracking applications

楊亮魯
8 min readJan 22, 2020

--

Eyewitness的核心情慾流動. The flowchart of eyewitness.

Library Repository: https://gitlab.com/penolove15/witness

剛好沒買到過年回家的車票, 來介紹一下eyewiteness這個 python library.
This article introduces a python library: eyewitness.

Motivation 動機

Object detection 跟 Object tracking 的發展跟變化是相當快速的, 以object detection為例 faster-rcnn好像還是昨天的事情, 現在Yolov3/Trident/EfficientDet/CenterNet 如 雨後春筍 越來越快, 越來越準.

想像以下的案例:

你有一個Faster-rcnn的 application 守衛著 你家的庭院, 然而隨著時間過去 你看到有新的model後 回來更新model, 發現這份code 你什麼都看不懂了, 我是誰, 我在哪裡, code是誰寫的.

你需要一個 Wrapper來打包你的 detector! 讓你無痛置換 detector, 讓你家庭院更安全! 讓你的application不會被菜鳥笑 old school!

the goal for eyewitness make you object detection/tracking application always sota.

來阿開始阿, QuickStart

讓我們跟著quick start 跑一次.

# 安裝!
pip install eyewitness

先看一眼 ObjectDetector abstract class 的定義.

ObjectDetector的定義, 不偉大也不卑微. ObjectDetector definition, nothing special

quickstart example

一個範例, 不偉大也不卑微. An example, nothing special

哇, 真棒, 這個FakePikachuDetector 真的就是一個 fake Pikachu detector, 他總是detector在(15, 15, 250, 255) 這個位置呢.

痞卡痞, pika pika.

到這邊 你就知道這個Library就真的只是個Wrapper了吧!

我都點進這篇文章了你給我看這個!? A fake detector as a quick start, are you kidding me?

真的Detector, Real Detector Examples

好聲好氣 好聲好氣, 這篇文章浪費你三分鐘, 就還會再浪費你三分鐘

https://gitlab.com/penolove15/witness/tree/master/docker

在這個Library 的docker example 中有試圖去打包更多 有名氣的 Detector

韭菜Detectors, we are standing upon the shoulders of giants.

夥計 測量阿! 發呆阿!, Evaluation your Detector with Dataset

當你有個 Detector, 你會想幹嘛? 知道他多強嘛. 怎麼知道他多強? Evaluation嘛. 常用的Evaluation是什麼? mAP嘛. 怎麼算mAP? 算了 我不Evaluate了.

上述這個情境就是一個標準的小懶人的心情, 所以eyewitness 就是試圖去克服你的懶惰! 這裡有葛Example:

VOC2007 x YOLO, 死給 , an evaluation example for a yolov3 detector with VOC2007 dataset

J葛 example 就是拿VOC2007 來 evaluates 你的 detector.

dataset_VOC_2007 是個 BboxDataSet, 事實上這個class還有實做一些功能:

  • Union Dataset
你是不覺得很煩, 這家伙code 都要用圖片, 誰叫medium的上色這麼糟我又懶的弄到gist, 不然你去git clone eyewitness repo下來看呀, an example of union dataset.
  • 轉成Darknet training 需要的format:
懶的打註解惹, convert_into_darknet_format

家家有本難念的經, Ecosystem to Localize your detector with your field.

更完整的Eyewitness的情慾流動. The flowchart of eyewitness with annotation mechanism

從上面這個圖就可以看到幾個點

  • DetectionResultHandler (to Line(it can be any msg platform) , to DB)
  • FeedbackMsgHandler

大概就可以猜到這邊想幹嘛, 就是Annotation嘛

一個Annoataion msg的示意圖, what we want to do is collect the annotated result from msg platform and thus we can use it to finetune/localize our model

在Msg Platform上製作 feedback mechanism 讓你的回饋能夠回到你的系統.

最後, 當你的application run的夠久 你就可以把一些你們家的資料收集回來做為一個Dataset.

在我的use case 就是IR image (夜視) detect 的比較不行, 所以我又透過這個feedback system多蒐集了一些label過的資料 跟VOC喇在一起 回來 finetune yolov3, 目前感受不差, 在我家的資料集上mAP也比 pre-trained yolov3高一點點.

把標注過的資料收集回來成為dataset, export collected annotation data as a dataset.

注意到這邊有個db file, db的內容可於SqliteLiteSchema tab 中看到 (當然也要用相對應的ORM 操作, 因為自認實做的不乾淨 懶得贅述)

想要看到相對完整的end2end example可以在這份code 中找到.

多物件追蹤 Multiple Object Tracking Support

這個功能於eyewitness 1.2.1之後support

# if you want mot related module, please specify the extra requirements
# also mot needs ffmpeg support, e.g. ubuntu: `apt-get install -y ffmpeg`
pip install eyewitness[mot]>=1.2.1

這章有空再說, 這裡也實做了 MOT 的 Evaluation, Visualization.

有興趣的人可以先看看這個Example.

I will write another article to introduce the eyewitness MOT wrapper which including:

  • Viedo Data abstraction
  • Tracker definition
  • MOT evaluation
  • MOT visualization

anyone can’t wait until the article can read this example first.

最後的最後就放葛MOT result結束這回合.

an eyewitness mot tracked result visualization example.

If there are anyone wants to contribute to this library can contact me here or send an email(penolove15@gmail.com) to me.

--

--