Reputation: 11753
I understand there are many people who are in favor of using Jupyter Notebook, powered by IPython library. I am, however, prefer to work in PyCharm and write Python script.
When I want to reduplicate codes written in Jupyter Notebook, I found sometimes they use functions from IPython. For example, this example:
from fastai.vision.widgets import *
cleaner = ImageClassifierCleaner(learn)
cleaner
Here cleaner
is a class that has widgets that can be displayed in Juypter Notebook. If I run the function in a Python script, then the widget will not be shown. I tried to fix it use the following codes:
from fastai.vision.widgets import *
cleaner = ImageClassifierCleaner(learn)
from IPython.display import display
display(cleaner.widget)
plt.show()
It does not work. Any ideas? Thanks.
ps1: use print(cleaner)
:
<PIL.Image.Image image mode=RGBA size=227x128 at 0x7F99C4F97470>
<PIL.Image.Image image mode=RGBA size=226x128 at 0x7F99C3679898>
<fastai.vision.widgets.ImageClassifierCleaner object at 0x7f99f803ec88>
Upvotes: 0
Views: 1010
Reputation: 565
Jupyter widgets (and the display
function) use JavaScript to render the output as an HTML element within the notebook page, so you can't use those in a regular Python script. If the hang-up is that you want to be able to use PyCharm, here's how you can run a Jupyter notebook within the IDE.
Upvotes: 2