Home > database >  AssertionError for tfrecord_dir in stylegan . What should be correct argument?
AssertionError for tfrecord_dir in stylegan . What should be correct argument?

Time:08-29

When I try to run stylegan training.py it throws AssertionError as follows. What should be the correct tfrecord_dir argument ?

In training.py it has ;

desc  = '-dataset';     
dataset = EasyDict(tfrecord_dir='dataset', resolution=128); 
train.mirror_augment = False

I put tfrecord_dir argument as dataset. The path should be correct. My tfrecords path is \stylegan\dataset. My training.py path is \stylegan.

This is my error:

PS C:\Users\dell> & C:/Users/dell/AppData/Local/Programs/Python/Python310/python.exe "c:/Users/dell/Desktop/Data Science/GAN/stylegan/train.py"

File "c:\Users\dell\Desktop\Data Science\GAN\stylegan\training\dataset.py", line 71, in __init__
    assert os.path.isdir(self.tfrecord_dir)
AssertionError

Paths are as follows:

tfrecords_path: https://img.codepudding.com/202208/9ab8374880134fc28da2d4bc5de24cc5.png

training.py & tfrecords_path: https://img.codepudding.com/202208/223b0ccbd5e54103961f94aa7d39cafe.png

CodePudding user response:

Short answer:

You have to set self.tfrecord_dir= '../dataset/'

Long answer:

I had a look at the files. Ok so basically the error comes from the line:

assert os.path.isdir(self.tfrecord_dir)

It means that the path you have inserted in self.tfrecord_dir is not recognized as a directory.

You set: self.tfrecord_dir= '\stylegan\dataset'

This is your file structure:

/stylegan/dataset/ 
/stylegan/training/dataset.py

You are executing the code from inside the training directory, and you want to go two position up from that, in stylegan, to be able to access dataset.

Adding ./ before your path lets you access the files of the parent directory of your current position. If you add ../ you get what you need. This leaves us with:

self.tfrecord_dir= '../dataset/'

CodePudding user response:

I have found the answer.You have to set self.tfrecord_dir= 'mars' and the dataset should be under ./datasets/mars folder.

  • Related