mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-05 23:38:42 +08:00
fixed most linting errors
This commit is contained in:
1 parent
a7167f890e
commit
5691d00d42
14 files changed
+110
-45
No files matched your search
@@ -1,6 +1,12 @@
|
||||
"""
|
||||
The dataset baseclass.
|
||||
"""
|
||||
|
||||
from abc import abstractmethod
|
||||
import torch
|
||||
|
||||
from mattport.nerf.cameras import Camera
|
||||
|
||||
|
||||
class Dataset(torch.utils.data.Dataset):
|
||||
"""_summary_
|
||||
@@ -12,20 +18,51 @@ class Dataset(torch.utils.data.Dataset):
|
||||
def __init__(
|
||||
self,
|
||||
data_directory: str,
|
||||
) -> None:
|
||||
dataset_type: str,
|
||||
scene: str
|
||||
):
|
||||
"""_summary_
|
||||
|
||||
Args:
|
||||
data_directory (str): _description_
|
||||
type (str): _description_
|
||||
scene (str): _description_
|
||||
"""
|
||||
super().__init__()
|
||||
pass
|
||||
self.data_directory = data_directory
|
||||
self.dataset_type = dataset_type
|
||||
self.scene = scene
|
||||
|
||||
|
||||
def __len__(self):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_image(self, idx):
|
||||
pass
|
||||
"""_summary_
|
||||
|
||||
Args:
|
||||
idx (_type_): _description_
|
||||
|
||||
Raises:
|
||||
NotImplementedError: _description_
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def get_pose(self, idx):
|
||||
pass
|
||||
def get_camera(self, idx) -> Camera:
|
||||
"""_summary_
|
||||
|
||||
Args:
|
||||
idx (_type_): _description_
|
||||
|
||||
Raises:
|
||||
NotImplementedError: _description_
|
||||
|
||||
Returns:
|
||||
Camera: _description_
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def __getitem__(self, idx):
|
||||
raise NotImplementedError
|
||||
@@ -1,8 +1,12 @@
|
||||
from argon2 import DEFAULT_RANDOM_SALT_LENGTH
|
||||
from mattport.nerf.dataset.base import Dataset
|
||||
"""
|
||||
Builds the dataset
|
||||
"""
|
||||
import importlib
|
||||
import logging
|
||||
|
||||
from mattport.nerf.dataset.base import Dataset
|
||||
|
||||
|
||||
def build_dataset(config: dict) -> Dataset:
|
||||
"""Returns the dataset according to the specified config.
|
||||
# TODO(ethan): change the type from dict to be a dataclass
|
||||
@@ -11,7 +15,12 @@ def build_dataset(config: dict) -> Dataset:
|
||||
config (dict): _description_
|
||||
"""
|
||||
|
||||
# TODO(ethan): better handle this with configs
|
||||
module = importlib.import_module("mattport.nerf.dataset.base")
|
||||
dataset = module.Dataset(**config)
|
||||
dataset = module.Dataset(
|
||||
data_directory=config.data_directory,
|
||||
dataset_type=config.dataset_type,
|
||||
scene=config.scene,
|
||||
)
|
||||
logging.info(dataset)
|
||||
return dataset
|
||||
return dataset
|
||||
+16
-3
@@ -1,6 +1,17 @@
|
||||
"""
|
||||
The Graph module contains all trainable parameters.
|
||||
"""
|
||||
from dataclasses import dataclass
|
||||
from torch import nn
|
||||
|
||||
|
||||
@dataclass
|
||||
class GraphInputs:
|
||||
"""Datastucture to encode the inputs to the graph."""
|
||||
|
||||
points: float
|
||||
|
||||
|
||||
class Graph(nn.Module):
|
||||
"""_summary_
|
||||
|
||||
@@ -8,8 +19,10 @@ class Graph(nn.Module):
|
||||
nn (_type_): _description_
|
||||
"""
|
||||
|
||||
def __init__(self, config) -> None:
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self.config = config
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
def forward(self):
|
||||
"""_summary_"""
|
||||
raise NotImplementedError
|
||||
@@ -1,21 +1,26 @@
|
||||
"""
|
||||
Optimizer class.
|
||||
"""
|
||||
|
||||
from torch import optim
|
||||
|
||||
|
||||
class Optimizer:
|
||||
"""_summary_"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
params: dict,
|
||||
lr: float) -> None:
|
||||
def __init__(self, params: dict, lr: float):
|
||||
"""
|
||||
Args:
|
||||
params (dict): _description_
|
||||
lr (float): Learning rate.
|
||||
"""
|
||||
self.optimizer = optim.Adam(params)
|
||||
self.lr = lr
|
||||
|
||||
def test(self):
|
||||
raise NotImplementedError
|
||||
"""_summary_
|
||||
|
||||
|
||||
Raises:
|
||||
NotImplementedError: _description_
|
||||
"""
|
||||
raise NotImplementedError
|
||||
+16
-13
@@ -1,15 +1,20 @@
|
||||
from abc import abstractmethod
|
||||
import logging
|
||||
import torch
|
||||
|
||||
"""
|
||||
Code to train model.
|
||||
"""
|
||||
from mattport.nerf.dataset.build import build_dataset
|
||||
from mattport.nerf.optimizer import Optimizer
|
||||
from mattport.nerf.graph import Graph
|
||||
from mattport.nerf.dataset.build import build_dataset
|
||||
|
||||
|
||||
class Trainer(object):
|
||||
"""Training class"""
|
||||
|
||||
def __init__(self, config: dict):
|
||||
self.config = config
|
||||
self.train_dataset = None
|
||||
self.test_dataset = None
|
||||
self.graph = None
|
||||
self.optimizer = None
|
||||
|
||||
def setup_dataset(self):
|
||||
"""_summary_
|
||||
@@ -20,13 +25,11 @@ class Trainer(object):
|
||||
def setup_graph(self):
|
||||
"""_summary_
|
||||
"""
|
||||
self.graph = Graph(
|
||||
encodings_config=self.config.encodings,
|
||||
renderer_config=self.config.renderer,
|
||||
loss_config=self.config.loss
|
||||
)
|
||||
self.graph = Graph()
|
||||
|
||||
def setup_optimizer(self):
|
||||
"""_summary_
|
||||
"""
|
||||
self.optimizer = Optimizer(params=self.graph.parameters(), **self.config.optimizer)
|
||||
|
||||
def load_checkpoint(self):
|
||||
@@ -47,12 +50,12 @@ class Trainer(object):
|
||||
|
||||
def train(self):
|
||||
"""_summary_"""
|
||||
pass
|
||||
raise NotImplementedError
|
||||
|
||||
def train_epoch(self):
|
||||
"""_summary_"""
|
||||
pass
|
||||
raise NotImplementedError
|
||||
|
||||
def train_iteration(self):
|
||||
"""_summary_"""
|
||||
pass
|
||||
raise NotImplementedError
|
||||
Reference in new issue
Block a user