当前位置: 首页>>代码示例>>C++>>正文


C++ DataSet::HasGtShape方法代码示例

本文整理汇总了C++中DataSet::HasGtShape方法的典型用法代码示例。如果您正苦于以下问题:C++ DataSet::HasGtShape方法的具体用法?C++ DataSet::HasGtShape怎么用?C++ DataSet::HasGtShape使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataSet的用法示例。


在下文中一共展示了DataSet::HasGtShape方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Train


//.........这里部分代码省略.........
          cart.mean = 0.;
          cart.std = 1.;
        }
        pos.QSort();
        neg.QSort();
        //JDA_Assert(cart.th == pos.CalcThresholdByNumber(1), "restart error");
      }
      else {
        // recover data scores
        pos.ResetScores();
        neg.ResetScores();
        k--;
        continue;
      }
    }

    // update restart parameters
    best_drop_rate = 0.;
    restarts = 0;

    pos.Remove(cart.th);
    neg.Remove(cart.th);

    // print cart info
    cart.PrintSelf();
    if ((kk != K) && (kk%c.snapshot_iter == 0)) { // snapshot model and data
      DataSet::Snapshot(pos, neg);
      c.joincascador->Snapshot();
    }

    int pos_drop = pos_n - pos.size;
    int neg_drop = neg_n - neg.size;
    double pos_drop_rate = double(pos_drop) / double(pos_n)* 100.;
    double neg_drop_rate = double(neg_drop) / double(neg_n)* 100.;
    LOG("Pos drop = %d, Neg drop = %d, drop rate = %.2lf%%", pos_drop, neg_drop, neg_drop_rate);
    neg_rejected += neg_n - neg.size;
  }
  // Global Regression with LBF
  // generate lbf
  const int pos_n = pos.size;
  const int neg_n = neg.size;
  LOG("Generate LBF of DataSet");
  vector<Mat_<int> > pos_lbf(pos_n);
  vector<Mat_<int> > neg_lbf(neg_n);

  #pragma omp parallel for
  for (int i = 0; i < pos_n; i++) {
    pos_lbf[i] = GenLBF(pos.imgs[i], pos.current_shapes[i]);
  }
  #pragma omp parallel for
  for (int i = 0; i < neg_n; i++) {
    neg_lbf[i] = GenLBF(neg.imgs[i], neg.current_shapes[i]);
  }

  // regression, use valid face which has gt_shape
  vector<int> valid_pos_idx;
  vector<Mat_<int> > valid_pos_lbf;
  for (int i = 0; i < pos.size; i++) {
    if (pos.HasGtShape(i)) {
      valid_pos_idx.push_back(i);
      valid_pos_lbf.push_back(pos_lbf[i]);
    }
  }
  Mat_<double> shape_residual_valid = pos.CalcShapeResidual(valid_pos_idx);
  LOG("Start Global Regression");
  GlobalRegression(valid_pos_lbf, shape_residual_valid);
  // update shapes
  #pragma omp parallel for
  for (int i = 0; i < pos_n; i++) {
    pos.current_shapes[i] += GenDeltaShape(pos_lbf[i], pos.stp_mc[i]);
  }
  #pragma omp parallel for
  for (int i = 0; i < neg_n; i++) {
    neg.current_shapes[i] += GenDeltaShape(neg_lbf[i], neg.stp_mc[i]);
  }

  // summary
  LOG("====================");
  LOG("|      Summary     |");
  LOG("====================");
  // regression error
  vector<Mat_<double> > valid_gt_shapes;
  vector<Mat_<double> > valid_current_shapes;
  for (int i = 0; i < pos.size; i++) {
    if (pos.HasGtShape(i)) {
      valid_gt_shapes.push_back(pos.gt_shapes[i]);
      valid_current_shapes.push_back(pos.current_shapes[i]);
    }
  }
  double e = calcMeanError(valid_gt_shapes, valid_current_shapes);
  LOG("Regression Mean Error = %.4lf", e);

  // accept and reject rate
  double accept_rate = 0.;
  double reject_rate = 0.;
  accept_rate = double(pos_n) / double(pos_original_size) * 100.;
  reject_rate = double(neg_rejected) / double(neg_rejected + neg_original_size) * 100.;
  LOG("Accept Rate = %.2lf%%", accept_rate);
  // Done
}
开发者ID:langongjin,项目名称:JDA,代码行数:101,代码来源:btcart.cpp


注:本文中的DataSet::HasGtShape方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。