Download pi4/postprocess.py from yyfz233/Pi4: direct link, hf CLI and curl.
- Browser
- Download file 441 Bytes
-
https://huggingface.co/spaces/yyfz233/Pi4/resolve/main/pi4/postprocess.py
- Command line
-
hf download hf://spaces/yyfz233/Pi4/pi4/postprocess.py
-
curl -L -o postprocess.py https://huggingface.co/spaces/yyfz233/Pi4/resolve/main/pi4/postprocess.py
441 Bytes
| import torch | |
| from .geometry import depth_normal_edge | |
| def geometry_confidence(points, confidence): | |
| """Copy geometry confidence, zeroing invalid pixels and depth-normal edges.""" | |
| valid = ( | |
| torch.isfinite(points).all(dim=-1) | |
| & (points[..., 2] > 0) | |
| & torch.isfinite(confidence) | |
| & (confidence >= 0) | |
| ) | |
| edges = depth_normal_edge(points, valid) | |
| return confidence.masked_fill(~valid | edges, 0) | |