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

Fixed wrong pixel scales in XAI notebook #424

Merged
merged 1 commit into from
Mar 21, 2024
Merged

Conversation

takumiohym
Copy link
Collaborator

@takumiohym takumiohym commented Mar 5, 2024

The pixel values are wrongly rescale to [0, 1/255] in prediction, while they are [0,1] in training, and It was breaking the prediction and xai results.

The tf.image.convert_image_dtype(decoded, tf.float32) line changes the scale to [0,1] by default, and tf.cast(resized / 255.0, tf.float32) rescales it to [0, 1/255]. So I removed tf.cast(resized / 255.0, tf.float32).

Before this fix: (almost always predict as dandelion. Not picking up important pixels correctly)
Screenshot 2024-03-05 at 17 16 04

After this fix:
Screenshot 2024-03-05 at 17 16 48

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@takumiohym takumiohym marked this pull request as ready for review March 5, 2024 06:34
@takumiohym takumiohym changed the title Fixed wrong pixel scales in prediction Fixed wrong pixel scales in XAI notebook Mar 5, 2024
@takumiohym takumiohym requested a review from maabel0712 March 5, 2024 07:00
Copy link
Collaborator

@maabel0712 maabel0712 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@BenoitDherin BenoitDherin left a comment

Choose a reason for hiding this comment

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

LGTM

@takumiohym takumiohym merged commit 065baf5 into master Mar 21, 2024
5 checks passed
@takumiohym takumiohym deleted the fix_xai_scale branch March 21, 2024 14:08
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.

3 participants