donydchen / ganimation_replicate

An Out-of-the-Box Replication of GANimation using PyTorch, pretrained weights are available!
MIT License
251 stars 48 forks source link

AttributeError: Can't pickle local object 'BaseDataset.img_transformer.<locals>.<lambda>' #4

Open c1a1o1 opened 5 years ago

c1a1o1 commented 5 years ago

E:\Users\Raytine\Anaconda3\python.exe F:/pytorchgan/ganimation_replicate-master/main.py --mode test --data_root datasets/celebA --batch_size 8 --max_dataset_size 150 --gpu_ids 0 --ckpt_dir ckpts/celebA/ganimation/190327_161852/ --load_epoch 30 ------------------- [ test][190508_160507]Options -------------------- aus_nc: 17
aus_pkl: aus_openface.pkl
batch_size: 8 [default: 25] beta1: 0.5
ckpt_dir: ckpts/celebA/ganimation/190327_161852/ [default: ./ckpts] data_root: datasets/celebA [default: None] epoch_count: 1
final_size: 128
gan_type: wgan-gp
gpu_ids: [0] [default: 0] img_nc: 3
imgs_dir: imgs
init_gain: 0.02
init_type: normal
interpolate_len: 5
lambda_aus: 160.0
lambda_dis: 1.0
lambda_mask: 0
lambda_rec: 10.0
lambda_tv: 0
lambda_wgan_gp: 10.0
load_epoch: 30 [default: 0] load_size: 148
log_file: logs.txt
lr: 0.0001
lr_decay_iters: 50
lr_policy: lambda
lucky_seed: 1557302708 [default: 0] max_dataset_size: 150 [default: inf] mode: test [default: train] model: ganimation
n_threads: 6
name: 190508_160507
ndf: 64
ngf: 64
niter: 20
niter_decay: 10
no_aus_noise: False
no_flip: False
no_test_eval: False
norm: instance
opt_file: opt.txt
plot_losses_freq: 20000
print_losses_freq: 100
resize_or_crop: none
results: results\celebA_ganimation_30 [default: results] sample_img_freq: 2000
save_epoch_freq: 2
save_test_gif: False
serial_batches: False
test_csv: test_ids.csv
train_csv: train_ids.csv
train_gen_iter: 5
use_dropout: False
visdom_display_id: 0 [default: 1] visdom_env: main
visdom_port: 8097
--------------------- [ test][190508_160507]End ----------------------

initialize network with normal [Info] Successfully load trained weights for net_gen. Test with Model [GANimation] Set model to Test state. Set net_gen to EVAL. Traceback (most recent call last): File "F:/pytorchgan/ganimation_replicate-master/main.py", line 16, in solver.run_solver() File "F:\pytorchgan\ganimation_replicate-master\solvers.py", line 38, in run_solver self.test_networks(self.opt) File "F:\pytorchgan\ganimation_replicate-master\solvers.py", line 106, in test_networks self.test_ops() File "F:\pytorchgan\ganimation_replicate-master\solvers.py", line 113, in test_ops for batch_idx, batch in enumerate(self.test_dataset): File "F:\pytorchgan\ganimation_replicate-master\data\data_loader.py", line 46, in iter for i, data in enumerate(self.dataloader): File "E:\Users\Raytine\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 501, in iter return _DataLoaderIter(self) File "E:\Users\Raytine\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 289, in init w.start() File "E:\Users\Raytine\Anaconda3\lib\multiprocessing\process.py", line 105, in start self._popen = self._Popen(self) File "E:\Users\Raytine\Anaconda3\lib\multiprocessing\context.py", line 212, in _Popen return _default_context.get_context().Process._Popen(process_obj) File "E:\Users\Raytine\Anaconda3\lib\multiprocessing\context.py", line 313, in _Popen return Popen(process_obj) File "E:\Users\Raytine\Anaconda3\lib\multiprocessing\popen_spawn_win32.py", line 66, in init reduction.dump(process_obj, to_child) File "E:\Users\Raytine\Anaconda3\lib\multiprocessing\reduction.py", line 59, in dump ForkingPickler(file, protocol).dump(obj) AttributeError: Can't pickle local object 'BaseDataset.img_transformer..' Traceback (most recent call last): File "", line 1, in File "E:\Users\Raytine\Anaconda3\lib\multiprocessing\spawn.py", line 106, in spawn_main exitcode = _main(fd) File "E:\Users\Raytine\Anaconda3\lib\multiprocessing\spawn.py", line 116, in _main self = pickle.load(from_parent) EOFError: Ran out of input

Process finished with exit code 1

donydchen commented 5 years ago

Hi, @c1a1o1 , what is the version of your PyTorch? It looks like the error you posted is raised by the PyTorch framework, and the project is built and tested on PyTorch version 0.4.1.

c1a1o1 commented 5 years ago

I use PyTorch 0.4.1 and python3.5

c1a1o1 commented 5 years ago

My celebA images is here:

F:\pytorchgan\ganimation_replicate-master\datasets\celebA\imgs

donydchen commented 5 years ago

My celebA images is here:

F:\pytorchgan\ganimation_replicate-master\datasets\celebA\imgs

That is exactly the same relative path as I used. I look deeper into your error info, and I think it is caused by the python multiprocessing used by the PyTorch framework. Specifically, it is related to the compatibility problem. Multiprocessing in python sometimes does not work well on Windows. So I strongly suggest you to run this project on a Ubuntu or other Linux system.

donydchen commented 5 years ago

@c1a1o1 , similar case and discussion can be seen at https://discuss.pytorch.org/t/cant-pickle-local-object-dataloader-init-locals-lambda/31857

pytyeah commented 4 years ago

I met the same problem. Have you solved it?

Diuyon commented 4 years ago

me too.

sjtuplayer commented 3 years ago

It's the problem of threads, you can set n_threads=0 or run in ubuntu