训练结果不正确dlib [英] improper training result dlib

查看:97
本文介绍了训练结果不正确dlib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试训练train_shape_predictor_ex以检测印度钞票中的以下图像。我正在使用34张不同的图像,这些图像都经过了点击和扫描。对
模型进行了成功的

i'm trying to train train_shape_predictor_ex for detecting following image in indian bill. i'm using 34 different images both clicked and scanned. model is trained succesfully with

taining error = 0
testing error = 0.35468-6

我尝试将过采样参数从300更改为12000
,但结果仍然相同。
我在做什么错?

i have tried changing oversampling parameter from 300 to 12000 but still same results. what am i doing wrong?

绘制代码-从图像加载到绘制步骤:

drawing code - from image loading to drawing step:

    image_window win;

    frontal_face_detector detector = get_frontal_face_detector();
    shape_predictor pose_model;
    deserialize("sp.dat") >> pose_model;

    while (!win.is_closed())
    {
        cv::Mat temp;
        cap >> temp;


        cv_image<bgr_pixel> cimg(temp);

        std::vector<rectangle> faces = detector(cimg);

        std::vector<full_object_detection> shapes;
        for (unsigned long i = 0; i < faces.size(); ++i)
        {
            full_object_detection shape = pose_model(cimg, faces[i]);
            std::vector<rectangle> dets = detector(cimg);

            shapes.push_back(pose_model(cimg, faces[i]));

            win.clear_overlay();
            win.set_image(cimg);
            win.add_overlay(dets, rgb_pixel(255, 0, 0));
            win.add_overlay(render_face_detections(shapes));
       }
    }


推荐答案

As我现在知道了-您正在尝试使用Dlib的 render_face_detections 函数训练仅需14点的自定义shape_predictor,该函数要求Dlib的脸部形状具有68点。 render_face_detections 将无法正确绘制形状,并应引发异常。

As I see now - you are trying to train custom shape_predictor that will only have 14 points while using Dlib's render_face_detections function that require Dlib's face shape that has 68 points. render_face_detections will not draw your shape correctly and should throw an exception.

要确保形状预测有效,请确保您必须遵循以下条件:

To make your shape prediction work, please ensure that you follow this conditions:


  1. 每个点的含义在每张图像上都应相同。请勿在第一张图片的耳朵上放置#0点,在第二张图片的鼻子上放置#0点

  2. 不应手工绘制对象边界框如果数据集较小。如果您使用面部检测器来测试形状预测器-请确保通过使用同一面部检测器检测面部来制作训练/测试图像边界框。是的,您可以手工绘制whis边界框,但是请确保它们具有与将被检测到的相同的大小和位置。 在训练集上放置框的方式应与将来获得该框的方式相同。

  3. 不需要使所有点都适合面部边界框内的。实际上,它可以具有任何大小和位置,即使是鼻尖上每个脸部的静态10x10盒子(或完整钞票)也可以使用-但您应该有足够的训练样本。并遵循先前的条件

  4. 使用尽可能多的图像。 34张图像不足以训练形状预测器-如果仅将其记住在其内部存储器中并且将来将无法使用。 Dlib的形状预测器接受了约2-3k图像的训练。

  5. 您可以通过扭曲原始图像来生成新图像-缩放,调整大小,添加噪点...

  6. 如果您的形状预测器没有68个点与dlib的面部形状预测器具有相同的含义,请不要使用Dlib的测试和绘图功能。您可以使用其源代码并根据需要调整功能

  1. The meaning of each point should be the same on each image. Do not put point #0 on ear on first image and #0 on the tip of nose on the second image
  2. Object bounding box should not be hand-drawn if you have small dataset. If you use face detector for testing shape predictor - ensure that your training/testing images bounding boxes are made by detecting face with the same face detector. Yes, you can hand-draw whis bounding boxes, but please make sure that they have the same size and position as if they will be detected. The way how you put box on the training set should be identical the way how you will get it in a future.
  3. There is no requirement to fit all points inside face bounding box. Really it can have any size and position, even static 10x10 box for each face on the tip of nose (or full bill rect) will work - but you should have enough training samples. And follow previous condition
  4. Use as many images as possible. 34 images is not enough for training shape predictor - if will simply remember them in its internal memory and will not work in a future. Dlib's shape predictor is trained with about 2-3k images.
  5. You can generate new images by distorting original ones - scale, resize, add noise...
  6. Do not use Dlib's testing and drawing functions if your shape predictor does not have 68 points with the same meaning as dlib's face shape predictor. You can use its source code and make your functions as you need

这篇关于训练结果不正确dlib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆