2016-11-02 6 views
1

D-lib 라이브러리를 사용하여 안구 인식을 사용하고 있습니다. 그래서 문서에 나와있는 옵션을 사용하여 나만의 분류자를 훈련 할 계획입니다. C++과 비교할 때 파이썬을 언어 플랫폼으로 사용하고 있습니다.교육용 D-lib 이미지

그래서 저는 imglab 도구를 사용하여 두 개의 .xml 파일을 만들고 테스트했습니다. imglab 도구에서 모든 주제 이름에 레이블을 지정해야합니까? 20000 개의 이미지가 있습니다. 어려운 일이 아니겠습니까? 우리는 쉽게 할 수 있습니까? 첨부 된 시나리오와 일치하는 코드를 찾으십시오. 당신이 기차 dlib의 객체 (경계 상자까지) 레이블이 필요 검출기 데이터 세트를 사용하려면 나 때문에

import os 
import sys 
import glob 

import dlib 
from skimage import io 


# In this example we are going to train a face detector based on the small 
# faces dataset in the examples/faces directory. This means you need to supply 
# the path to this faces folder as a command line argument so we will know 
# where it is. 

faces_folder = "/media/praveen/SSD/NIVL_Ocular/NIR_Ocular_Training" 


# Now let's do the training. The train_simple_object_detector() function has a 
# bunch of options, all of which come with reasonable default values. The next 
# few lines goes over some of these options. 
options = dlib.simple_object_detector_training_options() 
# Since faces are left/right symmetric we can tell the trainer to train a 
# symmetric detector. This helps it get the most value out of the training 
# data. 
options.add_left_right_image_flips = False 
# The trainer is a kind of support vector machine and therefore has the usual 
# SVM C parameter. In general, a bigger C encourages it to fit the training 
# data better but might lead to overfitting. You must find the best C value 
# empirically by checking how well the trained detector works on a test set of 
# images you haven't trained on. Don't just leave the value set at 5. Try a 
# few different C values and see what works best for your data. 
options.C = 5 
# Tell the code how many CPU cores your computer has for the fastest training. 
options.num_threads = 4 
options.be_verbose = True 


training_xml_path = os.path.join(faces_folder, "/media/praveen/SSD/NIVL_Ocular/praveen_ocular_dataset.xml") 
testing_xml_path = os.path.join(faces_folder, "/media/praveen/SSD/NIVL_Ocular/praveen_ocular_test_dataset.xml") 
# This function does the actual training. It will save the final detector to 
# detector.svm. The input is an XML file that lists the images in the training 
# dataset and also contains the positions of the face boxes. To create your 
# own XML files you can use the imglab tool which can be found in the 
# tools/imglab folder. It is a simple graphical tool for labeling objects in 
# images with boxes. To see how to use it read the tools/imglab/README.txt 
# file. But for this example, we just use the training.xml file included with 
# dlib. 
dlib.train_simple_object_detector(training_xml_path, "detector.svm", options) 



# Now that we have a face detector we can test it. The first statement tests 
# it on the training data. It will print(the precision, recall, and then) 
# average precision. 
print("") # Print blank line to create gap from previous output 
print("Training accuracy: {}".format(
    dlib.test_simple_object_detector(training_xml_path, "detector.svm"))) 
# However, to get an idea if it really worked without overfitting we need to 
# run it on images it wasn't trained on. The next line does this. Happily, we 
# see that the object detector works perfectly on the testing images. 
print("Testing accuracy: {}".format(
    dlib.test_simple_object_detector(testing_xml_path, "detector.svm"))) 




# 
# # Now let's use the detector as you would in a normal application. First we 
# # will load it from disk. 
# detector = dlib.simple_object_detector("detector.svm") 
# 
# # We can look at the HOG filter we learned. It should look like a face. Neat! 
# win_det = dlib.image_window() 
# win_det.set_image(detector) 
# 
# # Now let's run the detector over the images in the faces folder and display the 
# # results. 
# print("Showing detections on the images in the faces folder...") 
# win = dlib.image_window() 
# for f in glob.glob(os.path.join(faces_folder, "*.png")): 
#  print("Processing file: {}".format(f)) 
#  img = io.imread(f) 
#  dets = detector(img) 
#  print("Number of faces detected: {}".format(len(dets))) 
#  for k, d in enumerate(dets): 
#   print("Detection {}: Left: {} Top: {} Right: {} Bottom: {}".format(
#    k, d.left(), d.top(), d.right(), d.bottom())) 
# 
#  win.clear_overlay() 
#  win.set_image(img) 
#  win.add_overlay(dets) 
#  dlib.hit_enter_to_continue() 
+1

이미지 라벨링에 도움이되는 경우 [web] (https://github.com/NaturalIntelligence/imglab) 버전을 확인하십시오. –

답변

0

간단하게, 그래, 당신은 가능하고 표시된 데이터 집합을 사용합니다.

또한 imglab의 주요 기능은 경계 상자 작성하고 당신의 의견에 쓰여 :

자신의 XML 파일을 만들려면 당신이 도구/imglab에서 발견 을 할 수있는 imglab 도구를 사용할 수 있습니다 폴더. 그것은 상자에 심상 안에 객체를 레테르를 붙이는 을위한 간단한 그래픽 도구이다. 당신이 말한대로 https://arxiv.org/pdf/1502.00046v1.pdf

사실, 정말 어렵습니다 :에

원본 용지의 참조하십시오. 물체 감지 또는 인식에서 주요 과제 중 하나는 데이터 세트를 만드는 것입니다. 그래서 연구원은 군중의 힘을 사용하는 사이트와 같은 Mechanical Turk을 사용합니다.

+0

귀하의 조언에 감사드립니다. 레이블이 지정된 데이터 세트의 의미는 무엇입니까? 내가 가지고있는 데이터 세트에는 존재하는 주제에 따라 레이블이 붙은 이미지가 있습니다. 얼굴의 안구 만 잘라 냈고 사진의 경계 상자가 될 것입니다. – Praveen

+0

나는 그것이 잘못되었다고 생각한다. 각 사람들의 망막을 서로 차별화하려고합니까? 탐지기가 "존의 망막이고 이것은 브래드의 망막입니다"라고 말해야한다는 뜻입니다. 맞습니까? – cagatayodabasi

+0

예, 맞습니다. – Praveen