Closed John1231983 closed 2 years ago
HorizontalFlip with points_flip parameter is not fully support now, in my todo list.
for now, you might need to let points_flip as constant list or indices array within your custom function and use torchlm.bind to bind it togather into the transform pipeline
# First, defined your custom functions
def callable_array_noop(img: np.ndarray, landmarks: np.ndarray) -> Tuple[np.ndarray, np.ndarray]:
# do some transform here
points_flips = [] # or array ...
return img.astype(np.uint32), landmarks.astype(np.float32)
# Then, bind your functions and put it into the transforms pipeline.
transform = torchlm.LandmarksCompose([
torchlm.bind(callable_array_noop, bind_type=torchlm.BindEnum.Callable_Array),
])
See data-augmentation for more details.
Is possible to use Albumentations?
sure, torchlm have add a soft-support for Albumentations, data-augmentation will show you the details of how to bind transforms from Albumentations.
NOTE: Please install albumentations first if you want to bind albumentations's transforms. If you have the conflict problem between different installed version of opencv (opencv-python and opencv-python-headless, ablumentations
need opencv-python-headless). Please uninstall the opencv-python and opencv-python-headless first, and then reinstall albumentations. See albumentations#1140 for more details.
# first uninstall conflict opencvs
pip uninstall opencv-python
pip uninstall opencv-python-headless
pip uninstall albumentations # if you have installed albumentations
pip install albumentations # then reinstall albumentations, will also install deps, e.g opencv
Then, check if albumentations is available.
torchlm.albumentations_is_available() # True or False
transform = torchlm.LandmarksCompose([
torchlm.bind(torchvision.transforms.GaussianBlur(kernel_size=(5, 25)), prob=0.5),
torchlm.bind(albumentations.ColorJitter(p=0.5))
])
Great project and thanks for sharing it! For Horizontal flip, the pipnet has aug point flip such as
How do you implement the above function with Albumentations? I found HorizontalFlip but it has no points_flip aug