Home>
I want to read sequential images, convert them to ndarray format, and save them in a text file.
from PIL import Image
import numpy as np
import glob
file = glob.glob ('./ Desktop/Cat/*. jpg')
for f in file:
image = np.array (Image.open (file) .convert ('RGB'))
np.savetxt ('./ Desktop/image.txt', image, fmt = '%. 1e')
Traceback (most recent call last):
File "/home/hoge/.local/lib/python3.6/site-packages/PIL/Image.py", line 2613, in open
fp.seek (0)
AttributeError: 'list' object has no attribute 'seek'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./Desktop/image_data.py", line 7, in<module>
image = np.array (Image.open (files) .convert ('RGB'))
File "/home/yudai/.local/lib/python3.6/site-packages/PIL/Image.py", line 2615, in open
fp = io.BytesIO (fp.read ())
AttributeError: 'list' object has no attribute 'read'
There was the following related question.
How to store multiple image data in Python
python 3.6.7
numpy 1.15.4
ubuntu 18.04
-
Answer # 1
-
Answer # 2
Each error presented is an error on a variable named fp, but the code presented does not have fp
What is the definition of fp?
Related articles
- [python] i created a card game according to the textbook, but i get an attribute error
- python - how to list and represent line graphs
- python - object is not displayed in html in django queryset
- datetime - attribute error of "python practice data analysis 100 knocks"
- python - i want to send a list of yahoo news rankings to line
- python - about 2d list
- python - get member list with discord bot
- python - about unhashable, object is not callable
- python - combination/multiplication of list elements
- python - an error has occurred in yolo v3
- python 3x - manipulating python list
- python - [opencv] i want to display the area of each object at the position adjacent to the object
- python 3x - i want to convert to str list float list
- python - typeerror:'list' object is not callable
- python - 'httpresponse' object has no attribute'cookies'
- python - 'numpyndarray' object has no attribute'numpy' error
- python - i want to pass a list as an argument of glob and repeat it
- python - i want to store an object in an array
- python - the generated object will be cut off in 10 seconds
- python 3x - why is there no load attribute?
Trends
- python - you may need to restart the kernel to use updated packages error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- javascript - how to check if an element exists in puppeteer
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- sh - 'apt-get' is not recognized as an internal or external command, operable program or batch file
- i want to call a child component method from a parent in vuejs
- python 3x - typeerror: 'method' object is not subscriptable
instead of
image = np.array (Image.open (file). convert ('RGB'))) image = np.array (Image.open (f). convert ('RGB'))).
Furthermore,
image
is overwritten in the loop.To save multiple files as one text file, it is necessary to save the file after adding it to another array by the related question method.