-
Notifications
You must be signed in to change notification settings - Fork 221
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
Can't pickle local object #5
Comments
Did you modify the code? I have run the original code, too. There are no problems. |
No, I just run the original code. can you tell me your environment? |
Ubuntu 14.04 64-bit |
I met the same problem too? not so sure why |
Yes, I encountered the same error. Did you fix it?@billhhh |
Not yet, @CocaKoala7 |
Hi, did anybody solve the "can't pickle local objects" issue? Thanks in advance. |
@omrfrkmfy This is the right issue. It seems the issue is the pickler. I think multiprocessing has to pickle the dataset to use across processes. The pickle module, unlike a better pickler like dill, can't pickle lambda functions, # somewhere outside the "main" function
def crops_to_tensors(crops):
to_tensor = transforms.ToTensor()
return torch.stack([to_tensor(crop) for crop in crops])
def normalize_crops(crops):
normalize = transforms.Normalize([0.485, 0.456, 0.406],
[0.229, 0.224, 0.225])
return torch.stack([normalize(crop)for crop in crops])
# in the "main" function
test_dataset = ChestXrayDataSet(data_dir=DATA_DIR,
image_list_file=TEST_IMAGE_LIST,
transform=transforms.Compose([
transforms.Resize(256),
transforms.TenCrop(224),
transforms.Lambda(crops_to_tensors),
transforms.Lambda(normalize_crops),
])) |
Yes it worked. But sorry for the disturbance; |
Have you solved this problem? Can you share your ideas? |
Did you get a chance to rectify this issue? |
Hi,
Thank you for your sharing.
When I run the code, There is an error occurred in this line "for i, (inp, target) in enumerate(test_loader)" ,
Somebody tell me that "python can't pickle functions. ", can you point me the right way to fix it?
I run the code on win7 python 3.6 pytorch 0.1.12.
Than you~
The text was updated successfully, but these errors were encountered: