1

Here is the code:

from os import listdir
from os.path import isfile, join

vvy_imgs = []
#images to tensors
for img in np.array([f for f in listdir('E:/vachan') if isfile(join('E:/vachan', f))]): # filepaths 
    print(img) # shows it's of jpg extension
    tensor = tf.io.decode_jpeg(img, channels=3)
    vvy_imgs = np.append(vvy_imgs, tensor)

but it is showing error

InvalidArgumentError: Unknown image file format. One of JPEG, PNG, GIF, BMP required. [Op:DecodeJpeg]

though all the images are of '.jpg' extension.

AloneTogether
  • 25,814
  • 5
  • 20
  • 39

1 Answers1

0

Seems like img is a path to an image and not an image. Maybe try:

image = tf.io.read_file(img)
tensor= tf.io.decode_jpeg(image)
...
AloneTogether
  • 25,814
  • 5
  • 20
  • 39