Search code examples
pythonmachine-learninggoogle-colaboratorytensorflow-liteimage-classification

ValueError: Image size is zero in Google Colab


I'm learning ML model training following this tutorial from Tensorflow. I have uploaded my own dataset from my computer to a folder named "sample_arrow" in Google Colab and specified the path to it:

image_path = 'sample_arrow'

The folder contains images, the size is not 0. But I get an error when executing this line of code:

data = DataLoader.from_folder(image_path) train_data, test_data = data.split(0.9)

ValueError: Image size is zero

enter image description here

What is wrong here? Maybe the folder path is not specified correctly? I'm completely new to the topic, unfamiliar with Pyhon (have Java skills) and would appreciate a detailed answer.


Solution

  • At last, I've found the solution. Import os and the correct path definition were missing:

    import os
    
    
    root_path = "/content/"    
    image_path = os.path.join(os.path.dirname(root_path), 'sample_arrow')
    

    enter image description here