fixed normalization, can overfit on single image

This commit is contained in:
2023-01-24 22:45:14 +00:00
parent a0f3e95255
commit d062c2068d
6 changed files with 147 additions and 72 deletions
+14 -1
View File
@@ -6,7 +6,7 @@ import numpy as np
import scipy.io as sio
from math import cos, sin
from pytorch3d.utils import cameras_from_opencv_projection
import torchvision as tv
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..')
# from superSMPL.IO import readPC2Frame, readOBJ
@@ -58,6 +58,19 @@ def get_normals_from_depth(depth_image, depth_mask, camera_intrinsic):
return normals
def resize_image(img, mask_croped, mask_resized, size):
resizer = tv.transforms.Resize(size, interpolation=tv.transforms.functional.InterpolationMode.BILINEAR)
dilated = kornia.morphology.dilation(img, torch.ones((3,3), device=img.get_device()), engine='convolution')
dilated = kornia.morphology.dilation(dilated, torch.ones((3,3), device=img.get_device()), engine='convolution')
dilated = torch.permute(dilated, [0,2,3,1])
img = torch.permute(img, [0,2,3,1])
dilated[mask_croped, :] = img[mask_croped, :]
dilated = torch.permute(dilated, [0,3,1,2])
out = resizer(dilated)
out = out * mask_resized[:,None,:,:]
return out
def center_crop_resize(img, new_center, size):
pass