Open 121649982 opened 4 years ago
did you find the solution?
modify the code
Which part?
Hello,
I had a similar problem. I traced it back to the data iterator farm. In the file multithread_dataiter_for_cross_entropy_v2.py (or v1 if you are using that one) the values crop_top, crop_bottom, crop_left and crop_right are calculated for cropping the input image, e.g. crop_top = int(target_bbox[1] + target_bbox[3] / 2 + offset_y - self.net_input_height / 2.0)
The problem seems to be that target_box consists if float values (even if your original bounding boxes were int, because it gets multiplied by the float target_scale). Weird things can happen if we work with float values on computers. In that case, for example 100.3333333 + 50.666666 + x = x+151 while 100.3333333 + 50.666666 - x = 150.999999-x And then int(151+x) = x+151 while int(150.9999-x) = 150-x and that's the origin of the problem.
You can add a line like if crop_bottom-crop_top !=640: print(target_bbox,target_bbox[1] + target_bbox[3] / 2 + offset_x - self.net_input_width / 2.0,target_bbox[1] + target_bbox[3] / 2 + offset_x + self.net_input_width / 2.0)
to see it for yourself. (similiarly for crop_left and crop_right and you have to adjust the value of 640 to whatever you are using)
Anyway, I solved it by putting crop_top = int(int(target_bbox[1]) + int(target_bbox[3] / 2) + offset_y - self.net_input_height / 2.0) and similiarly for crop_bottom, crop_left and crop_right, i.e. I turn the values of target_bbox into ints to avoid the problems.
I don't know if this is the most elegant or most beautiful or most sophisticated solution, though, so any better ideas are highly welcomed.
I encountered such a problem