Skip to content

Conversation

larryaxinc
Copy link

@larryaxinc larryaxinc commented Jun 18, 2025

#145 Implemented.
Also looks like the click point on image height is not fit well. It would be very appreciate if you could have some idea.

@larryaxinc larryaxinc requested a review from kyakuno June 18, 2025 04:59
float scale = GetScale(originalWidth, originalHeight);
int newWidth = imageSize;
int newHeight = imageSize;
Color32[] resizedImage = ResizeColor32(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In ResizeColor32, scaling is performed without maintaining the aspect ratio, ignoring scale. In ApplyCoordinateScaling, the coordinates of the Point are corrected with scale. A mismatch occurs here. Please provide the scale as an argument to ResizeColor32 and perform resizing while maintaining the aspect ratio.

Copy link
Author

@larryaxinc larryaxinc Jun 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. The solution is to scale the width and height separately with target size(1024). Because the inference need the shape to be (3, 1024, 1024). So if scale ratio(GetScale) cause it become (3, 683, 1024),it will cause memory out error with the inference.
Please refer to line 1279.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@larryaxinc Resize while maintaining the aspect ratio, and fill the margins with black. If this is not corrected, I think the problem where the clicked point and the segmented point do not align will not be resolved.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2025-06-30 at 12 57 18 Keep the aspect ration, and fill in other margin with black to make the shape keep(3, 1024, 1024). But somehow this looked a bit wried on height(1200 in height, 1800 in width for original img).

Application.temporaryCachePath,
promptProtoPath
);
// string mlpPath = System.IO.Path.Combine(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please delete unnecessary comments.

@kyakuno
Copy link
Contributor

kyakuno commented Jun 24, 2025

@larryaxinc I have filled in the feedback, so please respond. Also, please test whether it works in WEB camera mode. You can set camera_mode to true in AiliaImageSegmentationSample.cs to enable WEB camera mode.

@kyakuno
Copy link
Contributor

kyakuno commented Jul 11, 2025

@larryaxinc The accuracy is lower compared to the Python version. Please dump the input and output float values of the vision encoder and calculate the mean squared error between the outputs of the Python and Unity versions to analyze where the issue lies.

unity python

@larryaxinc
Copy link
Author

@larryaxinc The accuracy is lower compared to the Python version. Please dump the input and output float values of the vision encoder and calculate the mean squared error between the outputs of the Python and Unity versions to analyze where the issue lies.

unity python

@kyakuno It has been fixed by the new commit. Please have a check.

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.

2 participants