Skip to content

Commit

Permalink
Merge pull request #16 from DefTruth/dev
Browse files Browse the repository at this point in the history
feat(pypi): update torchlm to pypi v0.1.3 (#16)
  • Loading branch information
DefTruth authored Feb 18, 2022
2 parents 56c260d + 3a09f80 commit dccbcfe
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ debug.py
build
dist
torchlm.egg-info
*.sh
*.sh
./data
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@


def get_long_description():
description = (PATH_ROOT / "docs/README.md").read_text(encoding="utf-8")
description = (PATH_ROOT / "README.md").read_text(encoding="utf-8")
# replace relative repository path to absolute link to the release
static_url = f"https://github.com/DefTruth/torchlm/blob/main/"
description = description.replace("docs/res/", f"{static_url}/docs/res/")
return description

setuptools.setup(
name="torchlm",
version="0.1.2",
version="0.1.3",
author="DefTruth",
author_email="[email protected]",
description="A PyTorch landmarks-only library with 100+ data augmentations, "
Expand Down
2 changes: 1 addition & 1 deletion torchlm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Versions
__version__ = '0.1.2'
__version__ = '0.1.3'
# Transforms Module: 100+ transforms available, can bind torchvision and
# albumentations into torchlm pipeline with autodtype wrapper.
from .transfroms import *
Expand Down
Empty file added torchlm/data/_300w.py
Empty file.
Empty file added torchlm/data/_aflw.py
Empty file.
Empty file added torchlm/data/_cofw.py
Empty file.
Empty file added torchlm/data/_wflw.py
Empty file.
16 changes: 12 additions & 4 deletions torchlm/transfroms/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,7 @@ def __call__(
self.scale_y = scale_y

if len(new_landmarks) != num_landmarks:
self.flag = False
raise F.Error('LandmarksResize: {0} input landmarks, but got {1} output '
'landmarks'.format(num_landmarks, len(new_landmarks)))

Expand Down Expand Up @@ -957,6 +958,7 @@ def __call__(
self.scale_y = (1 / scale_factor_y)

if len(new_landmarks) != num_landmarks:
self.flag = False
raise F.Error('LandmarksAlign: {0} input landmarks, but got {1} output '
'landmarks'.format(num_landmarks, len(new_landmarks)))

Expand Down Expand Up @@ -1038,6 +1040,7 @@ def __call__(
self.scale_y = (1 / scale_factor_y)

if len(new_landmarks) != num_landmarks:
self.flag = False
raise F.Error('LandmarksAlign: {0} input landmarks, but got {1} output '
'landmarks'.format(num_landmarks, len(new_landmarks)))

Expand Down Expand Up @@ -1114,6 +1117,7 @@ def __call__(
ly_max = np.max(new_landmarks[:, 1])

if any((lx_min < 0., lx_max > crop_width, ly_min < 0., ly_max > crop_height)):
self.flag = False
return img.astype(np.uint8), landmarks

new_img = img[y1:y2, x1:x2, :].copy()
Expand Down Expand Up @@ -1255,6 +1259,7 @@ def __call__(
self.scale_y = resize_scale_y

if len(new_landmarks) != num_landmarks:
self.flag = False
raise F.Error('LandmarksRandomScale: {0} input landmarks, but got {1} output '
'landmarks'.format(num_landmarks, len(new_landmarks)))

Expand Down Expand Up @@ -1344,6 +1349,7 @@ def __call__(
img_h=new_img.shape[0])

if len(new_landmarks) != num_landmarks:
self.flag = False
raise F.Error('LandmarksRandomTranslate: {0} input landmarks, but got {1} '
'output landmarks'.format(num_landmarks, len(new_landmarks)))

Expand Down Expand Up @@ -1430,6 +1436,7 @@ def __call__(
self.scale_y = (1 / scale_factor_y)

if len(new_landmarks) != num_landmarks:
self.flag = False
raise F.Error(
'LandmarksRandomRotate: {0} input landmarks, but got {1} output '
'landmarks'.format(num_landmarks, len(new_landmarks))
Expand Down Expand Up @@ -1512,6 +1519,7 @@ def __call__(
self.scale_y = 1.

if len(new_landmarks) != num_landmarks:
self.flag = False
raise F.Error(
'LandmarksRandomShear: {0} input landmarks, but got {1} output '
'landmarks'.format(num_landmarks, len(new_landmarks))
Expand Down Expand Up @@ -1848,7 +1856,7 @@ def __call__(
patch = F.select_patch(patch_h=new_patch_h, patch_w=new_patch_w,
patches_paths=self._patches_paths)
if patch is None:
self.flag = True
self.flag = False
img.astype(np.uint8), landmarks.astype(np.float32)

new_img, patch_corner = F.apply_patch(img=img, patch=patch)
Expand Down Expand Up @@ -1911,7 +1919,7 @@ def __call__(
patch = F.select_patch(patch_h=new_patch_h, patch_w=new_patch_w,
patches_paths=self._patches_paths)
if patch is None:
self.flag = True
self.flag = False
img.astype(np.uint8), landmarks.astype(np.float32)

alpha = np.random.uniform(0.1, self._alpha)
Expand Down Expand Up @@ -1961,7 +1969,7 @@ def __call__(
)

if background is None:
self.flag = True
self.flag = False
return img.astype(np.uint8), landmarks.astype(np.float32)

new_img = F.apply_background_with_alpha(img=img, background=background, alpha=alpha)
Expand Down Expand Up @@ -2008,7 +2016,7 @@ def __call__(
)

if background is None:
self.flag = True
self.flag = False
return img.astype(np.uint8), landmarks.astype(np.float32)

new_img = F.apply_background(img=img, background=background)
Expand Down

0 comments on commit dccbcfe

Please sign in to comment.