| 48 | return refined_rgbs |
| 49 | |
| 50 | def erode_alpha(img_list): |
| 51 | out_img_list = [] |
| 52 | for idx, img in enumerate(img_list): |
| 53 | arr = np.array(img) |
| 54 | alpha = (arr[:, :, 3] > 127).astype(np.uint8) |
| 55 | # erode 1px |
| 56 | import cv2 |
| 57 | alpha = cv2.erode(alpha, np.ones((3, 3), np.uint8), iterations=1) |
| 58 | alpha = (alpha * 255).astype(np.uint8) |
| 59 | img = Image.fromarray(np.concatenate([arr[:, :, :3], alpha[:, :, None]], axis=-1)) |
| 60 | out_img_list.append(img) |
| 61 | return out_img_list |
| 62 | import time |
| 63 | def geo_reconstruct(rgb_pils, normal_pils, front_pil, do_refine=False, predict_normal=True, expansion_weight=0.1, init_type="std"): |
| 64 | if front_pil.size[0] <= 512: |