Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perception: prepare code for multi-scale camera object detection #8649

Merged

Conversation

KaWaiTsoiBaidu
Copy link
Contributor

Change code to accept multi-scale camera object detection outputs of neural networks. Preparation work for Yolo-v3 object detection network.

@techoe techoe changed the title prepare code for multi-scale camera object detection Perception: prepare code for multi-scale camera object detection Jun 4, 2019
@techoe
Copy link
Contributor

techoe commented Jun 4, 2019

Please fix lint error

@KaWaiTsoiBaidu KaWaiTsoiBaidu force-pushed the multi-scale_camera_obj_detection branch from 07b743d to c73a98a Compare June 4, 2019 23:01
@@ -126,21 +129,25 @@ __global__ void get_object_kernel(int n,
float scale = obj_data[loc_index];
float cx = (w + sigmoid_gpu(loc_data[offset_loc + 0])) / width;
float cy = (h + sigmoid_gpu(loc_data[offset_loc + 1])) / height;
float hw = exp(loc_data[offset_loc + 2]) * anchor_data[2 * c] / width * 0.5;
float hw = exp(max(-10.0f, min(loc_data[offset_loc + 2], 5.0f))) *
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-10.0f and 5.0f to constexpr values in header file


int num_anchor_per_scale = num_anchor;
if (multi_scale){
num_anchor_per_scale /= 3;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 in header file

const float *ori_data = ori_data_vec[i];
const float *dim_data = dim_data_vec[i];
const float *anchor_data = yolo_blobs.anchor_blob->gpu_data()
+ num_anchor_per_scale * 2 * i;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static_cast(num_anchor_per_scale * 2 * i)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an index, so integer should be used here.

std::vector<float> conf_score(cpu_cls_data + k * num_candidates,
cpu_cls_data + (k + 1) * num_candidates);
std::vector<float> conf_score(cpu_cls_data + k * all_scales_num_candidates,
cpu_cls_data + (k + 1) * all_scales_num_candidates);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

align indentation of all arguments in the next lanes to the first argument.
e.g.
std::vector conf_score(
. cpu_cls_data + k * all_scales_num_candidates,
cpu_cls_data + (k + 1) * all_scales_num_candidates);

int obj_size =
output_height * output_width * static_cast<int>(anchors_.size()) / 2;
output_height_scale1 * output_width_scale1 *
static_cast<int>(anchors_.size()) / 2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about
int obj_size = (output_height_scale1 * output_width_scale1 *
static_cast(anchors_.size())) / 2;
to reduce truncation error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here output_height_scale1 and output_width_scale1 are also integers, so maybe it does not matter?

(output_height_scale1 * output_width_scale1 +
output_height_scale2 * output_width_scale2 +
output_height_scale3 * output_width_scale3) *
static_cast<int>(anchors_.size()) / 2 / 3;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/2/3 to one constrexpr float

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, they are all integers in the expression. So I created 2 constexpr for both 2 and 3 and used them here as you suggested above instead of a constexpr float for 2/3.

@techoe techoe merged commit 97eb919 into ApolloAuto:master Jun 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants