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

Add option to return HMTL object from visualize_text() #548

Closed
wants to merge 5 commits into from

Conversation

cdpierse
Copy link
Contributor

@cdpierse cdpierse commented Dec 3, 2020

Related issue: #544

Adds flag return_htmlto visualize_text() that allows for the IPython HTML to be returned if the flag is set to True.

This is useful for cases where users may want to save the output from outside of a notebook etc.

Usage looks like:

from captum.attr import visualization as viz
.... # get attributions and data record


html_obj = viz.visualize_text([score_viz], return_html=True)

@facebook-github-bot
Copy link
Contributor

Hi @cdpierse!

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file.

In order for us to review and merge your code, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@bilalsal
Copy link
Contributor

bilalsal commented Dec 6, 2020

Thanks @cdpierse for putting this together!

@miguelmartin75 and @vivekmig: do you prefer we add return_html as a parameter? Or to always return the HTML content instead? (the routine currently does not return any value(.

@miguelmartin75
Copy link
Contributor

miguelmartin75 commented Dec 8, 2020

Thanks @cdpierse for putting this together!

@miguelmartin75 and @vivekmig: do you prefer we add return_html as a parameter? Or to always return the HTML content instead? (the routine currently does not return any value(.

re @bilalsal

I don't see any reason for why we couldn't always return HTML, since this method doesn't return anything and the HTML content is always being constructed.

@NarineK
Copy link
Contributor

NarineK commented Dec 8, 2020

Feel free to return HTML. To avoid additional input argument, we can always return HTML and the user can chose to use it or not.

@cdpierse
Copy link
Contributor Author

cdpierse commented Dec 9, 2020

I've updated the PR so that HTML is now just always returned by default. Thanks.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@bilalsal has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@bilalsal merged this pull request in 4e40f9f.

@cdpierse cdpierse deleted the visualize_text_return_html branch December 11, 2020 23:27
vivekmig pushed a commit that referenced this pull request Jan 21, 2021
Summary:
Related issue: #544

Adds flag `return_html`to `visualize_text()` that allows for the IPython HTML to be returned if the flag is set to `True`.

This is useful for cases where users may want to save the output from outside of a notebook etc.

Usage looks like:

```python
from captum.attr import visualization as viz
.... # get attributions and data record

html_obj = viz.visualize_text([score_viz])
```

Pull Request resolved: #548

Reviewed By: vivekmig

Differential Revision: D25424019

Pulled By: bilalsal

fbshipit-source-id: 27a90f2775d90cbc848858fe1b439ddc2855cba4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants