mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-04 14:58:55 +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
Vendored
+1
@@ -11,6 +11,7 @@
|
|||||||
"--line-length=120"
|
"--line-length=120"
|
||||||
],
|
],
|
||||||
"python.linting.pylintEnabled": true,
|
"python.linting.pylintEnabled": true,
|
||||||
|
"python.linting.pylintArgs": [],
|
||||||
"python.linting.flake8Enabled": false,
|
"python.linting.flake8Enabled": false,
|
||||||
"python.linting.enabled": true,
|
"python.linting.enabled": true,
|
||||||
"python.testing.pytestArgs": [
|
"python.testing.pytestArgs": [
|
||||||
|
|||||||
+2
-5
@@ -1,7 +1,3 @@
|
|||||||
# defaults:
|
|
||||||
# - experiment: lego_bulldozer
|
|
||||||
# - dataset: blender
|
|
||||||
|
|
||||||
# OPTIONS FOR DIFFERENT NERF VARIANTS
|
# OPTIONS FOR DIFFERENT NERF VARIANTS
|
||||||
# ----
|
# ----
|
||||||
# sampler options
|
# sampler options
|
||||||
@@ -28,7 +24,8 @@ loss:
|
|||||||
|
|
||||||
# dataset options
|
# dataset options
|
||||||
dataset:
|
dataset:
|
||||||
dataset: blender # type of dataset
|
data_directory: /path/to/data
|
||||||
|
dataset_type: blender # type of dataset
|
||||||
scene: lego
|
scene: lego
|
||||||
num_workers: 4
|
num_workers: 4
|
||||||
|
|
||||||
|
|||||||
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
@@ -1,2 +0,0 @@
|
|||||||
name: lego_bulldozer
|
|
||||||
feature_size: 5
|
|
||||||
Whitespace-only changes.
Whitespace-only changes.
@@ -1,6 +1,12 @@
|
|||||||
|
"""
|
||||||
|
The dataset baseclass.
|
||||||
|
"""
|
||||||
|
|
||||||
from abc import abstractmethod
|
from abc import abstractmethod
|
||||||
import torch
|
import torch
|
||||||
|
|
||||||
|
from mattport.nerf.cameras import Camera
|
||||||
|
|
||||||
|
|
||||||
class Dataset(torch.utils.data.Dataset):
|
class Dataset(torch.utils.data.Dataset):
|
||||||
"""_summary_
|
"""_summary_
|
||||||
@@ -12,20 +18,51 @@ class Dataset(torch.utils.data.Dataset):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
data_directory: str,
|
data_directory: str,
|
||||||
) -> None:
|
dataset_type: str,
|
||||||
|
scene: str
|
||||||
|
):
|
||||||
|
"""_summary_
|
||||||
|
|
||||||
|
Args:
|
||||||
|
data_directory (str): _description_
|
||||||
|
type (str): _description_
|
||||||
|
scene (str): _description_
|
||||||
|
"""
|
||||||
super().__init__()
|
super().__init__()
|
||||||
pass
|
self.data_directory = data_directory
|
||||||
|
self.dataset_type = dataset_type
|
||||||
|
self.scene = scene
|
||||||
|
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def get_image(self, idx):
|
def get_image(self, idx):
|
||||||
pass
|
"""_summary_
|
||||||
|
|
||||||
|
Args:
|
||||||
|
idx (_type_): _description_
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
NotImplementedError: _description_
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def get_pose(self, idx):
|
def get_camera(self, idx) -> Camera:
|
||||||
pass
|
"""_summary_
|
||||||
|
|
||||||
|
Args:
|
||||||
|
idx (_type_): _description_
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
NotImplementedError: _description_
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Camera: _description_
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
def __getitem__(self, idx):
|
def __getitem__(self, idx):
|
||||||
raise NotImplementedError
|
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 importlib
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from mattport.nerf.dataset.base import Dataset
|
||||||
|
|
||||||
|
|
||||||
def build_dataset(config: dict) -> Dataset:
|
def build_dataset(config: dict) -> Dataset:
|
||||||
"""Returns the dataset according to the specified config.
|
"""Returns the dataset according to the specified config.
|
||||||
# TODO(ethan): change the type from dict to be a dataclass
|
# TODO(ethan): change the type from dict to be a dataclass
|
||||||
@@ -11,7 +15,12 @@ def build_dataset(config: dict) -> Dataset:
|
|||||||
config (dict): _description_
|
config (dict): _description_
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# TODO(ethan): better handle this with configs
|
||||||
module = importlib.import_module("mattport.nerf.dataset.base")
|
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)
|
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
|
from torch import nn
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class GraphInputs:
|
||||||
|
"""Datastucture to encode the inputs to the graph."""
|
||||||
|
|
||||||
|
points: float
|
||||||
|
|
||||||
|
|
||||||
class Graph(nn.Module):
|
class Graph(nn.Module):
|
||||||
"""_summary_
|
"""_summary_
|
||||||
|
|
||||||
@@ -8,8 +19,10 @@ class Graph(nn.Module):
|
|||||||
nn (_type_): _description_
|
nn (_type_): _description_
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, config) -> None:
|
def __init__(self) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.config = config
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def forward(self):
|
||||||
|
"""_summary_"""
|
||||||
|
raise NotImplementedError
|
||||||
@@ -1,21 +1,26 @@
|
|||||||
|
"""
|
||||||
|
Optimizer class.
|
||||||
|
"""
|
||||||
|
|
||||||
from torch import optim
|
from torch import optim
|
||||||
|
|
||||||
|
|
||||||
class Optimizer:
|
class Optimizer:
|
||||||
"""_summary_"""
|
"""_summary_"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(self, params: dict, lr: float):
|
||||||
self,
|
|
||||||
params: dict,
|
|
||||||
lr: float) -> None:
|
|
||||||
"""
|
"""
|
||||||
Args:
|
Args:
|
||||||
params (dict): _description_
|
params (dict): _description_
|
||||||
lr (float): Learning rate.
|
lr (float): Learning rate.
|
||||||
"""
|
"""
|
||||||
self.optimizer = optim.Adam(params)
|
self.optimizer = optim.Adam(params)
|
||||||
|
self.lr = lr
|
||||||
|
|
||||||
def test(self):
|
def test(self):
|
||||||
raise NotImplementedError
|
"""_summary_
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
NotImplementedError: _description_
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
||||||
+16
-13
@@ -1,15 +1,20 @@
|
|||||||
from abc import abstractmethod
|
"""
|
||||||
import logging
|
Code to train model.
|
||||||
import torch
|
"""
|
||||||
|
from mattport.nerf.dataset.build import build_dataset
|
||||||
from mattport.nerf.optimizer import Optimizer
|
from mattport.nerf.optimizer import Optimizer
|
||||||
from mattport.nerf.graph import Graph
|
from mattport.nerf.graph import Graph
|
||||||
from mattport.nerf.dataset.build import build_dataset
|
|
||||||
|
|
||||||
|
|
||||||
class Trainer(object):
|
class Trainer(object):
|
||||||
|
"""Training class"""
|
||||||
|
|
||||||
def __init__(self, config: dict):
|
def __init__(self, config: dict):
|
||||||
self.config = config
|
self.config = config
|
||||||
|
self.train_dataset = None
|
||||||
|
self.test_dataset = None
|
||||||
|
self.graph = None
|
||||||
|
self.optimizer = None
|
||||||
|
|
||||||
def setup_dataset(self):
|
def setup_dataset(self):
|
||||||
"""_summary_
|
"""_summary_
|
||||||
@@ -20,13 +25,11 @@ class Trainer(object):
|
|||||||
def setup_graph(self):
|
def setup_graph(self):
|
||||||
"""_summary_
|
"""_summary_
|
||||||
"""
|
"""
|
||||||
self.graph = Graph(
|
self.graph = Graph()
|
||||||
encodings_config=self.config.encodings,
|
|
||||||
renderer_config=self.config.renderer,
|
|
||||||
loss_config=self.config.loss
|
|
||||||
)
|
|
||||||
|
|
||||||
def setup_optimizer(self):
|
def setup_optimizer(self):
|
||||||
|
"""_summary_
|
||||||
|
"""
|
||||||
self.optimizer = Optimizer(params=self.graph.parameters(), **self.config.optimizer)
|
self.optimizer = Optimizer(params=self.graph.parameters(), **self.config.optimizer)
|
||||||
|
|
||||||
def load_checkpoint(self):
|
def load_checkpoint(self):
|
||||||
@@ -47,12 +50,12 @@ class Trainer(object):
|
|||||||
|
|
||||||
def train(self):
|
def train(self):
|
||||||
"""_summary_"""
|
"""_summary_"""
|
||||||
pass
|
raise NotImplementedError
|
||||||
|
|
||||||
def train_epoch(self):
|
def train_epoch(self):
|
||||||
"""_summary_"""
|
"""_summary_"""
|
||||||
pass
|
raise NotImplementedError
|
||||||
|
|
||||||
def train_iteration(self):
|
def train_iteration(self):
|
||||||
"""_summary_"""
|
"""_summary_"""
|
||||||
pass
|
raise NotImplementedError
|
||||||
@@ -1,21 +1,23 @@
|
|||||||
import os
|
"""
|
||||||
from typing import Dict
|
run_train_nerf.py
|
||||||
from mattport.nerf.trainer import Trainer
|
"""
|
||||||
import logging
|
import logging
|
||||||
import hydra
|
import hydra
|
||||||
from omegaconf import DictConfig
|
from omegaconf import DictConfig
|
||||||
|
|
||||||
|
from mattport.nerf.trainer import Trainer
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(format="[%(filename)s:%(lineno)d] %(message)s", level=logging.DEBUG)
|
logging.basicConfig(format="[%(filename)s:%(lineno)d] %(message)s", level=logging.DEBUG)
|
||||||
|
|
||||||
|
|
||||||
@hydra.main(config_path="../configs", config_name="config.yaml")
|
@hydra.main(config_path="../configs", config_name="config.yaml")
|
||||||
def main(config: DictConfig):
|
def main(config: DictConfig):
|
||||||
|
"""Main function."""
|
||||||
trainer = Trainer(config)
|
trainer = Trainer(config)
|
||||||
print("trainer!")
|
|
||||||
|
|
||||||
trainer.setup_dataset()
|
trainer.setup_dataset()
|
||||||
# trainer.setup_graph()
|
trainer.setup_graph()
|
||||||
# trainer.setup_optimizer()
|
trainer.setup_optimizer()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in new issue
Block a user