Files
2025-07-29 02:30:47 +00:00

715 lines
62 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!doctype html>
<html class="no-js" lang="en" >
<head><meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<meta name="color-scheme" content="light dark"><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />
<meta property="og:title" content="DataManagers" />
<meta property="og:type" content="website" />
<meta property="og:url" content="http://docs.nerf.studio/developer_guides/pipelines/datamanagers.html" />
<meta property="og:description" content="What is a DataManager?: The DataManager batches and returns two components from an input dataset: A representation of viewpoint (either cameras or rays).- For splatting methods ( FullImageDataManag..." />
<meta property="og:image" content="https://assets.nerf.studio/opg.png" />
<meta property="og:image:alt" content="DataManagers" />
<link rel="index" title="Index" href="../../genindex.html" /><link rel="search" title="Search" href="../../search.html" /><link rel="next" title="Models" href="models.html" /><link rel="prev" title="Data Parsers" href="../../reference/api/data/dataparsers.html" />
<meta name="generator" content="sphinx-5.2.1, furo 2022.09.29" />
<title>DataManagers - nerfstudio</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="../../_static/styles/furo.css?digest=d81277517bee4d6b0349d71bb2661d4890b5617c" />
<link rel="stylesheet" type="text/css" href="../../_static/mystnb.css" />
<link rel="stylesheet" type="text/css" href="../../_static/togglebutton.css" />
<link rel="stylesheet" type="text/css" href="../../_static/copybutton.css" />
<link rel="stylesheet" type="text/css" href="../../_static/design-style.b7bb847fb20b106c3d81b95245e65545.min.css" />
<link rel="stylesheet" type="text/css" href="../../_static/styles/furo-extensions.css?digest=30d1aed668e5c3a91c3e3bf6a60b675221979f0e" />
<style>
body {
--color-code-background: #f8f9fb;
--color-code-foreground: black;
--color-brand-primary: #d34600;
--color-brand-content: #ff6f00;
}
@media not print {
body[data-theme="dark"] {
--color-code-background: #282C34;
--color-code-foreground: #ABB2BF;
--color-brand-primary: #fdd06c;
--color-brand-content: ##fea96a;
}
@media (prefers-color-scheme: dark) {
body:not([data-theme="light"]) {
--color-code-background: #282C34;
--color-code-foreground: #ABB2BF;
--color-brand-primary: #fdd06c;
--color-brand-content: ##fea96a;
}
}
}
</style><script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
<script src="../../_static/jquery.js"></script>
<script src="../../_static/underscore.js"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js"></script>
<script src="../../_static/doctools.js"></script>
<script src="../../_static/sphinx_highlight.js"></script>
<script src="../../_static/scripts/furo.js"></script>
<script src="../../_static/clipboard.min.js"></script>
<script src="../../_static/copybutton.js"></script>
<script>let toggleHintShow = 'Click to show';</script>
<script>let toggleHintHide = 'Click to hide';</script>
<script>let toggleOpenOnPrint = 'true';</script>
<script src="../../_static/togglebutton.js"></script>
<script>var togglebuttonSelector = '.toggle, .admonition.dropdown, .tag_hide_input div.cell_input, .tag_hide-input div.cell_input, .tag_hide_output div.cell_output, .tag_hide-output div.cell_output, .tag_hide_cell.cell, .tag_hide-cell.cell';</script>
<script src="../../_static/design-tabs.js"></script>
<script src="../../_static/require.min.js"></script>
<script src="../../_static/custom.js"></script>
</head>
<body>
<script>
document.body.dataset.theme = localStorage.getItem("theme") || "auto";
</script>
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
<symbol id="svg-toc" viewBox="0 0 24 24">
<title>Contents</title>
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 1024 1024">
<path d="M408 442h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8zm-8 204c0 4.4 3.6 8 8 8h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56zm504-486H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 632H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM115.4 518.9L271.7 642c5.8 4.6 14.4.5 14.4-6.9V388.9c0-7.4-8.5-11.5-14.4-6.9L115.4 505.1a8.74 8.74 0 0 0 0 13.8z"/>
</svg>
</symbol>
<symbol id="svg-menu" viewBox="0 0 24 24">
<title>Menu</title>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather-menu">
<line x1="3" y1="12" x2="21" y2="12"></line>
<line x1="3" y1="6" x2="21" y2="6"></line>
<line x1="3" y1="18" x2="21" y2="18"></line>
</svg>
</symbol>
<symbol id="svg-arrow-right" viewBox="0 0 24 24">
<title>Expand</title>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather-chevron-right">
<polyline points="9 18 15 12 9 6"></polyline>
</svg>
</symbol>
<symbol id="svg-sun" viewBox="0 0 24 24">
<title>Light mode</title>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="feather-sun">
<circle cx="12" cy="12" r="5"></circle>
<line x1="12" y1="1" x2="12" y2="3"></line>
<line x1="12" y1="21" x2="12" y2="23"></line>
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line>
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line>
<line x1="1" y1="12" x2="3" y2="12"></line>
<line x1="21" y1="12" x2="23" y2="12"></line>
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line>
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line>
</svg>
</symbol>
<symbol id="svg-moon" viewBox="0 0 24 24">
<title>Dark mode</title>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="icon-tabler-moon">
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path d="M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454z" />
</svg>
</symbol>
<symbol id="svg-sun-half" viewBox="0 0 24 24">
<title>Auto light/dark mode</title>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="icon-tabler-shadow">
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
<circle cx="12" cy="12" r="9" />
<path d="M13 12h5" />
<path d="M13 15h4" />
<path d="M13 18h1" />
<path d="M13 9h4" />
<path d="M13 6h1" />
</svg>
</symbol>
</svg>
<input type="checkbox" class="sidebar-toggle" name="__navigation" id="__navigation">
<input type="checkbox" class="sidebar-toggle" name="__toc" id="__toc">
<label class="overlay sidebar-overlay" for="__navigation">
<div class="visually-hidden">Hide navigation sidebar</div>
</label>
<label class="overlay toc-overlay" for="__toc">
<div class="visually-hidden">Hide table of contents sidebar</div>
</label>
<div class="page">
<header class="mobile-header">
<div class="header-left">
<label class="nav-overlay-icon" for="__navigation">
<div class="visually-hidden">Toggle site navigation sidebar</div>
<i class="icon"><svg><use href="#svg-menu"></use></svg></i>
</label>
</div>
<div class="header-center">
<a href="../../index.html"><div class="brand">nerfstudio</div></a>
</div>
<div class="header-right">
<div class="theme-toggle-container theme-toggle-header">
<button class="theme-toggle">
<div class="visually-hidden">Toggle Light / Dark / Auto color theme</div>
<svg class="theme-icon-when-auto"><use href="#svg-sun-half"></use></svg>
<svg class="theme-icon-when-dark"><use href="#svg-moon"></use></svg>
<svg class="theme-icon-when-light"><use href="#svg-sun"></use></svg>
</button>
</div>
<label class="toc-overlay-icon toc-header-icon" for="__toc">
<div class="visually-hidden">Toggle table of contents sidebar</div>
<i class="icon"><svg><use href="#svg-toc"></use></svg></i>
</label>
</div>
</header>
<aside class="sidebar-drawer">
<div class="sidebar-container">
<div class="sidebar-sticky"><a
class="sidebar-brand"
href="../../index.html"
>
<div class="sidebar-logo-container">
<img
class="sidebar-logo only-light"
src="../../_static/imgs/logo.png"
alt="Light Logo"
/>
<img
class="sidebar-logo only-dark"
src="../../_static/imgs/logo-dark.png"
alt="Dark Logo"
/>
</div>
</a>
<div style="text-align: center">
<script async defer src="https://buttons.github.io/buttons.js"></script>
<!-- Place this tag where you want the button to render. -->
<a
class="github-button"
href="https://github.com/nerfstudio-project/nerfstudio/"
data-color-scheme="no-preference: light; light: light; dark: light;"
data-size="large"
data-show-count="true"
aria-label="Download buttons/github-buttons on GitHub"
>
Github
</a>
<br />
<a
href="https://colab.research.google.com/github/nerfstudio-project/nerfstudio/blob/main/colab/demo.ipynb"
style="
background-color: #ebf0f4;
background-image: linear-gradient(180deg, #f6f8fa, #ebf0f4 90%);
border-radius: 3px;
border: 1px solid #1b1f2426;
display: inline-flex;
cursor: pointer;
color: #0d0d0d;
font-family: Arial;
font-size: 12px;
font-weight: bold;
padding: 5px 41px;
line-height: 16px;
text-decoration: none;
"
>
<svg
viewBox="0 0 24 24"
width="16"
height="16"
class="octicon octicon-mark-github"
>
<g>
<path
d="M4.54,9.46,2.19,7.1a6.93,6.93,0,0,0,0,9.79l2.36-2.36A3.59,3.59,0,0,1,4.54,9.46Z"
style=""
fill="#E8710A"
></path>
<path
d="M2.19,7.1,4.54,9.46a3.59,3.59,0,0,1,5.08,0l1.71-2.93h0l-.1-.08h0A6.93,6.93,0,0,0,2.19,7.1Z"
style=""
fill="#F9AB00"
></path>
<path
d="M11.34,17.46h0L9.62,14.54a3.59,3.59,0,0,1-5.08,0L2.19,16.9a6.93,6.93,0,0,0,9,.65l.11-.09"
style=""
fill="#F9AB00"
></path>
<path
d="M12,7.1a6.93,6.93,0,0,0,0,9.79l2.36-2.36a3.59,3.59,0,1,1,5.08-5.08L21.81,7.1A6.93,6.93,0,0,0,12,7.1Z"
style=""
fill="#F9AB00"
></path>
<path
d="M21.81,7.1,19.46,9.46a3.59,3.59,0,0,1-5.08,5.08L12,16.9A6.93,6.93,0,0,0,21.81,7.1Z"
style=""
fill="#E8710A"
></path>
</g>
</svg>
<span>&nbspcolab</span></a
>
</div><form class="sidebar-search-container" method="get" action="../../search.html" role="search">
<input class="sidebar-search" placeholder=Search name="q" aria-label="Search">
<input type="hidden" name="check_keywords" value="yes">
<input type="hidden" name="area" value="default">
</form>
<div id="searchbox"></div><div class="sidebar-scroll"><div class="sidebar-tree">
<p class="caption" role="heading"><span class="caption-text">Getting Started</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../quickstart/installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../quickstart/first_nerf.html">Training your first model</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../quickstart/existing_dataset.html">Using existing data</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../quickstart/custom_dataset.html">Using custom data</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../quickstart/viewer_quickstart.html">Using the viewer</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../quickstart/export_geometry.html">Export geometry</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../quickstart/data_conventions.html">Data conventions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../reference/contributing.html">Contributing</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Extensions</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../extensions/blender_addon.html">Blender VFX add-on</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../extensions/maya_plugin.html">Autodesk Maya Plug-in</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../extensions/unreal_engine.html">Exporting to Unreal Engine</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../extensions/sdfstudio.html">SDFStudio</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">NeRFology</span></p>
<ul>
<li class="toctree-l1 has-children"><a class="reference internal" href="../../nerfology/methods/index.html">Methods</a><input class="toctree-checkbox" id="toctree-checkbox-1" name="toctree-checkbox-1" role="switch" type="checkbox"/><label for="toctree-checkbox-1"><div class="visually-hidden">Toggle child pages in navigation</div><i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../../nerfology/methods/instant_ngp.html"> Instant-NGP</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../nerfology/methods/splat.html"> Splatfacto</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../nerfology/methods/splatw.html"> Splatfacto-W</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../nerfology/methods/in2n.html"> Instruct-NeRF2NeRF</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../nerfology/methods/igs2gs.html"> Instruct-GS2GS</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../nerfology/methods/signerf.html"> SIGNeRF</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../nerfology/methods/kplanes.html"> K-Planes</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../nerfology/methods/lerf.html"> LERF</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../nerfology/methods/livescene.html"> LiveScene</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../nerfology/methods/feature_splatting.html"> Feature-Splatting</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../nerfology/methods/mipnerf.html"> Mip-NeRF</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../nerfology/methods/nerf.html"> NeRF</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../nerfology/methods/nerfacto.html"> Nerfacto</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../nerfology/methods/nerfbusters.html"> Nerfbusters</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../nerfology/methods/nerfplayer.html"> NeRFPlayer</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../nerfology/methods/tetranerf.html"> Tetra-NeRF</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../nerfology/methods/tensorf.html"> TensoRF</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../nerfology/methods/generfacto.html"> Generfacto</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../nerfology/methods/pynerf.html"> PyNeRF</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../nerfology/methods/seathru_nerf.html"> SeaThru-NeRF</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../nerfology/methods/zipnerf.html"> Zip-NeRF</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../nerfology/methods/bionerf.html"> BioNeRF</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../nerfology/methods/nerf2gs2nerf.html"> NeRFtoGSandBack</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../nerfology/methods/opennerf.html"> OpenNeRF</a></li>
</ul>
</li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../../nerfology/model_components/index.html">Model components</a><input class="toctree-checkbox" id="toctree-checkbox-2" name="toctree-checkbox-2" role="switch" type="checkbox"/><label for="toctree-checkbox-2"><div class="visually-hidden">Toggle child pages in navigation</div><i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../../nerfology/model_components/visualize_cameras.html"> Cameras models</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../nerfology/model_components/visualize_samples.html"> Sample representation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../nerfology/model_components/visualize_samplers.html"> Ray samplers</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../nerfology/model_components/visualize_spatial_distortions.html"> Spatial distortions</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../nerfology/model_components/visualize_encoders.html"> Encoders</a></li>
</ul>
</li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Developer Guides</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../new_methods.html">Adding a New Method</a></li>
<li class="toctree-l1 current has-children"><a class="reference internal" href="index.html">Pipelines overview</a><input checked="" class="toctree-checkbox" id="toctree-checkbox-3" name="toctree-checkbox-3" role="switch" type="checkbox"/><label for="toctree-checkbox-3"><div class="visually-hidden">Toggle child pages in navigation</div><i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i></label><ul class="current">
<li class="toctree-l2 has-children"><a class="reference internal" href="dataparsers.html">DataParsers</a><input class="toctree-checkbox" id="toctree-checkbox-4" name="toctree-checkbox-4" role="switch" type="checkbox"/><label for="toctree-checkbox-4"><div class="visually-hidden">Toggle child pages in navigation</div><i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i></label><ul>
<li class="toctree-l3"><a class="reference internal" href="../../reference/api/data/dataparsers.html">Data Parsers</a></li>
</ul>
</li>
<li class="toctree-l2 current current-page"><a class="current reference internal" href="#">DataManagers</a></li>
<li class="toctree-l2"><a class="reference internal" href="models.html">Models</a></li>
<li class="toctree-l2"><a class="reference internal" href="fields.html">Fields</a></li>
<li class="toctree-l2"><a class="reference internal" href="pipelines.html">Pipelines</a></li>
</ul>
</li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../viewer/index.html">Viewer</a><input class="toctree-checkbox" id="toctree-checkbox-5" name="toctree-checkbox-5" role="switch" type="checkbox"/><label for="toctree-checkbox-5"><div class="visually-hidden">Toggle child pages in navigation</div><i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../viewer/custom_gui.html">Custom GUI</a></li>
<li class="toctree-l2"><a class="reference internal" href="../viewer/viewer_control.html">Python Viewer Control</a></li>
<li class="toctree-l2"><a class="reference internal" href="../viewer/local_viewer.html">(Legacy Viewer) Local Server</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../config.html">Customizable configs</a></li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../debugging_tools/index.html">Debugging tools</a><input class="toctree-checkbox" id="toctree-checkbox-6" name="toctree-checkbox-6" role="switch" type="checkbox"/><label for="toctree-checkbox-6"><div class="visually-hidden">Toggle child pages in navigation</div><i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../debugging_tools/local_logger.html">Local writer</a></li>
<li class="toctree-l2"><a class="reference internal" href="../debugging_tools/profiling.html">Code profiling support</a></li>
<li class="toctree-l2"><a class="reference internal" href="../debugging_tools/benchmarking.html">Benchmarking workflow</a></li>
</ul>
</li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Reference</span></p>
<ul>
<li class="toctree-l1 has-children"><a class="reference internal" href="../../reference/cli/index.html">CLI</a><input class="toctree-checkbox" id="toctree-checkbox-7" name="toctree-checkbox-7" role="switch" type="checkbox"/><label for="toctree-checkbox-7"><div class="visually-hidden">Toggle child pages in navigation</div><i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../../reference/cli/ns_install_cli.html">ns-install-cli</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../reference/cli/ns_process_data.html">ns-process-data</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../reference/cli/ns_download_data.html">ns-download-data</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../reference/cli/ns_train.html">ns-train</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../reference/cli/ns_render.html">ns-render</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../reference/cli/ns_viewer.html">ns-viewer</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../reference/cli/ns_export.html">ns-export</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../reference/cli/ns_eval.html">ns-eval</a></li>
</ul>
</li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../../reference/api/index.html">API</a><input class="toctree-checkbox" id="toctree-checkbox-8" name="toctree-checkbox-8" role="switch" type="checkbox"/><label for="toctree-checkbox-8"><div class="visually-hidden">Toggle child pages in navigation</div><i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../../reference/api/cameras.html">Cameras</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../reference/api/config.html">Configs</a></li>
<li class="toctree-l2 has-children"><a class="reference internal" href="../../reference/api/data/index.html">Data</a><input class="toctree-checkbox" id="toctree-checkbox-9" name="toctree-checkbox-9" role="switch" type="checkbox"/><label for="toctree-checkbox-9"><div class="visually-hidden">Toggle child pages in navigation</div><i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i></label><ul>
<li class="toctree-l3"><a class="reference internal" href="../../reference/api/data/dataparsers.html">Data Parsers</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../reference/api/data/datamanagers.html">Datamanagers</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../reference/api/data/datasets.html">Datasets</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../reference/api/data/utils.html">Utils</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../reference/api/fields.html">Fields</a></li>
<li class="toctree-l2 has-children"><a class="reference internal" href="../../reference/api/field_components/index.html">Field Modules</a><input class="toctree-checkbox" id="toctree-checkbox-10" name="toctree-checkbox-10" role="switch" type="checkbox"/><label for="toctree-checkbox-10"><div class="visually-hidden">Toggle child pages in navigation</div><i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i></label><ul>
<li class="toctree-l3"><a class="reference internal" href="../../reference/api/field_components/encodings.html">Encodings</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../reference/api/field_components/embeddings.html">Embeddings</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../reference/api/field_components/field_heads.html">Field Heads</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../reference/api/field_components/mlp.html">MLP</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../reference/api/field_components/spatial_distortions.html">Spatial Distortions</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../reference/api/models.html">Models</a></li>
<li class="toctree-l2 has-children"><a class="reference internal" href="../../reference/api/model_components/index.html">Model components</a><input class="toctree-checkbox" id="toctree-checkbox-11" name="toctree-checkbox-11" role="switch" type="checkbox"/><label for="toctree-checkbox-11"><div class="visually-hidden">Toggle child pages in navigation</div><i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i></label><ul>
<li class="toctree-l3"><a class="reference internal" href="../../reference/api/model_components/ray_sampler.html">Ray Sampler</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../reference/api/model_components/losses.html">Losses</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../reference/api/model_components/renderers.html">Renderers</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../reference/api/optimizers.html">Engine</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../reference/api/plugins.html">Plugins</a></li>
<li class="toctree-l2 has-children"><a class="reference internal" href="../../reference/api/utils/index.html">Utils</a><input class="toctree-checkbox" id="toctree-checkbox-12" name="toctree-checkbox-12" role="switch" type="checkbox"/><label for="toctree-checkbox-12"><div class="visually-hidden">Toggle child pages in navigation</div><i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i></label><ul>
<li class="toctree-l3"><a class="reference internal" href="../../reference/api/utils/colors.html">Colors</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../reference/api/utils/math.html">Math</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../reference/api/utils/colormaps.html">Colormaps</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../reference/api/utils/tensor_dataclass.html">TensorDataclass</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../reference/api/viewer.html">Viewer</a></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
</aside>
<div class="main">
<div class="content">
<div class="article-container">
<a href="#" class="back-to-top muted-link">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8v12z"></path>
</svg>
<span>Back to top</span>
</a>
<div class="content-icon-container">
<div class="theme-toggle-container theme-toggle-content">
<button class="theme-toggle">
<div class="visually-hidden">Toggle Light / Dark / Auto color theme</div>
<svg class="theme-icon-when-auto"><use href="#svg-sun-half"></use></svg>
<svg class="theme-icon-when-dark"><use href="#svg-moon"></use></svg>
<svg class="theme-icon-when-light"><use href="#svg-sun"></use></svg>
</button>
</div>
<label class="toc-overlay-icon toc-content-icon" for="__toc">
<div class="visually-hidden">Toggle table of contents sidebar</div>
<i class="icon"><svg><use href="#svg-toc"></use></svg></i>
</label>
</div>
<article role="main">
<section class="tex2jax_ignore mathjax_ignore" id="datamanagers">
<h1>DataManagers<a class="headerlink" href="#datamanagers" title="Permalink to this heading">#</a></h1>
<a class="only-light reference internal image-reference" href="../../_images/pipeline_datamanager-light.png"><img alt="../../_images/pipeline_datamanager-light.png" class="only-light align-center" src="../../_images/pipeline_datamanager-light.png" style="width: 600px;" /></a>
<a class="only-dark reference internal image-reference" href="../../_images/pipeline_datamanager-dark.png"><img alt="../../_images/pipeline_datamanager-dark.png" class="only-dark align-center" src="../../_images/pipeline_datamanager-dark.png" style="width: 600px;" /></a>
<section id="what-is-a-datamanager">
<h2>What is a DataManager?<a class="headerlink" href="#what-is-a-datamanager" title="Permalink to this heading">#</a></h2>
<p>The DataManager batches and returns two components from an input dataset:</p>
<ol class="arabic simple">
<li><p>A representation of viewpoint (either cameras or rays).</p>
<ul class="simple">
<li><p>For splatting methods (<code class="docutils literal notranslate"><span class="pre">FullImageDataManager</span></code>): a <code class="docutils literal notranslate"><span class="pre">Cameras</span></code> object.</p></li>
<li><p>For ray sampling methods (<code class="docutils literal notranslate"><span class="pre">VanillaDataManager</span></code>): a <code class="docutils literal notranslate"><span class="pre">RayBundle</span></code> object.</p></li>
</ul>
</li>
<li><p>A dictionary of ground truth data.</p>
<ul class="simple">
<li><p>For splatting methods (<code class="docutils literal notranslate"><span class="pre">FullImageDataManager</span></code>): dictionary contains complete images.</p></li>
<li><p>For ray sampling methods (<code class="docutils literal notranslate"><span class="pre">VanillaDataManager</span></code>): dictionary contains per-ray information.</p></li>
</ul>
</li>
</ol>
<p>Behaviors are defined by implementing the abstract methods required by the DataManager:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span><span class="w"> </span><span class="nc">DataManager</span><span class="p">(</span><span class="n">nn</span><span class="o">.</span><span class="n">Module</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Generic data manager&#39;s abstract class</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="nd">@abstractmethod</span>
<span class="k">def</span><span class="w"> </span><span class="nf">next_train</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">step</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Tuple</span><span class="p">[</span><span class="n">Union</span><span class="p">[</span><span class="n">RayBundle</span><span class="p">,</span> <span class="n">Cameras</span><span class="p">],</span> <span class="n">Dict</span><span class="p">]:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Returns the next batch of data for train.&quot;&quot;&quot;</span>
<span class="nd">@abstractmethod</span>
<span class="k">def</span><span class="w"> </span><span class="nf">next_eval</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">step</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Tuple</span><span class="p">[</span><span class="n">Union</span><span class="p">[</span><span class="n">RayBundle</span><span class="p">,</span> <span class="n">Cameras</span><span class="p">],</span> <span class="n">Dict</span><span class="p">]:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Returns the next batch of data for eval.&quot;&quot;&quot;</span>
<span class="nd">@abstractmethod</span>
<span class="k">def</span><span class="w"> </span><span class="nf">next_eval_image</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">step</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Tuple</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="n">RayBundle</span><span class="p">,</span> <span class="n">Dict</span><span class="p">]:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Returns the next eval image.</span>
<span class="sd"> Returns:</span>
<span class="sd"> The image index from the eval dataset, the CameraRayBundle, and the RayGT dictionary.</span>
<span class="sd"> &quot;&quot;&quot;</span>
</pre></div>
</div>
</section>
<section id="example">
<h2>Example<a class="headerlink" href="#example" title="Permalink to this heading">#</a></h2>
<p>We’ve implemented a VanillaDataManager that implements the standard logic of most NeRF papers. It will randomly sample training rays with corresponding ground truth information, in RayBundle and RayGT objects respectively. The config for the VanillaDataManager is the following.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@dataclass</span>
<span class="k">class</span><span class="w"> </span><span class="nc">VanillaDataManagerConfig</span><span class="p">(</span><span class="n">InstantiateConfig</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Configuration for data manager instantiation; DataManager is in charge of keeping the train/eval dataparsers;</span>
<span class="sd"> After instantiation, data manager holds both train/eval datasets and is in charge of returning unpacked</span>
<span class="sd"> train/eval data at each iteration</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">_target</span><span class="p">:</span> <span class="n">Type</span> <span class="o">=</span> <span class="n">field</span><span class="p">(</span><span class="n">default_factory</span><span class="o">=</span><span class="k">lambda</span><span class="p">:</span> <span class="n">VanillaDataManager</span><span class="p">)</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;target class to instantiate&quot;&quot;&quot;</span>
<span class="n">dataparser</span><span class="p">:</span> <span class="n">AnnotatedDataParserUnion</span> <span class="o">=</span> <span class="n">BlenderDataParserConfig</span><span class="p">()</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;specifies the dataparser used to unpack the data&quot;&quot;&quot;</span>
<span class="n">train_num_rays_per_batch</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">1024</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;number of rays per batch to use per training iteration&quot;&quot;&quot;</span>
<span class="n">train_num_images_to_sample_from</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;number of images to sample during training iteration&quot;&quot;&quot;</span>
<span class="n">eval_num_rays_per_batch</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">1024</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;number of rays per batch to use per eval iteration&quot;&quot;&quot;</span>
<span class="n">eval_num_images_to_sample_from</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;number of images to sample during eval iteration&quot;&quot;&quot;</span>
<span class="n">camera_optimizer</span><span class="p">:</span> <span class="n">CameraOptimizerConfig</span> <span class="o">=</span> <span class="n">CameraOptimizerConfig</span><span class="p">()</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;specifies the camera pose optimizer used during training&quot;&quot;&quot;</span>
</pre></div>
</div>
<p>Let’s take a quick look at how the <code class="docutils literal notranslate"><span class="pre">next_train</span></code> method is implemented. Here we sample images, then pixels, and then return the RayBundle and RayGT information.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span><span class="w"> </span><span class="nf">next_train</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">step</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Tuple</span><span class="p">[</span><span class="n">RayBundle</span><span class="p">,</span> <span class="n">Dict</span><span class="p">]:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Returns the next batch of data from the train dataloader.&quot;&quot;&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">train_count</span> <span class="o">+=</span> <span class="mi">1</span>
<span class="c1"># sample a batch of images</span>
<span class="n">image_batch</span> <span class="o">=</span> <span class="nb">next</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">iter_train_image_dataloader</span><span class="p">)</span>
<span class="c1"># sample pixels from this batch of images</span>
<span class="n">batch</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">train_pixel_sampler</span><span class="o">.</span><span class="n">sample</span><span class="p">(</span><span class="n">image_batch</span><span class="p">)</span>
<span class="n">ray_indices</span> <span class="o">=</span> <span class="n">batch</span><span class="p">[</span><span class="s2">&quot;indices&quot;</span><span class="p">]</span>
<span class="c1"># generate rays from this image and pixel indices</span>
<span class="n">ray_bundle</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">train_ray_generator</span><span class="p">(</span><span class="n">ray_indices</span><span class="p">)</span>
<span class="c1"># return RayBundle and RayGT information</span>
<span class="k">return</span> <span class="n">ray_bundle</span><span class="p">,</span> <span class="n">batch</span>
</pre></div>
</div>
<p>You can see our code for more details.</p>
<p><a class="sd-sphinx-override sd-btn sd-text-wrap sd-btn-outline-primary reference external" href="https://github.com/nerfstudio-project/nerfstudio/blob/main/nerfstudio/data/datamanagers/base_datamanager.py"><span>See the code!</span></a></p>
</section>
<section id="creating-your-own">
<h2>Creating Your Own<a class="headerlink" href="#creating-your-own" title="Permalink to this heading">#</a></h2>
<p>We currently don’t have other implementations because most papers follow the VanillaDataManager implementation. However, it should be straightforward to add a VanillaDataManager with logic that progressively adds cameras, for instance, by relying on the step and modifying RayBundle and RayGT generation logic.</p>
</section>
<section id="disk-caching-for-large-datasets">
<h2>Disk Caching for Large Datasets<a class="headerlink" href="#disk-caching-for-large-datasets" title="Permalink to this heading">#</a></h2>
<p>As of January 2025, the FullImageDatamanager and ParallelImageDatamanager implementations now support parallelized dataloading and dataloading from disk to avoid Out-Of-Memory errors and support very large datasets. To train a NeRF-based method with a large dataset that’s unable to fit in memory, please add the <code class="docutils literal notranslate"><span class="pre">load_from_disk</span></code> flag to your <code class="docutils literal notranslate"><span class="pre">ns-train</span></code> command. For example with nerfacto:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>ns-train<span class="w"> </span>nerfacto<span class="w"> </span>--data<span class="w"> </span><span class="o">{</span>PROCESSED_DATA_DIR<span class="o">}</span><span class="w"> </span>--pipeline.datamanager.load-from-disk
</pre></div>
</div>
<p>To train splatfacto with a large dataset that’s unable to fit in memory, please set the device of <code class="docutils literal notranslate"><span class="pre">cache_images</span></code> to <code class="docutils literal notranslate"><span class="pre">&quot;disk&quot;</span></code>. For example with splatfacto:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>ns-train<span class="w"> </span>splatfacto<span class="w"> </span>--data<span class="w"> </span><span class="o">{</span>PROCESSED_DATA_DIR<span class="o">}</span><span class="w"> </span>--pipeline.datamanager.cache-images<span class="w"> </span>disk
</pre></div>
</div>
<p>Checkout these flowcharts for more customization on large datasets!</p>
<a class="only-light reference internal image-reference" href="../../_images/DatamanagerGuide-LargeNeRF-light.png"><img alt="../../_images/DatamanagerGuide-LargeNeRF-light.png" class="only-light align-center" src="../../_images/DatamanagerGuide-LargeNeRF-light.png" style="width: 600px;" /></a>
<a class="only-dark reference internal image-reference" href="../../_images/DatamanagerGuide-LargeNeRF-dark.png"><img alt="../../_images/DatamanagerGuide-LargeNeRF-dark.png" class="only-dark align-center" src="../../_images/DatamanagerGuide-LargeNeRF-dark.png" style="width: 600px;" /></a>
<a class="only-light reference internal image-reference" href="../../_images/DatamanagerGuide-Large3DGS-light.png"><img alt="../../_images/DatamanagerGuide-Large3DGS-light.png" class="only-light align-center" src="../../_images/DatamanagerGuide-Large3DGS-light.png" style="width: 600px;" /></a>
<a class="only-dark reference internal image-reference" href="../../_images/DatamanagerGuide-Large3DGS-dark.png"><img alt="../../_images/DatamanagerGuide-Large3DGS-dark.png" class="only-dark align-center" src="../../_images/DatamanagerGuide-Large3DGS-dark.png" style="width: 600px;" /></a>
</section>
<section id="migrating-your-datamanager-to-the-new-datamanager">
<h2>Migrating Your DataManager to the new DataManager<a class="headerlink" href="#migrating-your-datamanager-to-the-new-datamanager" title="Permalink to this heading">#</a></h2>
<p>Many methods subclass a DataManager and add extra data to it. If you would like your custom datamanager to also support new parallel features, you can migrate any custom dataloading logic to the new <code class="docutils literal notranslate"><span class="pre">custom_ray_processor()</span></code> API. This function takes in a full training batch (either image or ray bundle) and allows the user to modify or add to it. Let’s take a look at an example for the LERF method, which was built on Nerfstudio’s VanillaDataManager. This API provides an interface to attach new information to the RayBundle (for ray based methods), Cameras object (for splatting based methods), or ground truth dictionary. It runs in a background process if disk caching is enabled, otherwise it runs in the main process.</p>
<p>Naively transfering code to <code class="docutils literal notranslate"><span class="pre">custom_ray_processor</span></code> may still OOM on very large datasets if initialization code requires computing something over the whole dataset. To fully take advantage of parallelization make sure your subclassed datamanager computes new information inside the <code class="docutils literal notranslate"><span class="pre">custom_ray_processor</span></code>, or caches a subset of the whole dataset. This can also still be slow if pre-computation requires GPU-heavy steps on the same GPU used for training.</p>
<p><strong>Note</strong>: Because the parallel DataManager uses background processes, any member of the DataManager needs to be <em>picklable</em> to be used inside <code class="docutils literal notranslate"><span class="pre">custom_ray_processor</span></code>.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span><span class="w"> </span><span class="nc">LERFDataManager</span><span class="p">(</span><span class="n">VanillaDataManager</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Subclass VanillaDataManager to add extra data processing</span>
<span class="sd"> </span>
<span class="sd"> Args:</span>
<span class="sd"> config: the DataManagerConfig used to instantiate class</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">config</span><span class="p">:</span> <span class="n">LERFDataManagerConfig</span>
<span class="k">def</span><span class="w"> </span><span class="fm">__init__</span><span class="p">(</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">config</span><span class="p">:</span> <span class="n">LERFDataManagerConfig</span><span class="p">,</span>
<span class="n">device</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="n">torch</span><span class="o">.</span><span class="n">device</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;cpu&quot;</span><span class="p">,</span>
<span class="n">test_mode</span><span class="p">:</span> <span class="n">Literal</span><span class="p">[</span><span class="s2">&quot;test&quot;</span><span class="p">,</span> <span class="s2">&quot;val&quot;</span><span class="p">,</span> <span class="s2">&quot;inference&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;val&quot;</span><span class="p">,</span>
<span class="n">world_size</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span>
<span class="n">local_rank</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span>
<span class="o">**</span><span class="n">kwargs</span><span class="p">,</span>
<span class="p">):</span>
<span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span>
<span class="n">config</span><span class="o">=</span><span class="n">config</span><span class="p">,</span> <span class="n">device</span><span class="o">=</span><span class="n">device</span><span class="p">,</span> <span class="n">test_mode</span><span class="o">=</span><span class="n">test_mode</span><span class="p">,</span> <span class="n">world_size</span><span class="o">=</span><span class="n">world_size</span><span class="p">,</span> <span class="n">local_rank</span><span class="o">=</span><span class="n">local_rank</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span>
<span class="p">)</span>
<span class="c1"># Some code to initialize all the CLIP and DINO feature encoders.</span>
<span class="bp">self</span><span class="o">.</span><span class="n">image_encoder</span><span class="p">:</span> <span class="n">BaseImageEncoder</span> <span class="o">=</span> <span class="n">kwargs</span><span class="p">[</span><span class="s2">&quot;image_encoder&quot;</span><span class="p">]</span>
<span class="bp">self</span><span class="o">.</span><span class="n">dino_dataloader</span> <span class="o">=</span> <span class="o">...</span>
<span class="bp">self</span><span class="o">.</span><span class="n">clip_interpolator</span> <span class="o">=</span> <span class="o">...</span>
<span class="k">def</span><span class="w"> </span><span class="nf">next_train</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">step</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Tuple</span><span class="p">[</span><span class="n">RayBundle</span><span class="p">,</span> <span class="n">Dict</span><span class="p">]:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Returns the next batch of data from the train dataloader.</span>
<span class="sd"> In this custom DataManager we need to add on the data that LERF needs, namely CLIP and DINO features.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">train_count</span> <span class="o">+=</span> <span class="mi">1</span>
<span class="n">image_batch</span> <span class="o">=</span> <span class="nb">next</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">iter_train_image_dataloader</span><span class="p">)</span>
<span class="k">assert</span> <span class="bp">self</span><span class="o">.</span><span class="n">train_pixel_sampler</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span>
<span class="n">batch</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">train_pixel_sampler</span><span class="o">.</span><span class="n">sample</span><span class="p">(</span><span class="n">image_batch</span><span class="p">)</span>
<span class="n">ray_indices</span> <span class="o">=</span> <span class="n">batch</span><span class="p">[</span><span class="s2">&quot;indices&quot;</span><span class="p">]</span>
<span class="n">ray_bundle</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">train_ray_generator</span><span class="p">(</span><span class="n">ray_indices</span><span class="p">)</span>
<span class="n">batch</span><span class="p">[</span><span class="s2">&quot;clip&quot;</span><span class="p">],</span> <span class="n">clip_scale</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">clip_interpolator</span><span class="p">(</span><span class="n">ray_indices</span><span class="p">)</span>
<span class="n">batch</span><span class="p">[</span><span class="s2">&quot;dino&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dino_dataloader</span><span class="p">(</span><span class="n">ray_indices</span><span class="p">)</span>
<span class="n">ray_bundle</span><span class="o">.</span><span class="n">metadata</span><span class="p">[</span><span class="s2">&quot;clip_scales&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">clip_scale</span>
<span class="c1"># assume all cameras have the same focal length and image width</span>
<span class="n">ray_bundle</span><span class="o">.</span><span class="n">metadata</span><span class="p">[</span><span class="s2">&quot;fx&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">train_dataset</span><span class="o">.</span><span class="n">cameras</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">fx</span><span class="o">.</span><span class="n">item</span><span class="p">()</span>
<span class="n">ray_bundle</span><span class="o">.</span><span class="n">metadata</span><span class="p">[</span><span class="s2">&quot;width&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">train_dataset</span><span class="o">.</span><span class="n">cameras</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">width</span><span class="o">.</span><span class="n">item</span><span class="p">()</span>
<span class="n">ray_bundle</span><span class="o">.</span><span class="n">metadata</span><span class="p">[</span><span class="s2">&quot;fy&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">train_dataset</span><span class="o">.</span><span class="n">cameras</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">fy</span><span class="o">.</span><span class="n">item</span><span class="p">()</span>
<span class="n">ray_bundle</span><span class="o">.</span><span class="n">metadata</span><span class="p">[</span><span class="s2">&quot;height&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">train_dataset</span><span class="o">.</span><span class="n">cameras</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">height</span><span class="o">.</span><span class="n">item</span><span class="p">()</span>
<span class="k">return</span> <span class="n">ray_bundle</span><span class="p">,</span> <span class="n">batch</span>
</pre></div>
</div>
<p>To migrate this custom datamanager to the new datamanager, we’ll subclass the new ParallelDataManager and shift the data customization process from <code class="docutils literal notranslate"><span class="pre">next_train()</span></code> to <code class="docutils literal notranslate"><span class="pre">custom_ray_processor()</span></code>.
The function <code class="docutils literal notranslate"><span class="pre">custom_ray_processor()</span></code> is called with a fully populated ray bundle and ground truth batch, just like the subclassed <code class="docutils literal notranslate"><span class="pre">next_train</span></code> in the above code. This code, however, is run in a background process.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span><span class="w"> </span><span class="nc">LERFDataManager</span><span class="p">(</span><span class="n">ParallelDataManager</span><span class="p">,</span> <span class="n">Generic</span><span class="p">[</span><span class="n">TDataset</span><span class="p">]):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> __init__ stays the same</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="o">...</span>
<span class="k">def</span><span class="w"> </span><span class="nf">custom_ray_processor</span><span class="p">(</span>
<span class="bp">self</span><span class="p">,</span> <span class="n">ray_bundle</span><span class="p">:</span> <span class="n">RayBundle</span><span class="p">,</span> <span class="n">batch</span><span class="p">:</span> <span class="n">Dict</span>
<span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Tuple</span><span class="p">[</span><span class="n">RayBundle</span><span class="p">,</span> <span class="n">Dict</span><span class="p">]:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;An API to add latents, metadata, or other further customization to the RayBundle dataloading process that is parallelized.&quot;&quot;&quot;</span>
<span class="n">ray_indices</span> <span class="o">=</span> <span class="n">batch</span><span class="p">[</span><span class="s2">&quot;indices&quot;</span><span class="p">]</span>
<span class="n">batch</span><span class="p">[</span><span class="s2">&quot;clip&quot;</span><span class="p">],</span> <span class="n">clip_scale</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">clip_interpolator</span><span class="p">(</span><span class="n">ray_indices</span><span class="p">)</span>
<span class="n">batch</span><span class="p">[</span><span class="s2">&quot;dino&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dino_dataloader</span><span class="p">(</span><span class="n">ray_indices</span><span class="p">)</span>
<span class="n">ray_bundle</span><span class="o">.</span><span class="n">metadata</span><span class="p">[</span><span class="s2">&quot;clip_scales&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">clip_scale</span>
<span class="c1"># Assume all cameras have the same focal length and image dimensions.</span>
<span class="n">ray_bundle</span><span class="o">.</span><span class="n">metadata</span><span class="p">[</span><span class="s2">&quot;fx&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">train_dataset</span><span class="o">.</span><span class="n">cameras</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">fx</span><span class="o">.</span><span class="n">item</span><span class="p">()</span>
<span class="n">ray_bundle</span><span class="o">.</span><span class="n">metadata</span><span class="p">[</span><span class="s2">&quot;width&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">train_dataset</span><span class="o">.</span><span class="n">cameras</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">width</span><span class="o">.</span><span class="n">item</span><span class="p">()</span>
<span class="n">ray_bundle</span><span class="o">.</span><span class="n">metadata</span><span class="p">[</span><span class="s2">&quot;fy&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">train_dataset</span><span class="o">.</span><span class="n">cameras</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">fy</span><span class="o">.</span><span class="n">item</span><span class="p">()</span>
<span class="n">ray_bundle</span><span class="o">.</span><span class="n">metadata</span><span class="p">[</span><span class="s2">&quot;height&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">train_dataset</span><span class="o">.</span><span class="n">cameras</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">height</span><span class="o">.</span><span class="n">item</span><span class="p">()</span>
<span class="k">return</span> <span class="n">ray_bundle</span><span class="p">,</span> <span class="n">batch</span>
</pre></div>
</div>
</section>
</section>
</article>
</div>
<footer>
<div class="related-pages">
<a class="next-page" href="models.html">
<div class="page-info">
<div class="context">
<span>Next</span>
</div>
<div class="title">Models</div>
</div>
<svg class="furo-related-icon"><use href="#svg-arrow-right"></use></svg>
</a>
<a class="prev-page" href="../../reference/api/data/dataparsers.html">
<svg class="furo-related-icon"><use href="#svg-arrow-right"></use></svg>
<div class="page-info">
<div class="context">
<span>Previous</span>
</div>
<div class="title">Data Parsers</div>
</div>
</a>
</div>
<div class="bottom-of-page">
<div class="left-details">
<div class="copyright">
Copyright &#169; 2022, nerfstudio Team
</div>
Made with <a href="https://www.sphinx-doc.org/">Sphinx</a> and <a class="muted-link" href="https://pradyunsg.me">@pradyunsg</a>'s
<a href="https://github.com/pradyunsg/furo">Furo</a>
</div>
<div class="right-details">
<div class="icons">
</div>
</div>
</div>
</footer>
</div>
<aside class="toc-drawer">
<div class="toc-sticky toc-scroll">
<div class="toc-title-container">
<span class="toc-title">
On this page
</span>
</div>
<div class="toc-tree-container">
<div class="toc-tree">
<ul>
<li><a class="reference internal" href="#">DataManagers</a><ul>
<li><a class="reference internal" href="#what-is-a-datamanager">What is a DataManager?</a></li>
<li><a class="reference internal" href="#example">Example</a></li>
<li><a class="reference internal" href="#creating-your-own">Creating Your Own</a></li>
<li><a class="reference internal" href="#disk-caching-for-large-datasets">Disk Caching for Large Datasets</a></li>
<li><a class="reference internal" href="#migrating-your-datamanager-to-the-new-datamanager">Migrating Your DataManager to the new DataManager</a></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</aside>
</div>
</div></body>
</html>