Is there a way to prevent python turicreate from using subdirectories as training data?

54 Views Asked by At

I'm getting my training data using...

turicreate.image_analysis.load_images('TrainingData', with_path=True)

TrainingData/ has all my training data using the folder names as labels...

data['label'] = data['path'].apply(lambda path: os.path.dirname(path.split('/')[-1]))

That gets the last directory... the problem is that turicreate is going deeper than I'm expecting it to.

The directory structure looks like this...

  • TrainingData/
    • Model1/
      • ADirectory/ // <== here's the problem (I want to ignore this directory)
        • img1_s.jpg
      • img1.jpg
      • img2.jpg
    • Model2/
  • runTuriCreate.py

At the moment turicreate is going into TrainingData which is what I'd expect... but it's using all subdirectories as well as the directories I want to model.

Is there a way to do this?

EDIT: I found that you can add recursive=False to the load_images function call. The problem with this is that I AM using recursion... just recursion with one depth level strictly.

0

There are 0 best solutions below