PIL.UnidentifiedImageError: cannot identify image file
See original GitHub issueI made tsv builder for custom image inference
but error occurs when I run it with my tsv file
PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x7f8897ba1e50>
I find that str convert into float64 automatically when I save tsv file with pandas
here’s my custom make_tsv function
def make_tsv(datapath, img_list, start_index):
data = pd.DataFrame({"unique_id": [], "img_id": [], "caption": [], "predicted_object_labels": [], "base64_str": []})
for i, img_name in enumerate(img_list):
print("index: ", i)
print("img_name: ", img_name)
img = Image.open(os.path.join(datapath, img_name))
img_buffer = BytesIO()
img.save(img_buffer, format=img.format)
byte_data = img_buffer.getvalue()
unique_id = start_index + i
img_id = img_name.split(".")[-2]
caption = ""
predicted_object_labels = ""
base64_str = base64.b64encode(byte_data)
temp_dataframe = pd.DataFrame({"unique_id": [unique_id], "img_id": [img_id], "caption": [caption], \
"predicted_object_labels": [predicted_object_labels], \
"base64_str": [str(base64_str)]})
data = pd.concat([data, temp_dataframe], ignore_index=True)
return data
and I can’t find solution yet.
can u give me advise??
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Image.open() cannot identify image file - Python?
When I was uploading my images, that had not been giving this error locally, I was observing UnidentifiedImageError exception thrown by PIL when ......
Read more >PIL.UnidentifiedImageError: cannot identify image file: .ai #4392
Pillow seems to not be able to load .ai file using Pillow 7.0 File "/usr/local/lib/python3.7/site-packages/PIL/Image.py", line 2862, ...
Read more >PIL.UnidentifiedImageError: cannot identify image file <_io ...
How to reproduce the issue ? I am experiencing an error similar to this topic: Error when executing tao classification, cannot identify image...
Read more >cannot identify image file <_io.BytesIO object at ... - Kaggle
I don't understand this error message : UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x7fcdd17f6d70>
Read more >Getting this error Unknown: UnidentifiedImageError: cannot ...
Hi, Can someone please help me with this error. Unknown: UnidentifiedImageError: cannot identify image file <_io.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Im really appreciate with your aid.
I was fool
I’ll check what u said first.
By the way, the necessity of using
base64_str = base64.b64encode(byte_data).decode("utf-8")
instead ofbase64_str = base64.b64encode(byte_data)
is to avoid obtaining a string like “b’/9j/4AAQSkZJRgA’” in your tsv file and further cause some errors.