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

The question about the different between darknet-yolo2 and caffe-yolo9000 #8

Closed
chengshuai opened this issue May 8, 2017 · 9 comments

Comments

@chengshuai
Copy link

Hello, thank you for the code caffe-yolo9000, i have some question:
question 1: why multiply -1.0 in the region_layer_loss.cpp(caffe-yolo9000), but no multiply the -1.0 in the region_layer.c(darknet-yolo2),for example,
the file region_layer.c in the darknet-yolo2:
float delta_region_box(box truth, float x, float biases, int n, int index, int i, int j, int w, int h, float delta, float scale)
{
box pred = get_region_box(x, biases, n, index, i, j, w, h);
float iou = box_iou(pred, truth);
//????????
float tx = (truth.x
w - i);
float ty = (truth.y
h - j);
float tw = log(truth.w
w / biases[2n]);
float th = log(truth.h
h / biases[2*n + 1]);

delta[index + 0] = scale * (tx - logistic_activate(x[index + 0])) * logistic_gradient(logistic_activate(x[index + 0]));//sigmoid gradient = f(x)*(1-f(x))
delta[index + 1] = scale * (ty - logistic_activate(x[index + 1])) * logistic_gradient(logistic_activate(x[index + 1]));
delta[index + 2] = scale * (tw - x[index + 2]);
delta[index + 3] = scale * (th - x[index + 3]);
return iou;

}
and in forward_region_layer,for example,
l.delta[index + 4] = l.noobject_scale * ((0 - l.output[index + 4]) * logistic_gradient(l.output[index + 4]));
l.delta[best_index + 4] = l.object_scale * (1 - l.output[best_index + 4]) * logistic_gradient(l.output[best_index + 4]);//

the file region_loss_layer.c in the caffe-yolo9000:
Dtype delta_region_box(vector truth, Dtype* x, vector biases, int n, int index, int i, int j, int w, int h, Dtype* delta, float scale){
vector pred;
pred.clear();
pred = get_region_box(x, biases, n, index, i, j, w, h);

float iou = Calc_iou(pred, truth);
//LOG(INFO) << pred[0] << "," << pred[1] << "," << pred[2] << "," << pred[3] << ";"<< truth[0] << "," << truth[1] << "," << truth[2] << "," << truth[3];
float tx = truth[0] * w - i; //0.5
float ty = truth[1] * h - j; //0.5
float tw = log(truth[2] * w / biases[2n]); //truth[2]=biases/w tw = 0
float th = log(truth[3] * h / biases[2
n + 1]); //th = 0

delta[index + 0] =# (-1.0) * scale * (tx - sigmoid(x[index + 0])) * sigmoid(x[index + 0]) * (1 - sigmoid(x[index + 0]));
delta[index + 1] =# (-1.0) * scale * (ty - sigmoid(x[index + 1])) * sigmoid(x[index + 1]) * (1 - sigmoid(x[index + 1]));
delta[index + 2] =# (-1.0) * scale * (tw - x[index + 2]);
delta[index + 3] =# (-1.0) * scale * (th - x[index + 3]);
return iou;
}
and loss function in the RegionLossLayer::Forward_cpu,for example,
diff[index + 4] = # (-1.0) * noobject_scale_ * (0 - swap_data[index + 4]) * (swap_data[index + 4]) * (1 - swap_data[index + 4]);
diff[best_index + 4] = # (-1.0) * object_scale_ * (1 - swap_data[best_index + 4]) * (swap_data[best_index + 4] * (1 - swap_data[best_index + 4]));

why do you multiply the coefficient -1.0?

question 2:

Do you add the reorg layer in the network? when add the reorg_layer, the train process is not convergence.

@choasup
Copy link
Owner

choasup commented May 8, 2017

  1. It is the difference between caffe and darknet. Gradient is added in caffe, but it is subtracted in darknet.
  2. I didn't add the reorg layer temporarily. I guess that maybe it is your problem.

@chengshuai
Copy link
Author

  1. I use the model that you release:gnet_yolo_region_darknet_v3_pretrain_rectify_iter_200000.caffemodel, and test the mAP in voc2007 test dataset , and the mAP is much lower than the darknet yolo2(55% vs 72%). Do you test the mAP on voc2007.
  2. I retrain the model caffeyolo9000, and the result is lower. (train data :voc07+12,test data:voc07). I do not use the pretraining model(gnet_yolo_region_darknet_v3_pretrain_iter_600000.caffemodel), because i do not have the model. Could you support the model? Do the pretraining model lead to the low mAP?

Thank you!

@choasup
Copy link
Owner

choasup commented May 12, 2017

  1. I have been finding where is the problem which results in low mAP.
  2. Pre-trained model is important, it refers to Weights file missing for PascalVOC training? #4.

@chengshuai
Copy link
Author

Thanks you for reply!

1.Could you show the details of the problem which results in low mAP, if you convenience, or share the code in github?

  1. Do you get convergence when add the reorg layer ?

Thank you!

@choasup
Copy link
Owner

choasup commented May 12, 2017

Details are all in the original repository. But I have to delete it for some reasons. I haven't add the reorg layer. I would tell you if I get a high mAP with reorg layer next week.

@chengshuai
Copy link
Author

@choasup

Do you add reorg layer and get a high mAP?

@OPPOA113
Copy link

@chengshuai @choasup
can you get a high mAp now?
i train my own data,but i can run successfully. some values bacame Nan or something like 0.0000000

@chengshuai
Copy link
Author

@OPPOA113

I do not get the high mAP.

you should check the train data(the data and label are wrong)

@litingsjj
Copy link

@choasup
void axpy_cpu(int N, float ALPHA, float *X, int INCX, float *Y, int INCY) { int i; for(i = 0; i < N; ++i) Y[i*INCY] += ALPHA*X[i*INCX]; }
Sorry, in this function, is the gradient is added in darknet? Or if defferent with caffe, where is it in darknet?Thx!

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

No branches or pull requests

4 participants