mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-25 18:39:55 +08:00
torchtyping => jaxtyping (#1838)
* Run `ruff --fix` * Add jaxtyping migration script * Run migration scripts + ruff + black * Merge remote-tracking branch 'origin/main' into brent/jaxtyping * black * Fix lint * fix lint * Cleanup and more specific types * Fixed annotation errors * Fix more errors * Fix annotation * Delete _torchtyping_to_jaxtyping.py --------- Co-authored-by: Matt Tancik <mattt4001@gmail.com>
This commit is contained in:
1 parent
9b6290ea43
commit
6ba2a18b2b
65 files changed
+597
-531
No files matched your search
@@ -20,7 +20,8 @@ import random
|
||||
from typing import Dict, Optional, Union
|
||||
|
||||
import torch
|
||||
from torchtyping import TensorType
|
||||
from jaxtyping import Int
|
||||
from torch import Tensor
|
||||
|
||||
|
||||
class PixelSampler: # pylint: disable=too-few-public-methods
|
||||
@@ -50,9 +51,9 @@ class PixelSampler: # pylint: disable=too-few-public-methods
|
||||
num_images: int,
|
||||
image_height: int,
|
||||
image_width: int,
|
||||
mask: Optional[TensorType] = None,
|
||||
mask: Optional[Tensor] = None,
|
||||
device: Union[torch.device, str] = "cpu",
|
||||
) -> TensorType["batch_size", 3]:
|
||||
) -> Int[Tensor, "batch_size 3"]:
|
||||
"""
|
||||
Naive pixel sampler, uniformly samples across all possible pixels of all possible images.
|
||||
|
||||
@@ -218,9 +219,9 @@ class EquirectangularPixelSampler(PixelSampler): # pylint: disable=too-few-publ
|
||||
num_images: int,
|
||||
image_height: int,
|
||||
image_width: int,
|
||||
mask: Optional[TensorType] = None,
|
||||
mask: Optional[Tensor] = None,
|
||||
device: Union[torch.device, str] = "cpu",
|
||||
) -> TensorType["batch_size", 3]:
|
||||
) -> Int[Tensor, "batch_size 3"]:
|
||||
if isinstance(mask, torch.Tensor):
|
||||
# Note: if there is a mask, sampling reduces back to uniform sampling, which gives more
|
||||
# sampling weight to the poles of the image than the equators.
|
||||
@@ -274,9 +275,9 @@ class PatchPixelSampler(PixelSampler): # pylint: disable=too-few-public-methods
|
||||
num_images: int,
|
||||
image_height: int,
|
||||
image_width: int,
|
||||
mask: Optional[TensorType] = None,
|
||||
mask: Optional[Tensor] = None,
|
||||
device: Union[torch.device, str] = "cpu",
|
||||
) -> TensorType["batch_size", 3]:
|
||||
) -> Int[Tensor, "batch_size 3"]:
|
||||
if mask:
|
||||
# Note: if there is a mask, sampling reduces back to uniform sampling
|
||||
indices = super().sample_method(batch_size, num_images, image_height, image_width, mask=mask, device=device)
|
||||
|
||||
Reference in new issue
Block a user