Image count is zero

Question:

I am trying to create image classification model using tensorflow lite for android app here: https://www.tensorflow.org/tutorials/images/classification However,
I am using my local directory.

Here is my code:

import matplotlib.pyplot as plt
import numpy as np
import os
import PIL
import tensorflow as tf

from tensorflow import keras
from tensorflow.keras import layers
from tensorflow.keras.models import Sequential

import pathlib
data_dir = pathlib.Path('C:/Users/aalroumi/Documents/MLKIT/V')

image_count = len(list(data_dir.glob('*/*.JPEG')))
print(image_count)

and here is an image of the output:

![][1]

and this is the image of my local directory:

So why am I getting image size is zero?

Am I missing something? I did everything right.

Because I am trying to files.download('model.tflite')

Image size is zero error:

Thank you

Asked By: Magedo

||

Answers:

It seems you have images directly in data_dir so you should use *.JPEG to get them in glob()


But from_folder(data_dir) expects images in subfolders which names will be used as labels for images.

ie.

data_dir/cat/small_cat.JPEG
data_dir/cat/big_cat.JPEG
# ...
data_dir/dog/white_dog.JPEG
data_dir/dog/black_dog.JPEG

but you don’t have subfolders so it can’t find images in subfolders.
It doesn’t count images directly in data_dir

Answered By: furas