Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem using pretrained data #1

Closed
BarDweller opened this issue Jan 22, 2019 · 3 comments
Closed

Problem using pretrained data #1

BarDweller opened this issue Jan 22, 2019 · 3 comments

Comments

@BarDweller
Copy link

Hi.. trying to use the pretrained here.

I've set up the environment with conda.

Then I clone the repo to e:\PhotoSketch
download and unpack the pretrained.zip to e:\PhotoSketch\pretrained
(this results in e:\PhotoSketch\pretrained\latest_net_(D|G).pth being created)
I run (a windows .bat conversion of the .sh) test_pretrained.bat

SET DATADIR=E:\PhotoSketch\pretrained

python test_only.py --name pretrained --dataset_mode test_dir --dataroot examples --results_dir %DATADIR%\Exp\PhotoSketch\Results\ --checkpoints_dir %DATADIR%\Exp\PhotoSketch\Checkpoints\ --model pix2pix --which_direction AtoB --norm batch --input_nc 3 --output_nc 1 --which_model_netG resnet_9blocks --no_dropout

Which results in an error saying the pretrained data couldn't be found (but looking in the wrong location).. E:\\PhotoSketch\\pretrained\\Exp\\PhotoSketch\\Checkpoints\\pretrained\\latest_net_G.pth

(sketch) E:\PhotoSketch>scripts\test_pretrained.bat

(sketch) E:\PhotoSketch>SET DATADIR=E:\PhotoSketch\pretrained

(sketch) E:\PhotoSketch>python test_only.py --name pretrained --dataset_mode test_dir --dataroot E:\pythondf\pythondf\python-3.6.3.amd64\PhotoSketch\examples --results_dir E:\PhotoSketch\pretrained\Exp\PhotoSketch\Results\ --checkpoints_dir E:\PhotoSketch\pretrained\Exp\PhotoSketch\Checkpoints\ --model pix2pix --which_direction AtoB --norm batch --input_nc 3 --output_nc 1 --which_model_netG resnet_9blocks --no_dropout
------------ Options -------------
aspect_ratio: 1.0
aug_folder: width-5
batchSize: 1
checkpoints_dir: E:\PhotoSketch\pretrained\Exp\PhotoSketch\Checkpoints\
color_jitter: False
crop: False
dataroot: E:\pythondf\pythondf\python-3.6.3.amd64\PhotoSketch\examples
dataset_mode: test_dir
display_id: 1
display_port: 8097
display_server: http://localhost
display_winsize: 256
file_name:
fineSize: 256
gpu_ids: [0]
how_many: 50
img_mean: None
img_std: None
init_type: normal
input_nc: 3
inverse_gamma: False
isTrain: False
jitter_amount: 0.02
loadSize: 286
lst_file: None
max_dataset_size: inf
model: pix2pix
nGT: 5
nThreads: 6
n_layers_D: 3
name: pretrained
ndf: 64
ngf: 64
no_dropout: True
no_flip: False
norm: batch
ntest: inf
output_nc: 1
phase: test
pretrain_path:
render_dir: sketch-rendered
resize_or_crop: resize_and_crop
results_dir: E:\PhotoSketch\pretrained\Exp\PhotoSketch\Results\
rot_int_max: 3
rotate: False
serial_batches: False
stroke_dir:
stroke_no_couple: False
suffix:
which_direction: AtoB
which_epoch: latest
which_model_netD: basic
which_model_netG: resnet_9blocks
-------------- End ----------------
CustomDatasetDataLoader
dataset [TestDirDataset] was created
pix2pix
initialization method [normal]
Traceback (most recent call last):
  File "test_only.py", line 17, in <module>
    model = create_model(opt)
  File "E:\PhotoSketch\models\models.py", line 10, in create_model
    model.initialize(opt)
  File "E:\PhotoSketch\models\pix2pix_model.py", line 30, in initialize
    self.load_network(self.netG, 'G', opt.which_epoch)
  File "E:\PhotoSketch\models\base_model.py", line 56, in load_network
    network.load_state_dict(torch.load(save_path))
  File "C:\Users\MyUserId\Miniconda3\envs\sketch\lib\site-packages\torch\serialization.py", line 265, in load
    f = open(f, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: 'E:\\PhotoSketch\\pretrained\\Exp\\PhotoSketch\\Checkpoints\\pretrained\\latest_net_G.pth'

If I copy both the the *.pth files to that location and relaunch, it produces a bit more output but eventually dies with..

model [Pix2PixModel] was created
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\MyUserId\Miniconda3\envs\sketch\lib\multiprocessing\spawn.py", line 105, in spawn_main
    exitcode = _main(fd)
  File "C:\Users\MyUserId\Miniconda3\envs\sketch\lib\multiprocessing\spawn.py", line 114, in _main
    prepare(preparation_data)
  File "C:\Users\MyUserId\Miniconda3\envs\sketch\lib\multiprocessing\spawn.py", line 225, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "C:\Users\MyUserId\Miniconda3\envs\sketch\lib\multiprocessing\spawn.py", line 277, in _fixup_main_from_path
    run_name="__mp_main__")
  File "C:\Users\MyUserId\Miniconda3\envs\sketch\lib\runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "C:\Users\MyUserId\Miniconda3\envs\sketch\lib\runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "C:\Users\MyUserId\Miniconda3\envs\sketch\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "E:\PhotoSketch\test_only.py", line 20, in <module>
    for i, data in enumerate(dataset):
  File "E:\PhotoSketch\data\custom_dataset_data_loader.py", line 41, in __iter__
    for i, data in enumerate(self.dataloader):
  File "C:\Users\MyUserId\Miniconda3\envs\sketch\lib\site-packages\torch\utils\data\dataloader.py", line 417, in __iter__
    return DataLoaderIter(self)
  File "C:\Users\MyUserId\Miniconda3\envs\sketch\lib\site-packages\torch\utils\data\dataloader.py", line 234, in __init__
    w.start()
  File "C:\Users\MyUserId\Miniconda3\envs\sketch\lib\multiprocessing\process.py", line 105, in start
    self._popen = self._Popen(self)
  File "C:\Users\MyUserId\Miniconda3\envs\sketch\lib\multiprocessing\context.py", line 223, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "C:\Users\MyUserId\Miniconda3\envs\sketch\lib\multiprocessing\context.py", line 322, in _Popen
    return Popen(process_obj)
  File "C:\Users\MyUserId\Miniconda3\envs\sketch\lib\multiprocessing\popen_spawn_win32.py", line 33, in __init__
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "C:\Users\MyUserId\Miniconda3\envs\sketch\lib\multiprocessing\spawn.py", line 143, in get_preparation_data
    _check_not_importing_main()
  File "C:\Users\MyUserId\Miniconda3\envs\sketch\lib\multiprocessing\spawn.py", line 136, in _check_not_importing_main
    is not going to be frozen to produce an executable.''')
RuntimeError:
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.
@BarDweller
Copy link
Author

Aha.. I suspect this may be the cause.. so I need to figure out where to add the fix =)

https://stackoverflow.com/questions/18204782/runtimeerror-on-windows-trying-python-multiprocessing

@mtli
Copy link
Owner

mtli commented Feb 2, 2019

Thanks for trying out the code! The pytorch 0.3 version isn't designed to work with Windows. I am working on a pytorch 0.4 version for our code, which should be cross-platform. Hopefully, it will be released soon.

@mtli
Copy link
Owner

mtli commented Feb 4, 2019

I just rolled out the support for pytorch 0.4.

@mtli mtli closed this as completed Feb 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants