mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-13 03:14:00 +08:00
refactored dataset names + multi-gpu running (#321)
* refactored dataset names + multi-gpu running * update comments + docs
This commit is contained in:
1 parent
bb2a528eb4
commit
b0f6d75cdf
16 files changed
+310
-304
No files matched your search
@@ -10,15 +10,15 @@
|
||||
"\n",
|
||||
"> Our goal is to enable Nerfactory users to implement an entire NeRF method by only editing one file.\n",
|
||||
"\n",
|
||||
"Here we explain how to create custom pipelines with nerfactory. Pipelines are composed of two components, namely a Dataloader and a Model. The pipeline is responsible for routing RayBundle instances returned from the Dataloader into the Model.\n",
|
||||
"Here we explain how to create custom pipelines with nerfactory. Pipelines are composed of two components, namely a DataManager and a Model. The pipeline is responsible for routing RayBundle instances returned from the DataManager into the Model.\n",
|
||||
"\n",
|
||||
"A NeRF method is implemented as a Pipeline. Users can create a Pipeline with a Dataloader and Model. We provide default implementations for these components prefixed with the name Vanilla (e.g., `VanillaPipeline`, `VanillaDataloader` which inherit from the `Pipeline` and `Dataloader` class, respectively) and specific Models (e.g., `InstantNGPModel` or `TensoRFModel` which inherit from the `Model` class). With most NeRF methods, `VanillaPipeline` and `VanillaDataloader` can be used and only the model needs to be changed. We provide many already implmented Models for people to get started with 3D reconstruction. However, in this tutorial we will demonstrate how to customize each of the Pipeline, Dataloader, and Model with an example.\n",
|
||||
"A NeRF method is implemented as a Pipeline. Users can create a Pipeline with a DataManager and Model. We provide default implementations for these components prefixed with the name Vanilla (e.g., `VanillaPipeline`, `VanillaDataManager` which inherit from the `Pipeline` and `DataManager` class, respectively) and specific Models (e.g., `InstantNGPModel` or `TensoRFModel` which inherit from the `Model` class). With most NeRF methods, `VanillaPipeline` and `VanillaDataManager` can be used and only the model needs to be changed. We provide many already implmented Models for people to get started with 3D reconstruction. However, in this tutorial we will demonstrate how to customize each of the Pipeline, DataManager, and Model with an example.\n",
|
||||
"\n",
|
||||
"We'll show how to make an incremental dataloader where we progressively add cameras to train with from multiple scenes and importance sample rays from pixels with a high loss. The extensible features that we show in this tutorial are the following:\n",
|
||||
"- a Dataloader that incrementally adds cameras\n",
|
||||
"- a Dataloader that uses multiple scenes\n",
|
||||
"We'll show how to make an incremental DataManager where we progressively add cameras to train with from multiple scenes and importance sample rays from pixels with a high loss. The extensible features that we show in this tutorial are the following:\n",
|
||||
"- a DataManager that incrementally adds cameras\n",
|
||||
"- a DataManager that uses multiple scenes\n",
|
||||
"- a Model that is conditioned on the scene\n",
|
||||
"- a Pipeline that modifies the Dataloader's PixelSampler to sample more rays in regions with high loss"
|
||||
"- a Pipeline that modifies the DataManager's PixelSampler to sample more rays in regions with high loss"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -62,34 +62,29 @@
|
||||
"<li>Spatial Distortions</li>\n",
|
||||
"</details>\n",
|
||||
"\n",
|
||||
"#### Dataloader Components\n",
|
||||
"#### DataManager Components\n",
|
||||
"\n",
|
||||
"> The Dataloader provides a RayBundle (3D line segments with metadata needed to run the forward pass) and a dictionary of information needed at train-time to supervise the pipeline components.\n",
|
||||
"> The DataManager provides a RayBundle (3D line segments with metadata needed to run the forward pass) and a dictionary of information needed at train-time to supervise the pipeline components.\n",
|
||||
"\n",
|
||||
"Similar to the Model components, we provide Dataloader components that are strung together to generate RayBundle instances. A RayBundle contains everything needed to generate a ray (e.g., origin and direction, near and far planes) as well as any additional metadata that the Model requires (e.g., camera index, scene index, etc.).\n",
|
||||
"Similar to the Model components, we provide DataManager components that are strung together to generate RayBundle instances. A RayBundle contains everything needed to generate a ray (e.g., origin and direction, near and far planes) as well as any additional metadata that the Model requires (e.g., camera index, scene index, etc.).\n",
|
||||
"\n",
|
||||
"<details closed>\n",
|
||||
"<summary>Dataloader Components</summary>\n",
|
||||
"<summary>DataManager Components</summary>\n",
|
||||
"<br>\n",
|
||||
"Scene Datasets:<br>\n",
|
||||
"Datasets Parsers:<br>\n",
|
||||
" <em style=\"padding-left:2em\">Takes a data location and returns a DatasetInputs instance. A DatasetInputs will contain all data needed throughout the pipeline.</em>\n",
|
||||
"<li>Vanilla Image Dataset</li>\n",
|
||||
"<li>Panoptic Image Dataset</li>\n",
|
||||
"<li>Vanilla Image DataParser</li>\n",
|
||||
"<li>Panoptic Image DataParser</li>\n",
|
||||
"<br>\n",
|
||||
"Image Datasets:<br>\n",
|
||||
" <em style=\"padding-left:2em\">Takes image filename information and can return images.</em>\n",
|
||||
"<li>Vanilla Image Dataset</li>\n",
|
||||
"<li>Panoptic Image Dataset</li>\n",
|
||||
"<br>\n",
|
||||
"Image Samplers:<br>\n",
|
||||
"Image Dataloader:<br>\n",
|
||||
" <em style=\"padding-left:2em\">Takes an Image Dataset and samples images from it.</em>\n",
|
||||
"<li>Vanilla Image Sampler</li>\n",
|
||||
"<li>Cache Image Sampler</li>\n",
|
||||
"<br>\n",
|
||||
"Pixel Samplers:<br>\n",
|
||||
" <em style=\"padding-left:2em\">Takes sampled images and returns pixel locations.</em>\n",
|
||||
"<li>Vanilla Image Sampler</li>\n",
|
||||
"<li>Cache Image Sampler</li>\n",
|
||||
"<li>Vanilla Image Dataloader</li>\n",
|
||||
"<li>Cache Image Dataloader</li>\n",
|
||||
"<br>\n",
|
||||
"Pixel Samplers:<br>\n",
|
||||
" <em style=\"padding-left:2em\">Takes sampled images and returns pixel locations.</em>\n",
|
||||
@@ -123,8 +118,8 @@
|
||||
"from typing import Dict, Optional, Tuple, List\n",
|
||||
"import torch\n",
|
||||
"\n",
|
||||
"from nerfactory.utils.config import DataloaderConfig, ModelConfig, PipelineConfig, ViewerConfig\n",
|
||||
"from nerfactory.dataloaders.base import Dataloader\n",
|
||||
"from nerfactory.utils.config import DataManagerConfig, ModelConfig, PipelineConfig, ViewerConfig\n",
|
||||
"from nerfactory.dataloaders.base import DataManager\n",
|
||||
"from nerfactory.dataloaders.structs import DatasetInputs\n",
|
||||
"from nerfactory.models.base import Model\n",
|
||||
"from nerfactory.pipelines.base import Pipeline\n",
|
||||
@@ -140,17 +135,17 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class CustomDataloaderConfig(DataloaderConfig):\n",
|
||||
" _target = \"CustomDataloader\"\n",
|
||||
"class CustomDataManagerConfig(DataManagerConfig):\n",
|
||||
" _target = \"CustomDataManager\"\n",
|
||||
" scene_names: List[str] = [\"chair\", \"drums\", \"fern\", \"lego\"]\n",
|
||||
" steps_per_add_cameras: int = 100 # every X iterations, add more cameras\n",
|
||||
" num_cameras_per_add: int = 10 # number of cameras to add\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class CustomDataloader(Dataloader):\n",
|
||||
"class CustomDataManager(DataManager):\n",
|
||||
" \"\"\"A custom dataloader that incrementally adds cameras and has multiple scenes.\"\"\"\n",
|
||||
"\n",
|
||||
" config: CustomDataloaderConfig\n",
|
||||
" config: CustomDataManagerConfig\n",
|
||||
"\n",
|
||||
" def populate_train_modules(self):\n",
|
||||
" \"\"\"Populate the train dataloader modules.\"\"\"\n",
|
||||
@@ -159,7 +154,7 @@
|
||||
" for scene_name in self.config.scene_names:\n",
|
||||
" dataset_inputs: DatasetInputs = None # TODO\n",
|
||||
" image_dataset = ImageDataset(dataset_inputs)\n",
|
||||
" image_sampler = CacheImageSampler(image_dataset=image_dataset) # a torch dataloader\n",
|
||||
" image_sampler = CacheImageDataloader(image_dataset=image_dataset) # a torch dataloader\n",
|
||||
" self.scene_name_to_image_sampler[scene_name] = image_sampler\n",
|
||||
" self.train_pixel_sampler = PixelSampler\n",
|
||||
" self.train_ray_generator = RayGenerator # nn.Module\n",
|
||||
@@ -250,7 +245,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"dataloader = Dataloader()\n",
|
||||
"dataloader = DataManager()\n",
|
||||
"model = SceneConditionNGPModel()\n",
|
||||
"pipeline = CustomPipeline.from_dataloader_and_model(dataloader=dataloader, model=model)"
|
||||
]
|
||||
@@ -352,7 +347,7 @@
|
||||
},
|
||||
"vscode": {
|
||||
"interpreter": {
|
||||
"hash": "e691f033e0f2f1b9c0a11e7e81375a1e27aec87a71fd1b1eaa545f7a5e61b3f6"
|
||||
"hash": "100252972d4ee5286ab455ef1c778abde05b4affca9d1be78633d3797abf7e8c"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user