Skip to content

Commit

Permalink
Added some hyper-params to the yolov4-tiny_contrastive.cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyAB committed Oct 20, 2020
1 parent 7a28aad commit 88936e0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
5 changes: 5 additions & 0 deletions build/darknet/x64/cfg/yolov4-tiny_contrastive.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,11 @@ beta_nms=0.6
max_delta=5
embedding_layer = -4

track_history_size = 20
sim_thresh = 0.7
dets_for_show = 2
dets_for_track = 8
track_ciou_norm = 0.2

[route]
layers= -5
Expand Down
28 changes: 23 additions & 5 deletions src/http_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -782,9 +782,27 @@ int check_classes_id(detection det1, detection det2, float thresh)
getchar();
}

int det1_id = -1;
float det1_prob = 0;
int det2_id = -1;
float det2_prob = 0;

for (int i = 0; i < det1.classes; ++i) {
if (det1.prob[i] > thresh && det2.prob[i] > thresh) return 1;
if (det1.prob[i] > thresh && det1.prob[i] > det1_prob) {
det1_prob = det1.prob[i];
det1_id = i;
}
if (det2.prob[i] > thresh && det2.prob[i] > det2_prob) {
det2_prob = det2.prob[i];
det2_id = i;
}
}

if (det1_id == det2_id && det2_id != -1) return 1;

//for (int i = 0; i < det1.classes; ++i) {
// if (det1.prob[i] > thresh && det2.prob[i] > thresh) return 1;
//}
return 0;
}

Expand Down Expand Up @@ -864,7 +882,6 @@ void set_track_id(detection *new_dets, int new_dets_num, float thresh, float sim
std::sort(sim_det.begin(), sim_det.end(), [](similarity_detections_t v1, similarity_detections_t v2) { return v1.sim > v2.sim; });
//if(sim_det.size() > 0) printf(" sim_det_first = %f, sim_det_end = %f \n", sim_det.begin()->sim, sim_det.rbegin()->sim);


std::vector<int> new_idx(new_dets_num, 1);
std::vector<int> old_idx(old_dets.size(), 1);
std::vector<int> track_idx(new_track_id, 1);
Expand All @@ -878,13 +895,14 @@ void set_track_id(detection *new_dets, int new_dets_num, float thresh, float sim
//printf(" ciou = %f \n", box_ciou(new_dets[new_id].bbox, old_dets[old_id].bbox));
if (track_idx[track_id] && new_idx[new_id] && old_idx[old_id] && check_classes_id(new_dets[new_id], old_dets[old_id], thresh)) {
float sim = sim_det[index].sim;
float ciou = box_ciou(new_dets[new_id].bbox, old_dets[old_id].bbox);
//float ciou = box_ciou(new_dets[new_id].bbox, old_dets[old_id].bbox);
float ciou = box_iou(new_dets[new_id].bbox, old_dets[old_id].bbox);
sim = sim * (1 - track_ciou_norm) + ciou * track_ciou_norm;
if (sim_thresh < sim) {
if (sim_thresh < sim && new_dets[new_id].sim < sim) {
new_dets[new_id].sim = sim;
new_dets[new_id].track_id = track_id;
new_dets[new_id].sort_class = det_count + 1;
new_idx[new_id] = 0;
//new_idx[new_id] = 0;
old_idx[old_id] = 0;
if(track_id) track_idx[track_id] = 0;
}
Expand Down

0 comments on commit 88936e0

Please sign in to comment.