Skip to content

Fix regression in object detection models#3841

Open
alanocallaghan wants to merge 6 commits into
deepjavalibrary:masterfrom
alanocallaghan:fix-double-norm-objs
Open

Fix regression in object detection models#3841
alanocallaghan wants to merge 6 commits into
deepjavalibrary:masterfrom
alanocallaghan:fix-double-norm-objs

Conversation

@alanocallaghan

@alanocallaghan alanocallaghan commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

Description

Resolve #3840

Previously imageWidth/height was used from ObjectDetectionTranslator:

double x = imageWidth > 0 ? box[0] / imageWidth : box[0];
double y = imageHeight > 0 ? box[1] / imageHeight : box[1];
double w = imageWidth > 0 ? box[2] / imageWidth - x : box[2] - x;
double h = imageHeight > 0 ? box[3] / imageHeight - y : box[3] - y;

These were usually ignored/set to zero unless the rescaleRatio was set:

/**
* Sets the optional rescale size.
*
* @param imageWidth the width to rescale images to
* @param imageHeight the height to rescale images to
* @return this builder
*/
public T optRescaleSize(double imageWidth, double imageHeight) {
this.imageWidth = imageWidth;
this.imageHeight = imageHeight;
return self();
}

now, width/height are used from BaseImageTranslator, and these always default to 224x224:

protected int width = 224;
protected int height = 224;

Currently it is possible (and indeed common) to double-normalize the coordinates in this method (if width/height are nonzero and applyRatio is true), and the default is to normalize coordinates even though they are by default normalized in the SSD models anyway; meaning the default was double normalization and triple normalization is possible. This change means that coordinates are only normalized if the applyRatio flag is set, which seems appropriate based on the documentation.

@alanocallaghan alanocallaghan requested review from a team and zachgk as code owners March 2, 2026 20:20
@alanocallaghan alanocallaghan changed the title Fix double norm objs Fix regression in object detection models Mar 2, 2026
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.

Regression in object detection

1 participant