Commit aa93c8f8 authored by Davis King's avatar Davis King

Updated python code to use the new dlib::jitter_image() instead of hacking it

out of the random_cropper.
parent e338bf02
...@@ -28,15 +28,6 @@ public: ...@@ -28,15 +28,6 @@ public:
face_recognition_model_v1(const std::string& model_filename) face_recognition_model_v1(const std::string& model_filename)
{ {
deserialize(model_filename) >> net; deserialize(model_filename) >> net;
cropper = make_shared<random_cropper>();
cropper->set_chip_dims(150,150);
cropper->set_randomly_flip(true);
cropper->set_max_object_size(0.99999);
cropper->set_background_crops_fraction(0);
cropper->set_min_object_size(0.97);
cropper->set_translate_amount(0.02);
cropper->set_max_rotation_degrees(3);
} }
matrix<double,0,1> compute_face_descriptor ( matrix<double,0,1> compute_face_descriptor (
...@@ -91,23 +82,16 @@ public: ...@@ -91,23 +82,16 @@ public:
private: private:
std::shared_ptr<random_cropper> cropper; dlib::rand rnd;
std::vector<matrix<rgb_pixel>> jitter_image( std::vector<matrix<rgb_pixel>> jitter_image(
const matrix<rgb_pixel>& img, const matrix<rgb_pixel>& img,
const int num_jitters const int num_jitters
) )
{ {
std::vector<mmod_rect> raw_boxes(1), ignored_crop_boxes;
raw_boxes[0] = shrink_rect(get_rect(img),3);
std::vector<matrix<rgb_pixel>> crops; std::vector<matrix<rgb_pixel>> crops;
matrix<rgb_pixel> temp;
for (int i = 0; i < num_jitters; ++i) for (int i = 0; i < num_jitters; ++i)
{ crops.push_back(dlib::jitter_image(img,rnd));
(*cropper)(img, raw_boxes, temp, ignored_crop_boxes);
crops.push_back(move(temp));
}
return crops; return crops;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment