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

AttributeError: 'numpy.ndarray' object has no attribute 'tobytes' #499

Closed
Vadimrozov opened this issue Mar 16, 2017 · 7 comments
Closed

AttributeError: 'numpy.ndarray' object has no attribute 'tobytes' #499

Vadimrozov opened this issue Mar 16, 2017 · 7 comments

Comments

@Vadimrozov
Copy link

@Vadimrozov Vadimrozov commented Mar 16, 2017

I have issue with write_gif function from basic example.

[MoviePy] Building file circle.gif with imageio
  0%|          | 0/31 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "/Users/vadimrozov/PycharmProjects/vector_art/main.py", line 12, in <module>
    clip.write_gif("circle.gif",fps=15)
  File "<decorator-gen-56>", line 2, in write_gif
  File "/Library/Python/2.7/site-packages/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "<decorator-gen-55>", line 2, in write_gif
  File "/Library/Python/2.7/site-packages/moviepy/decorators.py", line 22, in convert_masks_to_RGB
    return f(clip, *a, **k)
  File "/Library/Python/2.7/site-packages/moviepy/video/VideoClip.py", line 461, in write_gif
    verbose=verbose, colors=colors)
  File "/Library/Python/2.7/site-packages/moviepy/video/io/gif_writers.py", line 291, in write_gif_with_image_io
    writer.append_data(frame)
  File "/Library/Python/2.7/site-packages/imageio/core/format.py", line 481, in append_data
    return self._append_data(im, total_meta)
  File "/Library/Python/2.7/site-packages/imageio/plugins/pillowmulti.py", line 101, in _append_data
    self._writer.add_image(im, duration, dispose)
  File "/Library/Python/2.7/site-packages/imageio/plugins/pillowmulti.py", line 146, in add_image
    self.opt_palette_size)
  File "/Library/Python/2.7/site-packages/imageio/plugins/pillowmulti.py", line 332, in converToPIL
    im_pil = ndarray_to_pil(im, 'gif')
  File "/Library/Python/2.7/site-packages/imageio/plugins/pillow.py", line 483, in ndarray_to_pil
    array_buffer = arr.tobytes()
AttributeError: 'numpy.ndarray' object has no attribute 'tobytes'

Python 2.7.1
FFmpeg 3.2.4

I have no clue how to fix it.

@Zulko
Copy link
Owner

@Zulko Zulko commented Mar 16, 2017

What is your version of moviepy ?

import moviepy
print (moviepy.__version__)

@Vadimrozov
Copy link
Author

@Vadimrozov Vadimrozov commented Mar 17, 2017

/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 /Users/vadimrozov/PycharmProjects/vector_art/moviepy_example.py
print (moviepy.version) = 0.2.2.13

@gyglim
Copy link
Contributor

@gyglim gyglim commented Mar 17, 2017

How about this numpy version?
It didn't exist in older versions if numpy:
numpy/numpy#6163

import numpy
numpy.__version__

You can upgrade with
pip install numpy --upgrade

@Vadimrozov
Copy link
Author

@Vadimrozov Vadimrozov commented Mar 17, 2017

Thanks, it helps! But I have now another problem:

[MoviePy] Building file circle.gif with imageio
  0%|          | 0/31 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "/Users/vadimrozov/PycharmProjects/vector_art/moviepy_example.py", line 15, in <module>
    clip.write_gif("circle.gif",fps=15, opt="OptimizePlus", fuzz=10)
  File "<decorator-gen-56>", line 2, in write_gif
  File "/Library/Python/2.7/site-packages/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "<decorator-gen-55>", line 2, in write_gif
  File "/Library/Python/2.7/site-packages/moviepy/decorators.py", line 22, in convert_masks_to_RGB
    return f(clip, *a, **k)
  File "/Library/Python/2.7/site-packages/moviepy/video/VideoClip.py", line 461, in write_gif
    verbose=verbose, colors=colors)
  File "/Library/Python/2.7/site-packages/moviepy/video/io/gif_writers.py", line 291, in write_gif_with_image_io
    writer.append_data(frame)
  File "/Library/Python/2.7/site-packages/imageio/core/format.py", line 481, in append_data
    return self._append_data(im, total_meta)
  File "/Library/Python/2.7/site-packages/imageio/plugins/pillowmulti.py", line 101, in _append_data
    self._writer.add_image(im, duration, dispose)
  File "/Library/Python/2.7/site-packages/imageio/plugins/pillowmulti.py", line 146, in add_image
    self.opt_palette_size)
  File "/Library/Python/2.7/site-packages/imageio/plugins/pillowmulti.py", line 348, in converToPIL
    raise ValueError('Invalid value for quantizer: %r' % quantizer)
ValueError: Invalid value for quantizer: 'wu'

@Zulko
Copy link
Owner

@Zulko Zulko commented Mar 17, 2017

This will be fixed in the next release. Try using opt=0 in write_gif. If it doesnt work, install the version from the repo.

@Vadimrozov
Copy link
Author

@Vadimrozov Vadimrozov commented Mar 17, 2017

Thank you for help. I saved result to video file clip.write_videofile("circle.avi",fps=25,codec="mpeg4") and it's working as a charm.

@Shetuu
Copy link

@Shetuu Shetuu commented Jul 28, 2018

The baseline predictions are the historical averages

#baseline_preds = test_features[:, feature_list.index('average')]
baseline_preds = test_features.tofeature_list().index('DiabetesPedigreeFunction')

AttributeError: 'numpy.ndarray' object has no attribute 'tofeature_list'

whats the solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants