misc.imresize()
so,
AttributeError: module 'scipy.misc' has no attribute 'imresize'
May appear.
This is simple, You can see the countermeasures by going around, but I don't like that kind of activity. If I can afford it, I will do some research. This time, I will write an article about what I learned.
Name: scipy Version: 1.4.1 Summary: SciPy: Scientific Library for Python Home-page: https://www.scipy.org
This is related to the common scipy version upgrade, "What was working with the old version of sicpy becomes an error with scipy version 1.3.0 or later" series? is.
** Set scipy to 1.2.0 ** I get a warning saying "Remove in 1.3.0", but it works.
block_1_hobo_org.py:23: DeprecationWarning: `imresize` is deprecated!
`imresize` is deprecated in SciPy 1.0.0, and will be removed in 1.3.0.
Use Pillow instead: ``numpy.array(Image.fromarray(arr).resize())``.
obs = (misc.imresize(obs, (110, 84))) #===
Shown at the same time as the above warning numpy.array(Image.fromarray(arr).resize()) use.
** (First, there's just no function called imresize. Another one, It ’s a simple and very easy story to use resize, so As an easy thing, calm down. .. .. .. ) **
Note 1: Specifying the size with ** resize is tuple. ** ** Note 2: ** imresize and resize seem to have the reverse order of hight and width. ** **
In particular, ** imresize (xxx, (110, 42)) ** resize((42,110)) I think you should write it in reverse. Please note that some sites may be incorrect in the explanation on the net.
** Pay attention to the order of width and height **
(As an aside, the command is, for example, "python -m pydoc PIL.Image.Image.resize". ** Image.Image ** ... I think you can understand it. .)
C:XXXX>python -m pydoc PIL.Image.Image.resize
Help on function resize in PIL.Image.Image:
PIL.Image.Image.resize = resize(self, size, resample=0, box=None)
Returns a resized copy of this image.
:param size: The requested size in pixels, as a 2-tuple:
(width, height).
:param resample: An optional resampling filter. This can be
one of :py:attr:`PIL.Image.NEAREST`, :py:attr:`PIL.Image.BOX`,
:py:attr:`PIL.Image.BILINEAR`, :py:attr:`PIL.Image.HAMMING`,
:py:attr:`PIL.Image.BICUBIC` or :py:attr:`PIL.Image.LANCZOS`.
If omitted, or if the image has mode "1" or "P", it is
set :py:attr:`PIL.Image.NEAREST`.
See: :ref:`concept-filters`.
:param box: An optional 4-tuple of floats giving the region
of the source image which should be scaled.
The values should be within (0, 0, width, height) rectangle.
If omitted or None, the entire source is used.
:returns: An :py:class:`~PIL.Image.Image` object.
(As an aside, the command is, for example, "python -m pydoc scipy.misc.imresize".)
C:XXXXX>python -m pydoc scipy.misc.imresize
Help on function imresize in scipy.misc:
scipy.misc.imresize = imresize(*args, **kwds)
`imresize` is deprecated!
`imresize` is deprecated in SciPy 1.0.0, and will be removed in 1.3.0.
Use Pillow instead: ``numpy.array(Image.fromarray(arr).resize())``.
Resize an image.
This function is only available if Python Imaging Library (PIL) is installed.
.. warning::
This function uses `bytescale` under the hood to rescale images to use
the full (0, 255) range if ``mode`` is one of ``None, 'L', 'P', 'l'``.
It will also cast data for 2-D images to ``uint32`` for ``mode=None``
(which is the default).
Parameters
----------
arr : ndarray
The array of image to be resized.
size : int, float or tuple
* int - Percentage of current size.
* float - Fraction of current size.
* tuple - Size of the output image (height, width).
interp : str, optional
I got an error Guguru ... I have no choice but to do that, but I don't like it. I looked it up and made an article. .. .. .. (It's a contradiction because I'm writing an article with the intention of being confused and useful, but it's a stepping stone for the future ...)
[Correspondence to Python error "Import Error: cannot import name'imread' from'scipy.misc'" in deep learning] (https://qiita.com/enoughspacefor/items/c490ec7195cf66fa286f) Learn Python carefully using both English and Japanese.
If you have any comments, please let us know. : candy: Will study,,,,
Recommended Posts