detector = dlib.train_simple_object_detector(images, mmodlists, options) img = dlib.load_rgb_image("test.jpg") dets = detector(img) for det in dets: print(f"Class det.label at det.rect, score det.detection_confidence")
std::vector<mmod_rect> mmodlist; mmod_rect mr; mr.rect = rectangle(10,20,50,80); mr.label = 0; mr.ignore = false; mmodlist.push_back(mr); mmodlist
options = dlib.simple_object_detector_training_options() options.add_left_right_image_flips = True options.C = 5 options.num_threads = 4 options.be_verbose = True detector = dlib.train_simple_object_detector(images, boxes_per_image, options) Save the detector detector.save("mmod_detector.svm") detector = dlib
#include <dlib/image_processing.h> using namespace dlib; detector = dlib.train_simple_object_detector(images
options = dlib.simple_object_detector_training_options() options.C = 1 options.num_threads = 8 options.add_left_right_image_flips = True
Under the hood, train_simple_object_detector converts mmodlist into the internal MMOD loss format. The ignore flag is critical for hard examples: