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

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

Open
c1a1o1 opened this issue May 8, 2019 · 8 comments

Comments

@c1a1o1
Copy link

c1a1o1 commented May 8, 2019

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
Copy link
Owner

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
Copy link
Author

c1a1o1 commented May 9, 2019

I use PyTorch 0.4.1 and python3.5

@c1a1o1
Copy link
Author

c1a1o1 commented May 9, 2019

My celebA images is here:

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

@donydchen
Copy link
Owner

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
Copy link
Owner

@pytyeah
Copy link

pytyeah commented Dec 25, 2019

I met the same problem. Have you solved it?

@Diuyon
Copy link

Diuyon commented Jan 7, 2020

me too.

@sjtuplayer
Copy link

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

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

5 participants