Reputation: 1
I use tensorflow2.0 to train some photos. At first I use pokemon data (nearly 1000 photos) collected by other guys. And I made the model successfully.
Then I wanted to use my own photos. The amount is small just 20 photos . I run the code (which seems successful):
[https://i.sstatic.net/cq204.png]
But receive then error
:Invalid argument: Expected image (JPEG, PNG, or GIF), got unknown format starting with 'RIFF\320\025\000\000WEBPVP8 '
[https://i.sstatic.net/msjiz.png]
I guess it is my photo's error. Is the amount too small? or photo's type is wrong?
I check it and it's all JPG or PNG
Upvotes: 0
Views: 1804
Reputation: 597
Actually the file type of one of your files in the dataset is not of the specified JPEG, PNG or GIF format. Although anyone could easily mistake with the extension of the file being one of these formats, the actual contents of the file are not of the appropriate format.
So here is what I did,
I was not aware of which file in my data directory was of a RIFF
format (as is your case) so I decided to print the binary contents of the file and manually check it. [This is brute force way and this is what struck me then!]
I wrote this snippet to help me do that
import os
for i, filename in enumerate(os.listdir('./')):
with open(filename, 'rb') as imageFile:
if imageFile.read().startswith(b'RIFF'):
print(f"{i}: {filename} - found!")
I ran this snippet on all the class folders and found that indeed one of the files in those folders had a RIFF format, I got the name of the file as well which was not of the appropriate format and then just removed that file from directory. This solved my problem.
Upvotes: 3