"git@developer.sourcefind.cn:OpenDAS/dlib.git" did not exist on "af82bc402f10b611e4c21c6c444e7e5abd7f2877"
Commit d360a74e authored by Matteo Presutto's avatar Matteo Presutto Committed by Facebook GitHub Bot
Browse files

Bug fix - deadlock caused by Motion Blur in multiprocessing

Summary:
Pull Request resolved: https://github.com/facebookresearch/d2go/pull/395

Having a module as instance variable prevents multiprocessing from spawning a children using Pickle and creates a deadlock, making Motion Blur incompatible with multiprocessing

Reviewed By: wat3rBro

Differential Revision:
D40411481

LaMa Project: L1082110

fbshipit-source-id: b3e44b438367100044b948b5ea616c5c6fd41d3d
parent 69bf820c
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
from typing import Dict, List, Tuple from typing import Dict, List, Tuple
import detectron2.data.transforms.augmentation as aug import detectron2.data.transforms.augmentation as aug
import numpy as np import numpy as np
from detectron2.config import CfgNode from detectron2.config import CfgNode
from detectron2.data.transforms import NoOpTransform, Transform from detectron2.data.transforms import NoOpTransform, Transform
...@@ -122,14 +123,21 @@ class MotionBlurTransform(Transform): ...@@ -122,14 +123,21 @@ class MotionBlurTransform(Transform):
Args: Args:
will apply the specified blur to the image will apply the specified blur to the image
""" """
import imgaug.augmenters as iaa
super().__init__() super().__init__()
self._set_attributes(locals()) self._set_attributes(locals())
self.aug = iaa.MotionBlur(k, angle, direction, 1) self.k = k
self.angle = angle
self.direction = direction
def apply_image(self, img: np.ndarray) -> np.ndarray: def apply_image(self, img: np.ndarray) -> np.ndarray:
img = self.aug.augment_image(img) # Imported here and not in __init__to avoid linting errors
# also, imported here and not in the header section
# since the rest of the code does not have this dependency
import imgaug.augmenters as iaa
aug = iaa.MotionBlur(self.k, self.angle, self.direction, 1)
img = aug.augment_image(img)
return img return img
def apply_segmentation(self, segmentation: np.ndarray) -> np.ndarray: def apply_segmentation(self, segmentation: np.ndarray) -> np.ndarray:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment