Created
January 11, 2020 04:34
-
-
Save evergreenllc2020/dd4feca0b3f7393222935dbcacebaa57 to your computer and use it in GitHub Desktop.
Object detection Model Training
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# loop over the image paths | |
for imagePath in paths.list_images(args["class"]): | |
# extract the image ID from the image path and load the annotations file | |
imageID = imagePath[imagePath.rfind("/") + 1:].split("_")[1] | |
imageID = imageID.replace(".jpg", "") | |
p = "{}/annotation_{}.mat".format(args["annotations"], imageID) | |
annotations = loadmat(p)["box_coord"] | |
# loop over the annotations and add each annotation to the list of bounding | |
# boxes | |
bb = [dlib.rectangle(left=long(x), top=long(y), right=long(w), bottom=long(h)) | |
for (y, h, x, w) in annotations] | |
boxes.append(bb) | |
# add the image to the list of images | |
images.append(io.imread(imagePath)) | |
# train the object detector | |
print("[INFO] training detector...") | |
detector = dlib.train_simple_object_detector(images, boxes, options) | |
# dump the classifier to file | |
print("[INFO] dumping classifier to file...") | |
detector.save(args["output"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment