junyanz / pytorch-CycleGAN-and-pix2pix

Image-to-Image Translation in PyTorch
Other
22.72k stars 6.28k forks source link

Help! - AsserstionError - not a valid directory / randrange() (0,0, 0) #376

Closed ArchitectTaeyoon closed 6 years ago

ArchitectTaeyoon commented 6 years ago

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!

junyanz commented 6 years ago

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.

ArchitectTaeyoon commented 6 years ago

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 :)

junyanz commented 6 years ago

Please look at the Q & A.

ArchitectTaeyoon commented 6 years ago

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

ArchitectTaeyoon commented 6 years ago

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..!

junyanz commented 6 years ago

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.

ArchitectTaeyoon commented 6 years ago

Okay thanks for looking into it 👍

Maybe I should try docker.

ArchitectTaeyoon commented 6 years ago

Got this to run in Windows properly now!

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

Thanks again ! :)

kumarballapavan commented 4 years ago

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!

junyanz commented 4 years ago

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

kumarballapavan commented 4 years ago

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

Can you kindly help me to fix this error!

junyanz commented 4 years ago

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

zhushuqi2333 commented 2 years ago

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

Can you kindly help me to fix this error!

I have the same question, have you ever solved this problem? can you kindly help me to fix this error? thank you!