-
Notifications
You must be signed in to change notification settings - Fork 532
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 'TrainAugmentation.__init__.<locals>.<lambda>' #71
Comments
can u fix it ?? i have the same issue |
I also have this quesion. |
i read a comment saying that this program need the Os to be Linux(It doesnt work on Window) |
add to command line option: --num_workers=0 |
I also have this quesion. |
Replacing the lambda function in TrainAugmentation with the following function worked for me: class ScaleByStd:
|
Full instructions based on @kueblert 's answer: In the file class ScaleByStd:
def __init__(self, std: float):
self.std = std
def __call__(self, img, boxes=None, labels=None):
return (img / self.std, boxes, labels) Next modify the definitions of the lambda img, boxes=None, labels=None: (img / std, boxes, labels), with ScaleByStd(std), The top of the file should look like this: from ..transforms.transforms import *
class ScaleByStd:
def __init__(self, std: float):
self.std = std
def __call__(self, img, boxes=None, labels=None):
return (img / self.std, boxes, labels)
class TrainAugmentation:
def __init__(self, size, mean=0, std=1.0):
"""
Args:
size: the size the of final image.
mean: mean pixel value per channel.
"""
self.mean = mean
self.size = size
self.augment = Compose([
ConvertFromInts(),
PhotometricDistort(),
Expand(self.mean),
RandomSampleCrop(),
RandomMirror(),
ToPercentCoords(),
Resize(self.size),
SubtractMeans(self.mean),
ScaleByStd(std),
ToTensor(),
])
def __call__(self, img, boxes, labels):
"""
Args:
img: the output of cv.imread in RGB layout.
boxes: boundding boxes in the form of (x1, y1, x2, y2).
labels: labels of boxes.
"""
return self.augment(img, boxes, labels)
class TestTransform:
def __init__(self, size, mean=0.0, std=1.0):
self.transform = Compose([
ToPercentCoords(),
Resize(size),
SubtractMeans(mean),
ScaleByStd(std),
ToTensor(),
])
def __call__(self, image, boxes, labels):
return self.transform(image, boxes, labels)
class PredictionTransform:
def __init__(self, size, mean=0.0, std=1.0):
self.transform = Compose([
Resize(size),
SubtractMeans(mean),
ScaleByStd(std),
ToTensor()
])
def __call__(self, image):
image, _, _ = self.transform(image)
return image |
It worked for me! ...you must specify data type=object when creating the ndarray... |
您好,您的邮件我已收到,我将尽快查看给予回复
|
@rsamvelyan Thanks. Any idea why your code change made the error go away? |
The following error occurred during training(python train_ssd.py)
AttributeError: Can't pickle local object 'TrainAugmentation.init..'
EOFError: Ran out of input
The text was updated successfully, but these errors were encountered: