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

Make flexible naming in explanation.save #51

Merged

Conversation

GalyaZalesskaya
Copy link
Contributor

@GalyaZalesskaya GalyaZalesskaya commented Aug 2, 2024

Allows flexibly name the files with the prefix, suffix, and postfix. Add possibility to save confidence scores in saliency map name

    save(output_dir) -> aeroplane.jpg
    save(output_dir, prefix="image_name_target_") -> image_name_target_aeroplane.jpg
    save(output_dir, postfix="_class_map") -> aeroplane_class_map.jpg
    save(
        output_dir, prefix="image_name_", postfix="_conf_", confidence_scores=scores
    ) -> image_name_aeroplane_conf_0.85.jpg

@GalyaZalesskaya GalyaZalesskaya marked this pull request as ready for review August 2, 2024 15:57
Copy link

codecov bot commented Aug 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.25%. Comparing base (6f42d8d) to head (185e37d).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop      #51      +/-   ##
===========================================
+ Coverage    92.09%   92.25%   +0.16%     
===========================================
  Files           19       19              
  Lines         1278     1279       +1     
===========================================
+ Hits          1177     1180       +3     
+ Misses         101       99       -2     
Flag Coverage Δ
dev-py310 92.25% <100.00%> (+0.16%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@goodsong81 goodsong81 left a comment

Choose a reason for hiding this comment

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

Thank you for the usability enhancement!
BTW, I feel a bit confused by the terms. Can we refine?
Anyway, we need match the code & user guide.

docs/source/user-guide.md Outdated Show resolved Hide resolved
openvino_xai/explainer/explanation.py Outdated Show resolved Hide resolved
docs/source/user-guide.md Outdated Show resolved Hide resolved
@negvet
Copy link
Collaborator

negvet commented Aug 8, 2024

I am sorry, maybe I misunderstood it. But I am not sure why we need three string arguments. Can we can have just two?

We want the name to contain some target reference, this is for sure. This might be an index or a label name, it is known. Let's refer to it as target_id.
Then, we want to let the user to add some info before and after target_id, it can be image name, test number or whatever.

So here is the structure with two optional string arguments:
prefix + target_id + postfix

Having target_id=aeroplane, we can get:

  • aeroplane
  • image1_target_aeroplane (prefix=image1_target_)
  • aeroplane_test2 (postfix =_test2)

Now, we also want to support confidence_scores=scores, which is "" by default, then we have the following name components:
prefix + target_id + postfix + confidence

Then we get:

  • image1_target_aeroplane_conf_0.8 (prefix="image1_target_", postfix="_conf_", confidence_scores=scores)

@GalyaZalesskaya
Copy link
Contributor Author

@negvet I didn't like the idea of combining image_name_prefix and target_prefix since they have different meaning. One for image name, another - for target name. But the structure with 3 components indeed looks too complex, I agree.

My concern here, is that we put the responsibility to add target_ to prefix to the user, since there's no way for us to make it the default value. But probably, we don't need this target_ at all, since the saliency map name will be well-read even without it.

@negvet
Copy link
Collaborator

negvet commented Aug 8, 2024

@negvet I didn't like the idea of combining image_name_prefix and target_prefix since they have different meaning. One for image name, another - for target name. But the structure with 3 components indeed looks too complex, I agree.

My concern here, is that we put the responsibility to add target_ to prefix to the user, since there's no way for us to make it the default value. But probably, we don't need this target_ at all, since the saliency map name will be well-read even without it.

In general case, there might be image name, some explain parameters, shooting conditions, timeframe, etc.
Let's keep it simple, without any assumptions about meanings, such as string should start with image name. Why not just let the user define what she want to use before and after targer_id? For this we need to let the user control prefix and postfix.

In our examples, we might use image_name_target_aeroplane.jpg convention, but user is not required to follow it.

goodsong81
goodsong81 previously approved these changes Aug 9, 2024
Copy link
Contributor

@goodsong81 goodsong81 left a comment

Choose a reason for hiding this comment

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

Thanks for the update. I'm all OK for 2 args or 3 args.

Copy link
Collaborator

@negvet negvet left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@GalyaZalesskaya GalyaZalesskaya enabled auto-merge (squash) August 9, 2024 14:08
@GalyaZalesskaya GalyaZalesskaya merged commit ccfadb9 into openvinotoolkit:develop Aug 9, 2024
6 checks passed
@goodsong81 goodsong81 added this to the 1.1.0 milestone Sep 2, 2024
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