Histogram of Oriented Gradients and Object Detection
I’m not going to review the entire detailed process of training an object detector using Histogram of Oriented Gradients (yet), simply because each step can be fairly detailed. But I wanted to take a minute and detail the general algorithm for training an object detector using Histogram of Oriented Gradients. It goes a little something like this:
Step 1:
Sample P positive samples from your training data of the object(s) you want to detect and extract HOG descriptors from these samples.
Step 2:
Sample N negative samples from a negative training set that does not contain any of the objects you want to detect and extract HOG descriptors from these samples as well. In practice N >> P.
Step 3:
Train a Linear Support Vector Machine on your positive and negative samples.
Step 4:
Figure 2: Example of the sliding a window approach, where we slide a window from left-to-right and top-to-bottom.
Figure 2: Example of the sliding a window approach, where we slide a window from left-to-right and top-to-bottom. Note: Only a single scale is sown. In practice this window would be applied to multiple scales of the image.
Apply hard-negative mining. For each image and each possible scale of each image in your negative training set, apply the sliding window technique and slide your window across the image. At each window compute your HOG descriptors and apply your classifier. If your classifier (incorrectly) classifies a given window as an object (and it will, there will absolutely be false-positives), record the feature vector associated with the false-positive patch along with the probability of the classification. This approach is called hard-negative mining.
Step 5:
Take the false-positive samples found during the hard-negative mining stage, sort them by their confidence (i.e. probability) and re-train your classifier using these hard-negative samples. (Note: You can iteratively apply steps 4-5, but in practice one stage of hard-negative mining usually [not not always] tends to be enough. The gains in accuracy on subsequent runs of hard-negative mining tend to be minimal.)
Step 6:
Your classifier is now trained and can be applied to your test dataset. Again, just like in Step 4, for each image in your test set, and for each scale of the image, apply the sliding window technique. At each window extract HOG descriptors and apply your classifier. If your classifier detects an object with sufficiently large probability, record the bounding box of the window. After you have finished scanning the image, apply non-maximum suppression to remove redundant and overlapping bounding boxes.
These are the bare minimum steps required, but by using this 6-step process you can train and build object detection classifiers of your own! Extensions to this approach include a deformable parts model and Exemplar SVMs, where you train a classifier for each positive instance rather than a collection of them.
However, if you’ve ever worked with object detection in images you’ve likely ran into the problem of detecting multiple bounding boxes around the object you want to detect in the image.
Here’s an example of this overlapping bounding box problem:
Figure 3: (Left) Detecting multiple overlapping bounding boxes around the face we want to detect. (Right) Applying non-maximum suppression to remove the redundant bounding boxes.
Figure 3: (Left) Detecting multiple overlapping bounding boxes around the face we want to detect. (Right) Applying non-maximum suppression to remove the redundant bounding boxes.
Notice on the left we have 6 overlapping bounding boxes that have correctly detected Audrey Hepburn’s face. However, these 6 bounding boxes all refer to the same face — we need a method to suppress the 5 smallest bounding boxes in the region, keeping only the largest one, as seen on the right.
This is a common problem, no matter if you are using the Viola-Jones based method or following the Dalal-Triggs paper.
There are multiple ways to remedy this problem. Triggs et al. suggests to use the Mean-Shift algorithm to detect multiple modes in the bounding box space by utilizing the (x, y) coordinates of the bounding box as well as the logarithm of the current scale of the image.
I’ve personally tried this method and wasn’t satisfied with the results. Instead, you’re much better off relying on a strong classifier with higher accuracy (meaning there are very few false positives) and then applying non-maximum suppression to the bounding boxes.
I spent some time looking for a good non-maximum suppression (sometimes called non-maxima suppression) implementation in Python. When I couldn’t find one, I chatted with my friend Dr. Tomasz Malisiewicz, who has spent his entire career working with object detector algorithms and the HOG descriptor. There is literally no one that I know who has more experience in this area than Tomasz. And if you’ve ever read any of his papers, you’ll know why. His work is fantastic.
Anyway, after chatting with him, he pointed me to two MATLAB implementations. The first is based on the work by Felzenszwalb et al. and their deformable parts model.
The second method is implemented by Tomasz himself for his Exemplar SVM project which he used for his dissertation and his ICCV 2011 paper, Ensemble of Exemplar-SVMs for Object Detection and Beyond. It’s important to note that Tomasz’s method is over 100x faster than the Felzenszwalb et al. method. And when you’re executing your non-maximum suppression function millions of times, that 100x speedup really matters.
I’ve implemented both the Felzenszwalb et al. and Tomasz et al. methods, porting them from MATLAB to Python. Next week we’ll start with the Felzenszwalb method, then the following week I’ll cover Tomasz’s method. While Tomasz’s method is substantially faster, I think it’s important to see both implementations so we can understand exactly why his method obtains such drastic speedups.
Be sure to stick around and check out these posts! These are absolutely critical steps to building object detectors of your own!
ความถี่ของการไล่ระดับสีและมุ่งเน้นการตรวจจับวัตถุ
ผมจะทบทวนกระบวนการรายละเอียดทั้งหมดของการฝึกอบรมการใช้ความถี่ของเครื่องตรวจจับวัตถุที่มุ่งเน้นการไล่ระดับสี ( ยัง ) , เพียงเพราะ แต่ละขั้นตอนจะมีรายละเอียดค่อนข้าง แต่ฉันต้องการใช้เวลาสักครู่และรายละเอียดขั้นตอนวิธีการทั่วไปสำหรับการใช้ความถี่ของเครื่องตรวจจับวัตถุที่มุ่งเน้นการไล่ระดับสี .มันจะไปอะไรเช่นนี้ :
ขั้นตอนที่ 1 :
ตัวอย่างทางบวก ตัวอย่าง จากข้อมูลการฝึกอบรมของวัตถุ ( s ) ที่คุณต้องการตรวจสอบและสกัดจากมะกอกในตัวอย่างเหล่านี้ ขั้นตอนที่ 2
ตัวอย่าง n ลบลบตัวอย่างจากชุดฝึกอบรมที่ไม่ได้มีใด ๆของ วัตถุที่คุณต้องการตรวจสอบและสกัดจากมะกอกในตัวอย่างเหล่านี้เช่นกัน ในทางปฏิบัติ n > > หน้า
ขั้นตอนที่ 3 :
รถไฟเส้นสนับสนุนเวกเตอร์เครื่องจักรตัวอย่างเชิงบวกและเชิงลบของคุณ ขั้นตอนที่ 4 :
รูปที่ 2 : ตัวอย่างของการเลื่อนหน้าต่างวิธีการที่เราเลื่อนหน้าต่างจากซ้ายไปขวา และจากบนลงล่าง
รูปที่ 2 : ตัวอย่างของการเลื่อนหน้าต่างวิธีการที่เราเลื่อนหน้าต่างจากซ้าย ไปขวา และจากบนลงล่าง หมายเหตุ : ขนาดเดียวคือหว่าน .ในหน้าต่างนี้จะใช้กับการฝึกหลาย ๆแบบภาพ
ใช้เหมืองแร่ลบยาก สำหรับภาพแต่ละภาพและเป็นไปได้ในแต่ละขนาดของแต่ละภาพในชุดฝึกของคุณลบ ใช้เทคนิคเลื่อนหน้าต่างหน้าต่างของคุณข้ามและเลื่อนภาพ ที่คำนวณไว้ในแต่ละหน้าต่างของคุณและใช้ส่วนขยายของคุณถ้าตัวของคุณ ( ไม่ถูกต้อง ) แยกประเภทให้ หน้าต่างที่เป็นวัตถุ ( และจะ จะแน่นอนถูกบวกเท็จ ) , บันทึกแบบเวกเตอร์ที่เกี่ยวข้องกับ false-positive แพทช์พร้อมกับความน่าจะเป็นของการจำแนก วิธีการนี้เรียกว่าเหมืองแร่ลบอย่างหนัก
ขั้นตอนที่ 5 :
เอาตัวอย่าง false-positive พบในเหมืองเวทีมากลบจัดเรียงตามความเชื่อมั่นของพวกเขา ( เช่นความน่าจะเป็น ) และรถไฟแบบของคุณโดยใช้เหล่านี้ยากลบตัวอย่าง ( หมายเหตุ : คุณสามารถใช้ขั้นตอนซ้ำ 4-5 แต่ในทางปฏิบัติขั้นตอนหนึ่งของเหมืองลบยากมักจะไม่เสมอ [ ไม่ ] จึงจะพอ กําไรในความถูกต้องที่ตามมาวิ่งเหมืองแร่ลบยากมักจะเป็นน้อยที่สุด )
6
:ตัวของคุณคือตอนนี้ผ่านการอบรมและสามารถใช้กับชุดข้อมูลทดสอบ อีกครั้ง เช่นเดียวกับในขั้นตอนที่ 4 สำหรับภาพแต่ละภาพในชุดทดสอบของคุณและสำหรับแต่ละขนาดของภาพ ใช้หน้าต่างบานเลื่อน ) ในแต่ละหน้าต่างและใช้สารสกัดจากหมูในแบบของคุณ ถ้าตัวตรวจจับวัตถุที่มีความน่าจะเป็นมากพอ , บันทึกปกกล่องหน้าต่างหลังจากที่คุณได้เสร็จสิ้นการสแกนภาพสูงสุดใช้ไม่ปราบปราม เพื่อลบซ้ำซ้อนและทับซ้อนกันบริเวณกล่อง
นี่เป็นขั้นต่ำเปลือยขั้นตอนที่จำเป็น แต่โดยการใช้กระบวนการขั้นตอนที่ 6 นี้ คุณสามารถฝึกและสร้างวัตถุตรวจจับคำของคุณเอง ! ส่วนขยายของวิธีการนี้รวมถึงรูปแบบชิ้นส่วนและแบบโดยแบบอย่าง ,ที่คุณรถไฟลักษณนามสำหรับแต่ละบวกตัวอย่างมากกว่าคอลเลกชันของพวกเขา .
แต่ถ้าคุณเคยทำงานกับการตรวจจับวัตถุในภาพ คุณอาจเจอปัญหาของการตรวจสอบหลายปกกล่องรอบวัตถุที่คุณต้องการจะตรวจสอบในรูป
ที่นี่คือตัวอย่างของปัญหาที่ทับซ้อนกันวิ่งกล่อง :
รูปที่ 3 :( ซ้าย ) ตรวจสอบ ทับซ้อนกันหลายปกกล่องรอบหน้าเราต้องการตรวจสอบ ( ขวา ) ใช้ไม่เกินปราบปรามเอาซ้อนนอกกล่อง
รูปที่ 3 : ( ซ้าย ) ตรวจสอบหลายซ้อนวิ่งกล่องรอบหน้าเราต้องการตรวจสอบ ( ขวา ) ใช้ไม่เกินปราบปรามลบซ้ำซ้อน
จำกัดกล่องสังเกตุด้านซ้ายมี 6 กล่องซ้อนวิ่งตรวจพบได้อย่างถูกต้องเป็นออเดรย์ เฮปเบิร์น หน้า อย่างไรก็ตาม , เหล่านี้วิ่งกล่องทั้งหมดที่อ้างถึงหน้าเดียวกัน เราต้องมีวิธีการปราบปรามเล็กวิ่ง 5 กล่องในภูมิภาค , การรักษาเดียวที่ใหญ่ที่สุดที่เห็นด้านขวา
นี่เป็นปัญหาทั่วไปไม่ว่าถ้าคุณใช้ Viola โจนส์ตามวิธีการหรือตาม Dalal triggs กระดาษ
มีหลายวิธีที่จะแก้ไขปัญหานี้ triggs et al . แนะนำให้ใช้หมายถึงการเปลี่ยนแปลงขั้นตอนวิธีการตรวจสอบโหมดต่างๆในบริเวณกล่องพื้นที่โดยการใช้พิกัด ( x , y ) ที่บริเวณกล่องเป็นลอการิทึมของขนาดปัจจุบันของภาพ
ส่วนตัวผมเคยลองวิธีนี้แล้วไม่ได้พอใจกับผลลัพธ์ แทน คุณจะดีขึ้นมากโดยอาศัยแข็งแรงแบบที่มีความถูกต้องสูง ( หมายถึงมีผลบวกปลอมน้อยมาก ) แล้วใช้ไม่ปราบปราม เพื่อขอบเขตสูงสุดกล่อง
ผมใช้เวลามองหาที่ดีไม่ใช่การปราบปรามสูงสุด ( บางครั้งเรียกว่าไม่ปราบปราม maxima ) ดำเนินการในหลาม .เมื่อผมหาไม่เจอ ผมพูดคุยกับเพื่อนของฉัน ดร. ตอมัช malisiewicz ที่ได้ใช้เวลาตลอดอาชีพของเขาทำงานกับวัตถุที่ตรวจจับ ขั้นตอนวิธีและหมูหัวเรื่อง . มีจริง ไม่มีใครที่ผมรู้จักที่มีประสบการณ์มากในพื้นที่นี้กว่าตอมัช . และถ้าคุณเคยอ่านใด ๆของเอกสารของเขา , คุณจะรู้ว่าทำไม งานของเขาเป็นที่ยอดเยี่ยม
ยังไง หลังจากพูดคุยกับเขาเขาชี้ให้ฉันสองโปรแกรมที่ใช้งาน ก่อนจะใช้งาน โดย felzenszwalb et al . และโดยส่วนรุ่น
วิธีที่สองใช้ตอมัชตัวเองของเขาแบบอย่าง SVM ซึ่งเขาใช้สำหรับโครงการวิทยานิพนธ์ของเขา iccv 2011 กระดาษของเขาและวงดนตรีของแบบอย่างแบบสำหรับตรวจจับวัตถุและเกินมันเป็นสิ่งสำคัญที่จะทราบว่าตอมัชวิธีการมากกว่า 100x เร็วกว่า felzenszwalb et al . วิธี และเมื่อคุณรันการปราบปรามการทำงานสูงสุดของคุณไม่กี่ล้านครั้ง ซึ่ง 100x SpeedUp สำคัญจริงๆ
ผมเคยใช้ทั้ง felzenszwalb et al . และ ตอมัช et al . วิธีการย้ายจาก Matlab งูเหลือม สัปดาห์หน้า เราจะเริ่มกับ felzenszwalb วิธีแล้วอาทิตย์ต่อไปผมจะครอบคลุมตอมัชเป็นวิธี ในขณะที่ตอมัชแบบเป็นเร็วขึ้นอย่างมาก ผมคิดว่ามันสำคัญที่จะเห็นทั้งระบบเพื่อให้เราสามารถเข้าใจถึงวิธีการของเขาได้รับนั้นรุนแรง speedups
มั่นใจที่จะติดรอบและตรวจสอบการโพสต์นี้ ! เหล่านี้เป็นขั้นตอนที่สำคัญอย่างยิ่งที่จะสร้างเครื่องตรวจจับวัตถุของคุณเอง !
การแปล กรุณารอสักครู่..
