Pytorch-cyclegan-and-pix2pix: Help! - AsserstionError - not a valid directory / randrange() (0,0, 0)

Created on 11 Sep 2018  路  12Comments  路  Source: junyanz/pytorch-CycleGAN-and-pix2pix

I have manually downloaded the maps dataset,
and ran the train command in Anaconda3 prompt (Windows 10 64bit).
I get the following error -

Traceback (most recent call last): File "train.py", line 9, in <module> data_loader = CreateDataLoader(opt) File "C:\Users\tyk12\Documents\2_CODE\pix2pix\pytorch-CycleGAN-and-pix2pix\data\__init__.py", line 46, in CreateDataLoader data_loader.initialize(opt) File "C:\Users\tyk12\Documents\2_CODE\pix2pix\pytorch-CycleGAN-and-pix2pix\data\__init__.py", line 58, in initialize self.dataset = create_dataset(opt) File "C:\Users\tyk12\Documents\2_CODE\pix2pix\pytorch-CycleGAN-and-pix2pix\data\__init__.py", line 39, in create_dataset instance.initialize(opt) File "C:\Users\tyk12\Documents\2_CODE\pix2pix\pytorch-CycleGAN-and-pix2pix\data\unaligned_dataset.py", line 19, in initialize self.A_paths = make_dataset(self.dir_A) File "C:\Users\tyk12\Documents\2_CODE\pix2pix\pytorch-CycleGAN-and-pix2pix\data\image_folder.py", line 26, in make_dataset assert os.path.isdir(dir), '%s is not a valid directory' % dir AssertionError: ./datasets/maps/trainA is not a valid directory

Thank you in advance!

All 12 comments

Two possible reasons: (1) Maybe you haven't placed the dataset in the path ./datasets/maps/trainA. (2) I haven't used Windows for a long time. Maybe you want to replace the / by \ in the path.

Thank you ! After sorting out the file directory like you mentioned, it moved on :)

The training process started, but then I ran into 4 exceptions and 1 connection error -

  1. ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

  2. urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x000001B7122DDDD8>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it

  3. urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=8097): Max retries exceeded with url: /env/main (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000001B7122DDDD8>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it',))

  4. File "C:\Users\tyk12\Anaconda3\lib\site-packages\requests\adapters.py", line 508, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8097): Max retries exceeded with url: /env/main (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000001B7122DDDD8>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it',))

  5. ConnectionError: Error connecting to Visdom server

When I trigger visdom command, the Visdom browser window pops up fine.

I am going through Q&A, and google-searching to solve the issues one by one :)

Please look at the Q & A.

Oooooh... I never thought about having 2 anaconda prompt windows open!
one for Visdom and one for training... Sorry and thanks!

Now I ran into a new error;
ValueError: empty range for randrange() (0,0, 0)

I am referring to issue #194

I tried adding --loadSize 143 --fineSize 128

and I still get the same error;

    index_B = random.randint(0, self.B_size - 1)
  File "C:\Users\tyk12\Anaconda3\lib\random.py", line 221, in randint
    return self.randrange(a, b+1)
  File "C:\Users\tyk12\Anaconda3\lib\random.py", line 199, in randrange
    raise ValueError("empty range for randrange() (%d,%d, %d)" % (istart, istop, width))
ValueError: empty range for randrange() (0,0, 0)

Thank you for helping me along the way :)
I got to learn a lot.
I think I am almost there..!

I don't know the solution. The command python train.py --dataroot ./datasets/maps --name maps_cyclegan --model cycle_gan works for me on my Linux. The code has not been tested on Windows.

Okay thanks for looking into it 馃憤

Maybe I should try docker.

Got this to run in Windows properly now!

I changed the directories in image_folder.py, and downgraded the version of visdom.

Thanks again ! :)

Got this to run in Windows properly now!

I changed the directories in image_folder.py, and downgraded the version of visdom.

Thanks again ! :)

How do you change the directories in image_folder.py! Can you kindly explain with code? Also could you kindly guide me how to downgrade the visdom's version using pip!

You can change the data directories using dataroot. See this line. For pip usage, refer to this webpage.

AssertionError: ./datasets/dehazing\train is not a valid directory

Can you kindly help me to fix this error!

I think Windows has a different path format compared to Linux. Try something like .\datasets\dehazing\train.

Was this page helpful?
0 / 5 - 0 ratings