| 431 | } |
| 432 | |
| 433 | void warmup(int device_id) { |
| 434 | int logtostderr = FLAGS_logtostderr; |
| 435 | |
| 436 | LOG(INFO) << "Setting GPU " << device_id; |
| 437 | |
| 438 | caffe::Caffe::SetDevice(device_id); //cudaSetDevice(device_id) inside |
| 439 | caffe::Caffe::set_mode(caffe::Caffe::GPU); // |
| 440 | |
| 441 | LOG(INFO) << "GPU " << device_id << ": copying to person net"; |
| 442 | FLAGS_logtostderr = 0; |
| 443 | net_copies[device_id].person_net = new caffe::Net<float> |
| 444 | (PERSON_DETECTOR_PROTO, caffe::TEST); |
| 445 | net_copies[device_id].person_net->CopyTrainedLayersFrom |
| 446 | (PERSON_DETECTOR_CAFFEMODEL); |
| 447 | |
| 448 | net_copies[device_id].nblob_person = net_copies[device_id].person_net-> |
| 449 | blob_names().size(); |
| 450 | net_copies[device_id].num_people.resize(BATCH_SIZE); |
| 451 | const std::vector<int> shape { {BATCH_SIZE, 3, NET_RESOLUTION_HEIGHT, |
| 452 | NET_RESOLUTION_WIDTH} }; |
| 453 | |
| 454 | net_copies[device_id].person_net->blobs()[0]->Reshape(shape); |
| 455 | net_copies[device_id].person_net->Reshape(); |
| 456 | FLAGS_logtostderr = logtostderr; |
| 457 | |
| 458 | caffe::NmsLayer<float> *nms_layer = |
| 459 | (caffe::NmsLayer<float>*)net_copies[device_id].person_net-> |
| 460 | layer_by_name("nms").get(); |
| 461 | net_copies[device_id].nms_max_peaks = nms_layer->GetMaxPeaks(); |
| 462 | |
| 463 | |
| 464 | caffe::ImResizeLayer<float> *resize_layer = |
| 465 | (caffe::ImResizeLayer<float>*)net_copies[device_id].person_net-> |
| 466 | layer_by_name("resize").get(); |
| 467 | |
| 468 | resize_layer->SetStartScale(START_SCALE); |
| 469 | resize_layer->SetScaleGap(SCALE_GAP); |
| 470 | LOG(INFO) << "start_scale = " << START_SCALE; |
| 471 | |
| 472 | net_copies[device_id].nms_max_peaks = nms_layer->GetMaxPeaks(); |
| 473 | |
| 474 | net_copies[device_id].nms_num_parts = nms_layer->GetNumParts(); |
| 475 | CHECK_LE(net_copies[device_id].nms_num_parts, MAX_NUM_PARTS) |
| 476 | << "num_parts in NMS layer (" << net_copies[device_id].nms_num_parts |
| 477 | << ") " |
| 478 | << "too big ( MAX_NUM_PARTS )"; |
| 479 | |
| 480 | if (net_copies[device_id].nms_num_parts==15) { |
| 481 | ModelDescriptorFactory::createModelDescriptor |
| 482 | (ModelDescriptorFactory::Type::MPI_15, |
| 483 | net_copies[device_id].up_model_descriptor); |
| 484 | global.nms_threshold = 0.2; |
| 485 | global.connect_min_subset_cnt = 3; |
| 486 | global.connect_min_subset_score = 0.4; |
| 487 | global.connect_inter_threshold = 0.01; |
| 488 | global.connect_inter_min_above_threshold = 8; |
| 489 | LOG(INFO) << "Selecting MPI model."; |
| 490 | } else if (net_copies[device_id].nms_num_parts==18) { |
no test coverage detected