| 116 | |
| 117 | |
| 118 | def load_depth_model(): |
| 119 | # load depth model |
| 120 | with warnings.catch_warnings(): |
| 121 | warnings.simplefilter("ignore") |
| 122 | encoder = 'vitl' # can also be 'vitb' or 'vitl' |
| 123 | depth_model = DepthAnything.from_pretrained('LiheYoung/depth_anything_{:}14'.format(encoder)).cuda().eval() |
| 124 | dtransform = Compose([ |
| 125 | Resize( |
| 126 | width=518, |
| 127 | height=518, |
| 128 | resize_target=False, |
| 129 | keep_aspect_ratio=True, |
| 130 | ensure_multiple_of=14, |
| 131 | resize_method='lower_bound', |
| 132 | image_interpolation_method=cv2.INTER_CUBIC, |
| 133 | ), |
| 134 | NormalizeImage(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]), |
| 135 | PrepareForNet(), |
| 136 | ]) |
| 137 | return depth_model, dtransform |
| 138 | |
| 139 | # def invert_depth(depth_map): |
| 140 | # inv = depth_map.copy() |