mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-20 22:56:03 +08:00
Switch to ruff (#1939)
* `isort` -> `ruff` * `pylint` -> `ruff` * Remove line * More minor cleanup * Better documentation for rules we are enabling * Fix gitignore, run black * vscode settings --------- Co-authored-by: Matt Tancik <mattt4001@gmail.com>
This commit is contained in:
1 parent
814db32ec4
commit
d542646c72
79 files changed
+158
-237
No files matched your search
@@ -89,8 +89,8 @@ class Model(nn.Module):
|
||||
"""Returns the device that the model is on."""
|
||||
return self.device_indicator_param.device
|
||||
|
||||
def get_training_callbacks( # pylint:disable=no-self-use
|
||||
self, training_callback_attributes: TrainingCallbackAttributes # pylint: disable=unused-argument
|
||||
def get_training_callbacks(
|
||||
self, training_callback_attributes: TrainingCallbackAttributes
|
||||
) -> List[TrainingCallback]:
|
||||
"""Returns a list of callbacks that run functions at the specified training iterations."""
|
||||
return []
|
||||
@@ -146,8 +146,7 @@ class Model(nn.Module):
|
||||
outputs: the output to compute loss dict to
|
||||
batch: ground truth batch corresponding to outputs
|
||||
"""
|
||||
# pylint: disable=unused-argument
|
||||
# pylint: disable=no-self-use
|
||||
|
||||
return {}
|
||||
|
||||
@abstractmethod
|
||||
|
||||
@@ -129,7 +129,7 @@ class DepthNerfactoModel(NerfactoModel):
|
||||
if not self.config.should_decay_sigma:
|
||||
return self.depth_sigma
|
||||
|
||||
self.depth_sigma = torch.maximum( # pylint: disable=attribute-defined-outside-init
|
||||
self.depth_sigma = torch.maximum(
|
||||
self.config.sigma_decay_rate * self.depth_sigma, torch.tensor([self.config.depth_sigma])
|
||||
)
|
||||
return self.depth_sigma
|
||||
@@ -249,12 +249,12 @@ class NerfplayerNerfactoModel(NerfactoModel):
|
||||
mask = (batch["depth_image"] != 0).view([-1])
|
||||
loss_dict["depth_loss"] = 0
|
||||
|
||||
def l(x):
|
||||
def compute_depth_loss(x):
|
||||
return self.config.depth_weight * (x - batch["depth_image"][mask]).pow(2).mean()
|
||||
|
||||
loss_dict["depth_loss"] = l(outputs["depth"][mask])
|
||||
loss_dict["depth_loss"] = compute_depth_loss(outputs["depth"][mask])
|
||||
for i in range(self.config.num_proposal_iterations):
|
||||
loss_dict["depth_loss"] += l(outputs[f"prop_depth_{i}"][mask])
|
||||
loss_dict["depth_loss"] += compute_depth_loss(outputs[f"prop_depth_{i}"][mask])
|
||||
if self.config.temporal_tv_weight > 0:
|
||||
loss_dict["temporal_tv_loss"] = self.field.mlp_base.get_temporal_tv_loss()
|
||||
for net in self.proposal_networks:
|
||||
|
||||
@@ -129,9 +129,7 @@ class TensoRFModel(Model):
|
||||
self, training_callback_attributes: TrainingCallbackAttributes
|
||||
) -> List[TrainingCallback]:
|
||||
# the callback that we want to run every X iterations after the training iteration
|
||||
def reinitialize_optimizer(
|
||||
self, training_callback_attributes: TrainingCallbackAttributes, step: int # pylint: disable=unused-argument
|
||||
):
|
||||
def reinitialize_optimizer(self, training_callback_attributes: TrainingCallbackAttributes, step: int):
|
||||
index = self.upsampling_iters.index(step)
|
||||
resolution = self.upsampling_steps[index]
|
||||
|
||||
|
||||
Reference in new issue
Block a user