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

correct_yolo_boxes #352

Open
plenari opened this issue Sep 15, 2019 · 5 comments
Open

correct_yolo_boxes #352

plenari opened this issue Sep 15, 2019 · 5 comments

Comments

@plenari
Copy link

plenari commented Sep 15, 2019

Detetion.custom.init.CustomDetectionUtils.correct_yolo_boxes

@staticmethod
def correct_yolo_boxes(boxes, image_h, image_w, net_h, net_w):
    
    new_w, new_h = net_w, net_h
    for i in range(len(boxes)):
        x_offset, x_scale = (net_w - new_w) / 2. / net_w, float(new_w) / net_w
        y_offset, y_scale = (net_h - new_h) / 2. / net_h, float(new_h) / net_h
        boxes[i].xmin = int((boxes[i].xmin - x_offset) / x_scale * image_w)
        boxes[i].xmax = int((boxes[i].xmax - x_offset) / x_scale * image_w)
        boxes[i].ymin = int((boxes[i].ymin - y_offset) / y_scale * image_h)
        boxes[i].ymax = int((boxes[i].ymax - y_offset) / y_scale * image_h)

hello, I'm confused. Isn't net_w equal to new_w here, so x_sacle is always equal to 1? In my opinion, when using kmeans to generate anchors boxes, you can directly zoom the image to 416*416. Can you also directly zoom back anchors boxes according to the size of the original image? So I don't know how x_offset works? Thanks very much?

@rola93
Copy link
Contributor

rola93 commented Sep 16, 2019

good point. Also x_offset is a little redundant on its definition.

It is a bit different from the original implementation

It may be related to #338 looks lie another bug introduced while taking this implementation to ImageAI, maybe @OlafenwaMoses can help us to understand this

@rola93
Copy link
Contributor

rola93 commented Sep 19, 2019

the following message was originally posted on #353 but the issue was closed as the main point on the issue was solved. However the message contain some clues to the current #352 issue, which wasn't solved yet

I found that init.CustomObjectDetection.detectObjectsFromImage operation uses init.CustomDetectionUtils.correct_yolo_boxes line 1270 but the init.DetectionModelTrainer.evaluateModel calls the utils.evaluate operation here which also calls the correct_yolo_boxes from the util module: those both implementations on current ImageAI version are different, but they are exactly the same in the original implementation.

Up to this point, my guess is that maybe, the implementation on init.CustomDetectionUtils.correct_yolo_boxes was sligthly modified to use square images, assuming/forcing them to be square before calling it, but it was not adjusted in the evaluate method.

@rola93
Copy link
Contributor

rola93 commented Oct 11, 2019

any news on this @OlafenwaMoses @plenari ?

@SB2020-eye
Copy link

@rola93 , hi, did you ever figure out how to get around this?

@rola93
Copy link
Contributor

rola93 commented Jun 14, 2021

saddle, nope. However, someone closed the issu, and in addition to this, there is a new ImageAI version, so need to check if it is still there. May be @OlafenwaMoses has some news on this.

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

3 participants