forked from graphdeco-inria/gaussian-splatting
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
switched depth estimator for a faster implementation
- Loading branch information
Showing
4 changed files
with
112 additions
and
253 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import torch | ||
from transformers import pipeline | ||
|
||
from gaussian_splatting.dataset.image_dataset import ImageDataset | ||
from gaussian_splatting.utils.general import TorchToPIL | ||
|
||
|
||
class DepthEstimator: | ||
def __init__(self, model: str = "Intel/dpt-large"): | ||
self._model = pipeline("depth-estimation", model=model) | ||
|
||
def run(self, image): | ||
PIL_image = TorchToPIL(image) | ||
depth_estimation = self._model(PIL_image)["predicted_depth"] | ||
|
||
depth_estimation = torch.nn.functional.interpolate( | ||
depth_estimation.unsqueeze(1), | ||
size=PIL_image.size[::-1], | ||
mode="bicubic", | ||
align_corners=False, | ||
).squeeze() | ||
|
||
_min = depth_estimation.min() | ||
_max = depth_estimation.max() | ||
depth_estimation = (depth_estimation - _min) / (_max - _min) | ||
|
||
depth_estimation = -1 * (depth_estimation - 1) | ||
|
||
return depth_estimation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.