Publish site
1
css/main.css
Normal file
115
css/prism.css
Normal file
@ -0,0 +1,115 @@
|
||||
/**
|
||||
* Copyright (c) 2017-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* Modified prism.js default theme for JavaScript, CSS and HTML
|
||||
* Based on dabblet (http://dabblet.com)
|
||||
* @author Lea Verou
|
||||
*/
|
||||
|
||||
code[class*='language-'],
|
||||
pre[class*='language-'] {
|
||||
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
||||
text-align: left;
|
||||
white-space: pre;
|
||||
word-spacing: normal;
|
||||
word-break: normal;
|
||||
word-wrap: normal;
|
||||
line-height: 1.5;
|
||||
|
||||
-moz-tab-size: 4;
|
||||
-o-tab-size: 4;
|
||||
tab-size: 4;
|
||||
|
||||
-webkit-hyphens: none;
|
||||
-moz-hyphens: none;
|
||||
-ms-hyphens: none;
|
||||
hyphens: none;
|
||||
}
|
||||
|
||||
/* Code blocks */
|
||||
pre[class*='language-'] {
|
||||
padding: 1em;
|
||||
margin: 0.5em 0;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
/* Inline code */
|
||||
:not(pre) > code[class*='language-'] {
|
||||
padding: 0.1em;
|
||||
border-radius: 0.3em;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.token.comment,
|
||||
.token.prolog,
|
||||
.token.doctype,
|
||||
.token.cdata {
|
||||
color: slategray;
|
||||
}
|
||||
|
||||
.token.punctuation {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.namespace {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.token.property,
|
||||
.token.tag,
|
||||
.token.boolean,
|
||||
.token.constant,
|
||||
.token.symbol,
|
||||
.token.deleted {
|
||||
color: #905;
|
||||
}
|
||||
|
||||
.token.selector,
|
||||
.token.number,
|
||||
.token.attr-name,
|
||||
.token.string,
|
||||
.token.char,
|
||||
.token.builtin,
|
||||
.token.inserted {
|
||||
color: #690;
|
||||
}
|
||||
|
||||
.token.operator,
|
||||
.token.entity,
|
||||
.token.url,
|
||||
.language-css .token.string,
|
||||
.style .token.string {
|
||||
color: #9a6e3a;
|
||||
}
|
||||
|
||||
.token.atrule,
|
||||
.token.attr-value,
|
||||
.token.keyword {
|
||||
color: #07a;
|
||||
}
|
||||
|
||||
.token.function,
|
||||
.token.class-name {
|
||||
color: #dd4a68;
|
||||
}
|
||||
|
||||
.token.regex,
|
||||
.token.important,
|
||||
.token.variable {
|
||||
color: #e90;
|
||||
}
|
||||
|
||||
.token.important,
|
||||
.token.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
.token.italic {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.token.entity {
|
||||
cursor: help;
|
||||
}
|
BIN
docs/assets/architecture_overview.png
Normal file
After Width: | Height: | Size: 130 KiB |
BIN
docs/assets/batch_intro.png
Normal file
After Width: | Height: | Size: 272 KiB |
BIN
docs/assets/batch_modes.gif
Normal file
After Width: | Height: | Size: 1.5 MiB |
BIN
docs/assets/fullset_batch_size_16.png
Normal file
After Width: | Height: | Size: 64 KiB |
BIN
docs/assets/meshrcnn.png
Normal file
After Width: | Height: | Size: 1.1 MiB |
BIN
docs/assets/opengl_coordframes.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
docs/assets/p3d_naive_vs_coarse.png
Normal file
After Width: | Height: | Size: 314 KiB |
BIN
docs/assets/p3d_vs_softras.png
Normal file
After Width: | Height: | Size: 306 KiB |
BIN
docs/assets/transformations_overview.png
Normal file
After Width: | Height: | Size: 150 KiB |
79
docs/batching.html
Normal file
@ -0,0 +1,79 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>batching · PyTorch3d</title><meta name="viewport" content="width=device-width"/><meta name="generator" content="Docusaurus"/><meta name="description" content="# Batching"/><meta name="docsearch:language" content="en"/><meta property="og:title" content="batching · PyTorch3d"/><meta property="og:type" content="website"/><meta property="og:url" content="https://pytorch3d.org/"/><meta property="og:description" content="# Batching"/><meta property="og:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><meta name="twitter:card" content="summary"/><meta name="twitter:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><link rel="shortcut icon" href="/img/pytorch3dfavicon.png"/><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css"/><script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-157376881-1', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script><script type="text/javascript" src="https://buttons.github.io/buttons.js"></script><script src="/js/scrollSpy.js"></script><link rel="stylesheet" href="/css/main.css"/><script src="/js/codetabs.js"></script></head><body class="sideNavVisible separateOnPageNav"><div class="fixedHeaderContainer"><div class="headerWrapper wrapper"><header><a href="/"><img class="logo" src="/img/pytorch3dfavicon.png" alt="PyTorch3d"/><h2 class="headerTitleWithLogo">PyTorch3d</h2></a><div class="navigationWrapper navigationSlider"><nav class="slidingNav"><ul class="nav-site nav-site-internal"><li class="siteNavGroupActive"><a href="/docs/why_pytorch3d" target="_self">Docs</a></li><li class=""><a href="/tutorials" target="_self">Tutorials</a></li><li class=""><a href="https://pytorch3d.readthedocs.io/" target="_self">API</a></li><li class=""><a href="https://github.com/facebookresearch/pytorch3d" target="_self">GitHub</a></li></ul></nav></div></header></div></div><div class="navPusher"><div class="docMainWrapper wrapper"><div class="docsNavContainer" id="docsNav"><nav class="toc"><div class="toggleNav"><section class="navWrapper wrapper"><div class="navBreadcrumb wrapper"><div class="navToggle" id="navToggler"><div class="hamburger-menu"><div class="line1"></div><div class="line2"></div><div class="line3"></div></div></div><h2><i>›</i><span>Meshes</span></h2><div class="tocToggler" id="tocToggler"><i class="icon-toc"></i></div></div><div class="navGroups"><div class="navGroup"><h3 class="navGroupCategoryTitle">Introduction</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/why_pytorch3d">Why PyTorch3d</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Meshes</h3><ul class=""><li class="navListItem navListItemActive"><a class="navItem" href="/docs/batching">Batching</a></li><li class="navListItem"><a class="navItem" href="/docs/meshes_io">Loading from file</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Differentiable Renderer</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/renderer">Overview</a></li><li class="navListItem"><a class="navItem" href="/docs/renderer_getting_started">Getting Started</a></li></ul></div></div></section></div><script>
|
||||
var coll = document.getElementsByClassName('collapsible');
|
||||
var checkActiveCategory = true;
|
||||
for (var i = 0; i < coll.length; i++) {
|
||||
var links = coll[i].nextElementSibling.getElementsByTagName('*');
|
||||
if (checkActiveCategory){
|
||||
for (var j = 0; j < links.length; j++) {
|
||||
if (links[j].classList.contains('navListItemActive')){
|
||||
coll[i].nextElementSibling.classList.toggle('hide');
|
||||
coll[i].childNodes[1].classList.toggle('rotate');
|
||||
checkActiveCategory = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
coll[i].addEventListener('click', function() {
|
||||
var arrow = this.childNodes[1];
|
||||
arrow.classList.toggle('rotate');
|
||||
var content = this.nextElementSibling;
|
||||
content.classList.toggle('hide');
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
createToggler('#navToggler', '#docsNav', 'docsSliderActive');
|
||||
createToggler('#tocToggler', 'body', 'tocActive');
|
||||
|
||||
var headings = document.querySelector('.toc-headings');
|
||||
headings && headings.addEventListener('click', function(event) {
|
||||
var el = event.target;
|
||||
while(el !== headings){
|
||||
if (el.tagName === 'A') {
|
||||
document.body.classList.remove('tocActive');
|
||||
break;
|
||||
} else{
|
||||
el = el.parentNode;
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
|
||||
function createToggler(togglerSelector, targetSelector, className) {
|
||||
var toggler = document.querySelector(togglerSelector);
|
||||
var target = document.querySelector(targetSelector);
|
||||
|
||||
if (!toggler) {
|
||||
return;
|
||||
}
|
||||
|
||||
toggler.onclick = function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
target.classList.toggle(className);
|
||||
};
|
||||
}
|
||||
});
|
||||
</script></nav></div><div class="container mainContainer docsContainer"><div class="wrapper"><div class="post"><header class="postHeader"></header><article><div><span><h1><a class="anchor" aria-hidden="true" id="batching"></a><a href="#batching" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Batching</h1>
|
||||
<p>In deep learning, every optimization step operates on multiple input examples for robust training. Thus, efficient batching is crucial. For image inputs, batching is straighforward; N images are resized to the same height and width and stacked as a 4 dimensional tensor of shape <code>N x 3 x H x W</code>. For meshes, batching is less straighforward.</p>
|
||||
<p><img src="assets/batch_intro.png" alt="batch_intro" align="middle"/></p>
|
||||
<h2><a class="anchor" aria-hidden="true" id="batch-modes-for-meshes"></a><a href="#batch-modes-for-meshes" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Batch modes for meshes</h2>
|
||||
<p>Assume you want to construct a batch containing two meshes, with <code>mesh1 = (v1: V1 x 3, f1: F1 x 3)</code> containing <code>V1</code> vertices and <code>F1</code> faces, and <code>mesh2 = (v2: V2 x 3, f2: F2 x 3)</code> with <code>V2 (!= V1)</code> vertices and <code>F2 (!= F1)</code> faces. The <a href="https://github.com/facebookresearch/pytorch3d/blob/master/pytorch3d/structures/meshes.py">Meshes</a> data structure provides three different ways to batch <em>heterogeneous</em> meshes. If <code>meshes = Meshes(verts = [v1, v2], faces = [f1, f2])</code> is an instantiation of the data structure, then</p>
|
||||
<ul>
|
||||
<li>List: Returns the examples in the batch as a list of tensors. Specifically, <code>meshes.verts_list()</code> returns the list of vertices <code>[v1, v2]</code>. Similarly, <code>meshes.faces_list()</code> returns the list of faces <code>[f1, f2]</code>.</li>
|
||||
<li>Padded: The padded representation constructs a tensor by padding the extra values. Specifically, <code>meshes.verts_padded()</code> returns a tensor of shape <code>2 x max(V1, V2) x 3</code> and pads the extra vertices with <code>0</code>s. Similarly, <code>meshes.faces_padded()</code> returns a tensor of shape <code>2 x max(F1, F2) x 3</code> and pads the extra faces with <code>-1</code>s.</li>
|
||||
<li>Packed: The packed representation concatenates the examples in the batch into a tensor. In particular, <code>meshes.verts_packed()</code> returns a tensor of shape <code>(V1 + V2) x 3</code>. Similarly, <code>meshes.faces_packed()</code> returns a tensor of shape <code>(F1 + F2) x 3</code> for the faces. In the packed mode, auxiliary variables are computed that enable efficient conversion between packed and padded or list modes.</li>
|
||||
</ul>
|
||||
<p><img src="assets/batch_modes.gif" alt="batch_modes" height="450" align="middle" /></p>
|
||||
<h2><a class="anchor" aria-hidden="true" id="use-cases-for-batch-modes"></a><a href="#use-cases-for-batch-modes" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Use cases for batch modes</h2>
|
||||
<p>The need for different mesh batch modes is inherent to the way pytorch operators are implemented. To fully utilize the optimized pytorch ops, the <a href="https://github.com/facebookresearch/pytorch3d/blob/master/pytorch3d/structures/meshes.py">Meshes</a> data structure allows for efficient conversion between the different batch modes. This is crucial when aiming for a fast and efficient training cycle. An example of this is <a href="https://github.com/facebookresearch/meshrcnn">Mesh R-CNN</a>. Here, in the same forward pass different parts of the network assume different inputs, which are computed by converting between the different batch modes. In particular, <a href="https://github.com/facebookresearch/pytorch3d/blob/master/pytorch3d/ops/vert_align.py">vert_align</a> assumes a <em>padded</em> input tensor while immediately after <a href="https://github.com/facebookresearch/pytorch3d/blob/master/pytorch3d/ops/graph_conv.py">graph_conv</a> assumes a <em>packed</em> input tensor.</p>
|
||||
<p><img src="assets/meshrcnn.png" alt="meshrcnn" width="700" align="middle" /></p>
|
||||
</span></div></article></div><div class="docLastUpdate"><em>Last updated by Nikhila Ravi</em></div><div class="docs-prevnext"><a class="docs-prev button" href="/docs/why_pytorch3d"><span class="arrow-prev">← </span><span class="function-name-prevnext">Why PyTorch3d</span></a><a class="docs-next button" href="/docs/meshes_io"><span>Loading from file</span><span class="arrow-next"> →</span></a></div></div></div><nav class="onPageNav"><ul class="toc-headings"><li><a href="#batch-modes-for-meshes">Batch modes for meshes</a></li><li><a href="#use-cases-for-batch-modes">Use cases for batch modes</a></li></ul></nav></div><footer class="nav-footer" id="footer"><section class="sitemap"><div class="footerSection"><div class="social"><a class="github-button" href="https://github.com/facebookresearch/pytorch3d" data-count-href="https://github.com/facebookresearch/pytorch3d/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star PyTorch3d on GitHub">pytorch3d</a></div></div></section><a href="https://opensource.facebook.com/" target="_blank" rel="noreferrer noopener" class="fbOpenSource"><img src="/img/oss_logo.png" alt="Facebook Open Source" width="170" height="45"/></a><section class="copyright">Copyright "©" 2020 Facebook Inc</section></footer></div></body></html>
|
79
docs/batching/index.html
Normal file
@ -0,0 +1,79 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>batching · PyTorch3d</title><meta name="viewport" content="width=device-width"/><meta name="generator" content="Docusaurus"/><meta name="description" content="# Batching"/><meta name="docsearch:language" content="en"/><meta property="og:title" content="batching · PyTorch3d"/><meta property="og:type" content="website"/><meta property="og:url" content="https://pytorch3d.org/"/><meta property="og:description" content="# Batching"/><meta property="og:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><meta name="twitter:card" content="summary"/><meta name="twitter:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><link rel="shortcut icon" href="/img/pytorch3dfavicon.png"/><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css"/><script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-157376881-1', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script><script type="text/javascript" src="https://buttons.github.io/buttons.js"></script><script src="/js/scrollSpy.js"></script><link rel="stylesheet" href="/css/main.css"/><script src="/js/codetabs.js"></script></head><body class="sideNavVisible separateOnPageNav"><div class="fixedHeaderContainer"><div class="headerWrapper wrapper"><header><a href="/"><img class="logo" src="/img/pytorch3dfavicon.png" alt="PyTorch3d"/><h2 class="headerTitleWithLogo">PyTorch3d</h2></a><div class="navigationWrapper navigationSlider"><nav class="slidingNav"><ul class="nav-site nav-site-internal"><li class="siteNavGroupActive"><a href="/docs/why_pytorch3d" target="_self">Docs</a></li><li class=""><a href="/tutorials" target="_self">Tutorials</a></li><li class=""><a href="https://pytorch3d.readthedocs.io/" target="_self">API</a></li><li class=""><a href="https://github.com/facebookresearch/pytorch3d" target="_self">GitHub</a></li></ul></nav></div></header></div></div><div class="navPusher"><div class="docMainWrapper wrapper"><div class="docsNavContainer" id="docsNav"><nav class="toc"><div class="toggleNav"><section class="navWrapper wrapper"><div class="navBreadcrumb wrapper"><div class="navToggle" id="navToggler"><div class="hamburger-menu"><div class="line1"></div><div class="line2"></div><div class="line3"></div></div></div><h2><i>›</i><span>Meshes</span></h2><div class="tocToggler" id="tocToggler"><i class="icon-toc"></i></div></div><div class="navGroups"><div class="navGroup"><h3 class="navGroupCategoryTitle">Introduction</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/why_pytorch3d">Why PyTorch3d</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Meshes</h3><ul class=""><li class="navListItem navListItemActive"><a class="navItem" href="/docs/batching">Batching</a></li><li class="navListItem"><a class="navItem" href="/docs/meshes_io">Loading from file</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Differentiable Renderer</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/renderer">Overview</a></li><li class="navListItem"><a class="navItem" href="/docs/renderer_getting_started">Getting Started</a></li></ul></div></div></section></div><script>
|
||||
var coll = document.getElementsByClassName('collapsible');
|
||||
var checkActiveCategory = true;
|
||||
for (var i = 0; i < coll.length; i++) {
|
||||
var links = coll[i].nextElementSibling.getElementsByTagName('*');
|
||||
if (checkActiveCategory){
|
||||
for (var j = 0; j < links.length; j++) {
|
||||
if (links[j].classList.contains('navListItemActive')){
|
||||
coll[i].nextElementSibling.classList.toggle('hide');
|
||||
coll[i].childNodes[1].classList.toggle('rotate');
|
||||
checkActiveCategory = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
coll[i].addEventListener('click', function() {
|
||||
var arrow = this.childNodes[1];
|
||||
arrow.classList.toggle('rotate');
|
||||
var content = this.nextElementSibling;
|
||||
content.classList.toggle('hide');
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
createToggler('#navToggler', '#docsNav', 'docsSliderActive');
|
||||
createToggler('#tocToggler', 'body', 'tocActive');
|
||||
|
||||
var headings = document.querySelector('.toc-headings');
|
||||
headings && headings.addEventListener('click', function(event) {
|
||||
var el = event.target;
|
||||
while(el !== headings){
|
||||
if (el.tagName === 'A') {
|
||||
document.body.classList.remove('tocActive');
|
||||
break;
|
||||
} else{
|
||||
el = el.parentNode;
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
|
||||
function createToggler(togglerSelector, targetSelector, className) {
|
||||
var toggler = document.querySelector(togglerSelector);
|
||||
var target = document.querySelector(targetSelector);
|
||||
|
||||
if (!toggler) {
|
||||
return;
|
||||
}
|
||||
|
||||
toggler.onclick = function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
target.classList.toggle(className);
|
||||
};
|
||||
}
|
||||
});
|
||||
</script></nav></div><div class="container mainContainer docsContainer"><div class="wrapper"><div class="post"><header class="postHeader"></header><article><div><span><h1><a class="anchor" aria-hidden="true" id="batching"></a><a href="#batching" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Batching</h1>
|
||||
<p>In deep learning, every optimization step operates on multiple input examples for robust training. Thus, efficient batching is crucial. For image inputs, batching is straighforward; N images are resized to the same height and width and stacked as a 4 dimensional tensor of shape <code>N x 3 x H x W</code>. For meshes, batching is less straighforward.</p>
|
||||
<p><img src="assets/batch_intro.png" alt="batch_intro" align="middle"/></p>
|
||||
<h2><a class="anchor" aria-hidden="true" id="batch-modes-for-meshes"></a><a href="#batch-modes-for-meshes" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Batch modes for meshes</h2>
|
||||
<p>Assume you want to construct a batch containing two meshes, with <code>mesh1 = (v1: V1 x 3, f1: F1 x 3)</code> containing <code>V1</code> vertices and <code>F1</code> faces, and <code>mesh2 = (v2: V2 x 3, f2: F2 x 3)</code> with <code>V2 (!= V1)</code> vertices and <code>F2 (!= F1)</code> faces. The <a href="https://github.com/facebookresearch/pytorch3d/blob/master/pytorch3d/structures/meshes.py">Meshes</a> data structure provides three different ways to batch <em>heterogeneous</em> meshes. If <code>meshes = Meshes(verts = [v1, v2], faces = [f1, f2])</code> is an instantiation of the data structure, then</p>
|
||||
<ul>
|
||||
<li>List: Returns the examples in the batch as a list of tensors. Specifically, <code>meshes.verts_list()</code> returns the list of vertices <code>[v1, v2]</code>. Similarly, <code>meshes.faces_list()</code> returns the list of faces <code>[f1, f2]</code>.</li>
|
||||
<li>Padded: The padded representation constructs a tensor by padding the extra values. Specifically, <code>meshes.verts_padded()</code> returns a tensor of shape <code>2 x max(V1, V2) x 3</code> and pads the extra vertices with <code>0</code>s. Similarly, <code>meshes.faces_padded()</code> returns a tensor of shape <code>2 x max(F1, F2) x 3</code> and pads the extra faces with <code>-1</code>s.</li>
|
||||
<li>Packed: The packed representation concatenates the examples in the batch into a tensor. In particular, <code>meshes.verts_packed()</code> returns a tensor of shape <code>(V1 + V2) x 3</code>. Similarly, <code>meshes.faces_packed()</code> returns a tensor of shape <code>(F1 + F2) x 3</code> for the faces. In the packed mode, auxiliary variables are computed that enable efficient conversion between packed and padded or list modes.</li>
|
||||
</ul>
|
||||
<p><img src="assets/batch_modes.gif" alt="batch_modes" height="450" align="middle" /></p>
|
||||
<h2><a class="anchor" aria-hidden="true" id="use-cases-for-batch-modes"></a><a href="#use-cases-for-batch-modes" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Use cases for batch modes</h2>
|
||||
<p>The need for different mesh batch modes is inherent to the way pytorch operators are implemented. To fully utilize the optimized pytorch ops, the <a href="https://github.com/facebookresearch/pytorch3d/blob/master/pytorch3d/structures/meshes.py">Meshes</a> data structure allows for efficient conversion between the different batch modes. This is crucial when aiming for a fast and efficient training cycle. An example of this is <a href="https://github.com/facebookresearch/meshrcnn">Mesh R-CNN</a>. Here, in the same forward pass different parts of the network assume different inputs, which are computed by converting between the different batch modes. In particular, <a href="https://github.com/facebookresearch/pytorch3d/blob/master/pytorch3d/ops/vert_align.py">vert_align</a> assumes a <em>padded</em> input tensor while immediately after <a href="https://github.com/facebookresearch/pytorch3d/blob/master/pytorch3d/ops/graph_conv.py">graph_conv</a> assumes a <em>packed</em> input tensor.</p>
|
||||
<p><img src="assets/meshrcnn.png" alt="meshrcnn" width="700" align="middle" /></p>
|
||||
</span></div></article></div><div class="docLastUpdate"><em>Last updated by Nikhila Ravi</em></div><div class="docs-prevnext"><a class="docs-prev button" href="/docs/why_pytorch3d"><span class="arrow-prev">← </span><span class="function-name-prevnext">Why PyTorch3d</span></a><a class="docs-next button" href="/docs/meshes_io"><span>Loading from file</span><span class="arrow-next"> →</span></a></div></div></div><nav class="onPageNav"><ul class="toc-headings"><li><a href="#batch-modes-for-meshes">Batch modes for meshes</a></li><li><a href="#use-cases-for-batch-modes">Use cases for batch modes</a></li></ul></nav></div><footer class="nav-footer" id="footer"><section class="sitemap"><div class="footerSection"><div class="social"><a class="github-button" href="https://github.com/facebookresearch/pytorch3d" data-count-href="https://github.com/facebookresearch/pytorch3d/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star PyTorch3d on GitHub">pytorch3d</a></div></div></section><a href="https://opensource.facebook.com/" target="_blank" rel="noreferrer noopener" class="fbOpenSource"><img src="/img/oss_logo.png" alt="Facebook Open Source" width="170" height="45"/></a><section class="copyright">Copyright "©" 2020 Facebook Inc</section></footer></div></body></html>
|
118
docs/meshes_io.html
Normal file
@ -0,0 +1,118 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>meshes_io · PyTorch3d</title><meta name="viewport" content="width=device-width"/><meta name="generator" content="Docusaurus"/><meta name="description" content="# Meshes and IO"/><meta name="docsearch:language" content="en"/><meta property="og:title" content="meshes_io · PyTorch3d"/><meta property="og:type" content="website"/><meta property="og:url" content="https://pytorch3d.org/"/><meta property="og:description" content="# Meshes and IO"/><meta property="og:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><meta name="twitter:card" content="summary"/><meta name="twitter:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><link rel="shortcut icon" href="/img/pytorch3dfavicon.png"/><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css"/><script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-157376881-1', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script><script type="text/javascript" src="https://buttons.github.io/buttons.js"></script><script src="/js/scrollSpy.js"></script><link rel="stylesheet" href="/css/main.css"/><script src="/js/codetabs.js"></script></head><body class="sideNavVisible separateOnPageNav"><div class="fixedHeaderContainer"><div class="headerWrapper wrapper"><header><a href="/"><img class="logo" src="/img/pytorch3dfavicon.png" alt="PyTorch3d"/><h2 class="headerTitleWithLogo">PyTorch3d</h2></a><div class="navigationWrapper navigationSlider"><nav class="slidingNav"><ul class="nav-site nav-site-internal"><li class="siteNavGroupActive"><a href="/docs/why_pytorch3d" target="_self">Docs</a></li><li class=""><a href="/tutorials" target="_self">Tutorials</a></li><li class=""><a href="https://pytorch3d.readthedocs.io/" target="_self">API</a></li><li class=""><a href="https://github.com/facebookresearch/pytorch3d" target="_self">GitHub</a></li></ul></nav></div></header></div></div><div class="navPusher"><div class="docMainWrapper wrapper"><div class="docsNavContainer" id="docsNav"><nav class="toc"><div class="toggleNav"><section class="navWrapper wrapper"><div class="navBreadcrumb wrapper"><div class="navToggle" id="navToggler"><div class="hamburger-menu"><div class="line1"></div><div class="line2"></div><div class="line3"></div></div></div><h2><i>›</i><span>Meshes</span></h2><div class="tocToggler" id="tocToggler"><i class="icon-toc"></i></div></div><div class="navGroups"><div class="navGroup"><h3 class="navGroupCategoryTitle">Introduction</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/why_pytorch3d">Why PyTorch3d</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Meshes</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/batching">Batching</a></li><li class="navListItem navListItemActive"><a class="navItem" href="/docs/meshes_io">Loading from file</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Differentiable Renderer</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/renderer">Overview</a></li><li class="navListItem"><a class="navItem" href="/docs/renderer_getting_started">Getting Started</a></li></ul></div></div></section></div><script>
|
||||
var coll = document.getElementsByClassName('collapsible');
|
||||
var checkActiveCategory = true;
|
||||
for (var i = 0; i < coll.length; i++) {
|
||||
var links = coll[i].nextElementSibling.getElementsByTagName('*');
|
||||
if (checkActiveCategory){
|
||||
for (var j = 0; j < links.length; j++) {
|
||||
if (links[j].classList.contains('navListItemActive')){
|
||||
coll[i].nextElementSibling.classList.toggle('hide');
|
||||
coll[i].childNodes[1].classList.toggle('rotate');
|
||||
checkActiveCategory = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
coll[i].addEventListener('click', function() {
|
||||
var arrow = this.childNodes[1];
|
||||
arrow.classList.toggle('rotate');
|
||||
var content = this.nextElementSibling;
|
||||
content.classList.toggle('hide');
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
createToggler('#navToggler', '#docsNav', 'docsSliderActive');
|
||||
createToggler('#tocToggler', 'body', 'tocActive');
|
||||
|
||||
var headings = document.querySelector('.toc-headings');
|
||||
headings && headings.addEventListener('click', function(event) {
|
||||
var el = event.target;
|
||||
while(el !== headings){
|
||||
if (el.tagName === 'A') {
|
||||
document.body.classList.remove('tocActive');
|
||||
break;
|
||||
} else{
|
||||
el = el.parentNode;
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
|
||||
function createToggler(togglerSelector, targetSelector, className) {
|
||||
var toggler = document.querySelector(togglerSelector);
|
||||
var target = document.querySelector(targetSelector);
|
||||
|
||||
if (!toggler) {
|
||||
return;
|
||||
}
|
||||
|
||||
toggler.onclick = function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
target.classList.toggle(className);
|
||||
};
|
||||
}
|
||||
});
|
||||
</script></nav></div><div class="container mainContainer docsContainer"><div class="wrapper"><div class="post"><header class="postHeader"></header><article><div><span><h1><a class="anchor" aria-hidden="true" id="meshes-and-io"></a><a href="#meshes-and-io" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Meshes and IO</h1>
|
||||
<p>The Meshes object represents a batch of triangulated meshes, and is central to
|
||||
much of the functionality of pytorch3d. There is no insistence that each mesh in
|
||||
the batch has the same number of vertices or faces. When available, it can store
|
||||
other data which pertains to the mesh, for example face normals, face areas
|
||||
and textures.</p>
|
||||
<p>Two common file formats for storing single meshes are ".obj" and ".ply" files,
|
||||
and pytorch3d has functions for reading these.</p>
|
||||
<h2><a class="anchor" aria-hidden="true" id="obj"></a><a href="#obj" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>OBJ</h2>
|
||||
<p>Obj files have a standard way to store extra information about a mesh. Given an
|
||||
obj file, it can be read with</p>
|
||||
<pre><code class="hljs"> verts, faces, aux = load<span class="hljs-constructor">_obj(<span class="hljs-params">filename</span>)</span>
|
||||
</code></pre>
|
||||
<p>which sets <code>verts</code> to be a (V,3)-tensor of vertices and <code>faces.verts_idx</code> to be
|
||||
an (F,3)- tensor of the vertex-indices of each of the corners of the faces.
|
||||
Faces which are not triangles will be split into triangles. <code>aux</code> is an object
|
||||
which may contain normals, uv coordinates, material colors and textures if they
|
||||
are present, and <code>faces</code> may additionally contain indices into these normals,
|
||||
textures and materials in its NamedTuple structure. A Meshes object containing a
|
||||
single mesh can be created from just the vertices and faces using</p>
|
||||
<pre><code class="hljs"> meshes = <span class="hljs-constructor">Meshes(<span class="hljs-params">verts</span>=[<span class="hljs-params">verts</span>], <span class="hljs-params">faces</span>=[<span class="hljs-params">faces</span>.<span class="hljs-params">verts_idx</span>])</span>
|
||||
</code></pre>
|
||||
<p>If there is texture information in the <code>.obj</code> it can be used to initialize a
|
||||
<code>Textures</code> class which is passed into the <code>Meshes</code> constructor. Currently we
|
||||
support loading of texture maps for meshes which have one texture map for the
|
||||
entire mesh e.g.</p>
|
||||
<pre><code class="hljs"><span class="hljs-attr">verts_uvs</span> = aux.verts_uvs[None, ...] <span class="hljs-comment"># (1, V, 2)</span>
|
||||
<span class="hljs-attr">faces_uvs</span> = faces.textures_idx[None, ...] <span class="hljs-comment"># (1, F, 3)</span>
|
||||
<span class="hljs-attr">tex_maps</span> = aux.texture_images
|
||||
|
||||
<span class="hljs-comment"># tex_maps is a dictionary of {material name: texture image}.</span>
|
||||
<span class="hljs-comment"># Take the first image:</span>
|
||||
<span class="hljs-attr">texture_image</span> = list(tex_maps.values())[<span class="hljs-number">0</span>]
|
||||
<span class="hljs-attr">texture_image</span> = texture_image[None, ...] <span class="hljs-comment"># (1, H, W, 3)</span>
|
||||
|
||||
<span class="hljs-comment"># Create a textures object</span>
|
||||
<span class="hljs-attr">tex</span> = Textures(verts_uvs=verts_uvs, faces_uvs=faces_uvs, maps=texture_image)
|
||||
|
||||
<span class="hljs-comment"># Initialise the mesh with textures</span>
|
||||
<span class="hljs-attr">meshes</span> = Meshes(verts=[verts], faces=[faces.verts_idx], textures=tex)
|
||||
</code></pre>
|
||||
<h2><a class="anchor" aria-hidden="true" id="ply"></a><a href="#ply" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>PLY</h2>
|
||||
<p>Ply files are flexible in the way they store additional information, pytorch3d
|
||||
provides a function just to read the vertices and faces from a ply file.
|
||||
The call</p>
|
||||
<pre><code class="hljs"> verts, faces = load<span class="hljs-constructor">_ply(<span class="hljs-params">filename</span>)</span>
|
||||
</code></pre>
|
||||
<p>sets <code>verts</code> to be a (V,3)-tensor of vertices and <code>faces</code> to be an (F,3)-
|
||||
tensor of the vertex-indices of each of the corners of the faces. Faces which
|
||||
are not triangles will be split into triangles. A Meshes object containing a
|
||||
single mesh can be created from this data using</p>
|
||||
<pre><code class="hljs"> meshes = <span class="hljs-constructor">Meshes(<span class="hljs-params">verts</span>=[<span class="hljs-params">verts</span>], <span class="hljs-params">faces</span>=[<span class="hljs-params">faces</span>])</span>
|
||||
</code></pre>
|
||||
</span></div></article></div><div class="docLastUpdate"><em>Last updated by Nikhila Ravi</em></div><div class="docs-prevnext"><a class="docs-prev button" href="/docs/batching"><span class="arrow-prev">← </span><span>Batching</span></a><a class="docs-next button" href="/docs/renderer"><span>Overview</span><span class="arrow-next"> →</span></a></div></div></div><nav class="onPageNav"><ul class="toc-headings"><li><a href="#obj">OBJ</a></li><li><a href="#ply">PLY</a></li></ul></nav></div><footer class="nav-footer" id="footer"><section class="sitemap"><div class="footerSection"><div class="social"><a class="github-button" href="https://github.com/facebookresearch/pytorch3d" data-count-href="https://github.com/facebookresearch/pytorch3d/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star PyTorch3d on GitHub">pytorch3d</a></div></div></section><a href="https://opensource.facebook.com/" target="_blank" rel="noreferrer noopener" class="fbOpenSource"><img src="/img/oss_logo.png" alt="Facebook Open Source" width="170" height="45"/></a><section class="copyright">Copyright "©" 2020 Facebook Inc</section></footer></div></body></html>
|
118
docs/meshes_io/index.html
Normal file
@ -0,0 +1,118 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>meshes_io · PyTorch3d</title><meta name="viewport" content="width=device-width"/><meta name="generator" content="Docusaurus"/><meta name="description" content="# Meshes and IO"/><meta name="docsearch:language" content="en"/><meta property="og:title" content="meshes_io · PyTorch3d"/><meta property="og:type" content="website"/><meta property="og:url" content="https://pytorch3d.org/"/><meta property="og:description" content="# Meshes and IO"/><meta property="og:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><meta name="twitter:card" content="summary"/><meta name="twitter:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><link rel="shortcut icon" href="/img/pytorch3dfavicon.png"/><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css"/><script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-157376881-1', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script><script type="text/javascript" src="https://buttons.github.io/buttons.js"></script><script src="/js/scrollSpy.js"></script><link rel="stylesheet" href="/css/main.css"/><script src="/js/codetabs.js"></script></head><body class="sideNavVisible separateOnPageNav"><div class="fixedHeaderContainer"><div class="headerWrapper wrapper"><header><a href="/"><img class="logo" src="/img/pytorch3dfavicon.png" alt="PyTorch3d"/><h2 class="headerTitleWithLogo">PyTorch3d</h2></a><div class="navigationWrapper navigationSlider"><nav class="slidingNav"><ul class="nav-site nav-site-internal"><li class="siteNavGroupActive"><a href="/docs/why_pytorch3d" target="_self">Docs</a></li><li class=""><a href="/tutorials" target="_self">Tutorials</a></li><li class=""><a href="https://pytorch3d.readthedocs.io/" target="_self">API</a></li><li class=""><a href="https://github.com/facebookresearch/pytorch3d" target="_self">GitHub</a></li></ul></nav></div></header></div></div><div class="navPusher"><div class="docMainWrapper wrapper"><div class="docsNavContainer" id="docsNav"><nav class="toc"><div class="toggleNav"><section class="navWrapper wrapper"><div class="navBreadcrumb wrapper"><div class="navToggle" id="navToggler"><div class="hamburger-menu"><div class="line1"></div><div class="line2"></div><div class="line3"></div></div></div><h2><i>›</i><span>Meshes</span></h2><div class="tocToggler" id="tocToggler"><i class="icon-toc"></i></div></div><div class="navGroups"><div class="navGroup"><h3 class="navGroupCategoryTitle">Introduction</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/why_pytorch3d">Why PyTorch3d</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Meshes</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/batching">Batching</a></li><li class="navListItem navListItemActive"><a class="navItem" href="/docs/meshes_io">Loading from file</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Differentiable Renderer</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/renderer">Overview</a></li><li class="navListItem"><a class="navItem" href="/docs/renderer_getting_started">Getting Started</a></li></ul></div></div></section></div><script>
|
||||
var coll = document.getElementsByClassName('collapsible');
|
||||
var checkActiveCategory = true;
|
||||
for (var i = 0; i < coll.length; i++) {
|
||||
var links = coll[i].nextElementSibling.getElementsByTagName('*');
|
||||
if (checkActiveCategory){
|
||||
for (var j = 0; j < links.length; j++) {
|
||||
if (links[j].classList.contains('navListItemActive')){
|
||||
coll[i].nextElementSibling.classList.toggle('hide');
|
||||
coll[i].childNodes[1].classList.toggle('rotate');
|
||||
checkActiveCategory = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
coll[i].addEventListener('click', function() {
|
||||
var arrow = this.childNodes[1];
|
||||
arrow.classList.toggle('rotate');
|
||||
var content = this.nextElementSibling;
|
||||
content.classList.toggle('hide');
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
createToggler('#navToggler', '#docsNav', 'docsSliderActive');
|
||||
createToggler('#tocToggler', 'body', 'tocActive');
|
||||
|
||||
var headings = document.querySelector('.toc-headings');
|
||||
headings && headings.addEventListener('click', function(event) {
|
||||
var el = event.target;
|
||||
while(el !== headings){
|
||||
if (el.tagName === 'A') {
|
||||
document.body.classList.remove('tocActive');
|
||||
break;
|
||||
} else{
|
||||
el = el.parentNode;
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
|
||||
function createToggler(togglerSelector, targetSelector, className) {
|
||||
var toggler = document.querySelector(togglerSelector);
|
||||
var target = document.querySelector(targetSelector);
|
||||
|
||||
if (!toggler) {
|
||||
return;
|
||||
}
|
||||
|
||||
toggler.onclick = function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
target.classList.toggle(className);
|
||||
};
|
||||
}
|
||||
});
|
||||
</script></nav></div><div class="container mainContainer docsContainer"><div class="wrapper"><div class="post"><header class="postHeader"></header><article><div><span><h1><a class="anchor" aria-hidden="true" id="meshes-and-io"></a><a href="#meshes-and-io" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Meshes and IO</h1>
|
||||
<p>The Meshes object represents a batch of triangulated meshes, and is central to
|
||||
much of the functionality of pytorch3d. There is no insistence that each mesh in
|
||||
the batch has the same number of vertices or faces. When available, it can store
|
||||
other data which pertains to the mesh, for example face normals, face areas
|
||||
and textures.</p>
|
||||
<p>Two common file formats for storing single meshes are ".obj" and ".ply" files,
|
||||
and pytorch3d has functions for reading these.</p>
|
||||
<h2><a class="anchor" aria-hidden="true" id="obj"></a><a href="#obj" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>OBJ</h2>
|
||||
<p>Obj files have a standard way to store extra information about a mesh. Given an
|
||||
obj file, it can be read with</p>
|
||||
<pre><code class="hljs"> verts, faces, aux = load<span class="hljs-constructor">_obj(<span class="hljs-params">filename</span>)</span>
|
||||
</code></pre>
|
||||
<p>which sets <code>verts</code> to be a (V,3)-tensor of vertices and <code>faces.verts_idx</code> to be
|
||||
an (F,3)- tensor of the vertex-indices of each of the corners of the faces.
|
||||
Faces which are not triangles will be split into triangles. <code>aux</code> is an object
|
||||
which may contain normals, uv coordinates, material colors and textures if they
|
||||
are present, and <code>faces</code> may additionally contain indices into these normals,
|
||||
textures and materials in its NamedTuple structure. A Meshes object containing a
|
||||
single mesh can be created from just the vertices and faces using</p>
|
||||
<pre><code class="hljs"> meshes = <span class="hljs-constructor">Meshes(<span class="hljs-params">verts</span>=[<span class="hljs-params">verts</span>], <span class="hljs-params">faces</span>=[<span class="hljs-params">faces</span>.<span class="hljs-params">verts_idx</span>])</span>
|
||||
</code></pre>
|
||||
<p>If there is texture information in the <code>.obj</code> it can be used to initialize a
|
||||
<code>Textures</code> class which is passed into the <code>Meshes</code> constructor. Currently we
|
||||
support loading of texture maps for meshes which have one texture map for the
|
||||
entire mesh e.g.</p>
|
||||
<pre><code class="hljs"><span class="hljs-attr">verts_uvs</span> = aux.verts_uvs[None, ...] <span class="hljs-comment"># (1, V, 2)</span>
|
||||
<span class="hljs-attr">faces_uvs</span> = faces.textures_idx[None, ...] <span class="hljs-comment"># (1, F, 3)</span>
|
||||
<span class="hljs-attr">tex_maps</span> = aux.texture_images
|
||||
|
||||
<span class="hljs-comment"># tex_maps is a dictionary of {material name: texture image}.</span>
|
||||
<span class="hljs-comment"># Take the first image:</span>
|
||||
<span class="hljs-attr">texture_image</span> = list(tex_maps.values())[<span class="hljs-number">0</span>]
|
||||
<span class="hljs-attr">texture_image</span> = texture_image[None, ...] <span class="hljs-comment"># (1, H, W, 3)</span>
|
||||
|
||||
<span class="hljs-comment"># Create a textures object</span>
|
||||
<span class="hljs-attr">tex</span> = Textures(verts_uvs=verts_uvs, faces_uvs=faces_uvs, maps=texture_image)
|
||||
|
||||
<span class="hljs-comment"># Initialise the mesh with textures</span>
|
||||
<span class="hljs-attr">meshes</span> = Meshes(verts=[verts], faces=[faces.verts_idx], textures=tex)
|
||||
</code></pre>
|
||||
<h2><a class="anchor" aria-hidden="true" id="ply"></a><a href="#ply" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>PLY</h2>
|
||||
<p>Ply files are flexible in the way they store additional information, pytorch3d
|
||||
provides a function just to read the vertices and faces from a ply file.
|
||||
The call</p>
|
||||
<pre><code class="hljs"> verts, faces = load<span class="hljs-constructor">_ply(<span class="hljs-params">filename</span>)</span>
|
||||
</code></pre>
|
||||
<p>sets <code>verts</code> to be a (V,3)-tensor of vertices and <code>faces</code> to be an (F,3)-
|
||||
tensor of the vertex-indices of each of the corners of the faces. Faces which
|
||||
are not triangles will be split into triangles. A Meshes object containing a
|
||||
single mesh can be created from this data using</p>
|
||||
<pre><code class="hljs"> meshes = <span class="hljs-constructor">Meshes(<span class="hljs-params">verts</span>=[<span class="hljs-params">verts</span>], <span class="hljs-params">faces</span>=[<span class="hljs-params">faces</span>])</span>
|
||||
</code></pre>
|
||||
</span></div></article></div><div class="docLastUpdate"><em>Last updated by Nikhila Ravi</em></div><div class="docs-prevnext"><a class="docs-prev button" href="/docs/batching"><span class="arrow-prev">← </span><span>Batching</span></a><a class="docs-next button" href="/docs/renderer"><span>Overview</span><span class="arrow-next"> →</span></a></div></div></div><nav class="onPageNav"><ul class="toc-headings"><li><a href="#obj">OBJ</a></li><li><a href="#ply">PLY</a></li></ul></nav></div><footer class="nav-footer" id="footer"><section class="sitemap"><div class="footerSection"><div class="social"><a class="github-button" href="https://github.com/facebookresearch/pytorch3d" data-count-href="https://github.com/facebookresearch/pytorch3d/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star PyTorch3d on GitHub">pytorch3d</a></div></div></section><a href="https://opensource.facebook.com/" target="_blank" rel="noreferrer noopener" class="fbOpenSource"><img src="/img/oss_logo.png" alt="Facebook Open Source" width="170" height="45"/></a><section class="copyright">Copyright "©" 2020 Facebook Inc</section></footer></div></body></html>
|
131
docs/renderer.html
Normal file
@ -0,0 +1,131 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>renderer · PyTorch3d</title><meta name="viewport" content="width=device-width"/><meta name="generator" content="Docusaurus"/><meta name="description" content="# Rendering Overview"/><meta name="docsearch:language" content="en"/><meta property="og:title" content="renderer · PyTorch3d"/><meta property="og:type" content="website"/><meta property="og:url" content="https://pytorch3d.org/"/><meta property="og:description" content="# Rendering Overview"/><meta property="og:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><meta name="twitter:card" content="summary"/><meta name="twitter:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><link rel="shortcut icon" href="/img/pytorch3dfavicon.png"/><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css"/><script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-157376881-1', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script><script type="text/javascript" src="https://buttons.github.io/buttons.js"></script><script src="/js/scrollSpy.js"></script><link rel="stylesheet" href="/css/main.css"/><script src="/js/codetabs.js"></script></head><body class="sideNavVisible separateOnPageNav"><div class="fixedHeaderContainer"><div class="headerWrapper wrapper"><header><a href="/"><img class="logo" src="/img/pytorch3dfavicon.png" alt="PyTorch3d"/><h2 class="headerTitleWithLogo">PyTorch3d</h2></a><div class="navigationWrapper navigationSlider"><nav class="slidingNav"><ul class="nav-site nav-site-internal"><li class="siteNavGroupActive"><a href="/docs/why_pytorch3d" target="_self">Docs</a></li><li class=""><a href="/tutorials" target="_self">Tutorials</a></li><li class=""><a href="https://pytorch3d.readthedocs.io/" target="_self">API</a></li><li class=""><a href="https://github.com/facebookresearch/pytorch3d" target="_self">GitHub</a></li></ul></nav></div></header></div></div><div class="navPusher"><div class="docMainWrapper wrapper"><div class="docsNavContainer" id="docsNav"><nav class="toc"><div class="toggleNav"><section class="navWrapper wrapper"><div class="navBreadcrumb wrapper"><div class="navToggle" id="navToggler"><div class="hamburger-menu"><div class="line1"></div><div class="line2"></div><div class="line3"></div></div></div><h2><i>›</i><span>Differentiable Renderer</span></h2><div class="tocToggler" id="tocToggler"><i class="icon-toc"></i></div></div><div class="navGroups"><div class="navGroup"><h3 class="navGroupCategoryTitle">Introduction</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/why_pytorch3d">Why PyTorch3d</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Meshes</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/batching">Batching</a></li><li class="navListItem"><a class="navItem" href="/docs/meshes_io">Loading from file</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Differentiable Renderer</h3><ul class=""><li class="navListItem navListItemActive"><a class="navItem" href="/docs/renderer">Overview</a></li><li class="navListItem"><a class="navItem" href="/docs/renderer_getting_started">Getting Started</a></li></ul></div></div></section></div><script>
|
||||
var coll = document.getElementsByClassName('collapsible');
|
||||
var checkActiveCategory = true;
|
||||
for (var i = 0; i < coll.length; i++) {
|
||||
var links = coll[i].nextElementSibling.getElementsByTagName('*');
|
||||
if (checkActiveCategory){
|
||||
for (var j = 0; j < links.length; j++) {
|
||||
if (links[j].classList.contains('navListItemActive')){
|
||||
coll[i].nextElementSibling.classList.toggle('hide');
|
||||
coll[i].childNodes[1].classList.toggle('rotate');
|
||||
checkActiveCategory = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
coll[i].addEventListener('click', function() {
|
||||
var arrow = this.childNodes[1];
|
||||
arrow.classList.toggle('rotate');
|
||||
var content = this.nextElementSibling;
|
||||
content.classList.toggle('hide');
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
createToggler('#navToggler', '#docsNav', 'docsSliderActive');
|
||||
createToggler('#tocToggler', 'body', 'tocActive');
|
||||
|
||||
var headings = document.querySelector('.toc-headings');
|
||||
headings && headings.addEventListener('click', function(event) {
|
||||
var el = event.target;
|
||||
while(el !== headings){
|
||||
if (el.tagName === 'A') {
|
||||
document.body.classList.remove('tocActive');
|
||||
break;
|
||||
} else{
|
||||
el = el.parentNode;
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
|
||||
function createToggler(togglerSelector, targetSelector, className) {
|
||||
var toggler = document.querySelector(togglerSelector);
|
||||
var target = document.querySelector(targetSelector);
|
||||
|
||||
if (!toggler) {
|
||||
return;
|
||||
}
|
||||
|
||||
toggler.onclick = function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
target.classList.toggle(className);
|
||||
};
|
||||
}
|
||||
});
|
||||
</script></nav></div><div class="container mainContainer docsContainer"><div class="wrapper"><div class="post"><header class="postHeader"></header><article><div><span><h1><a class="anchor" aria-hidden="true" id="rendering-overview"></a><a href="#rendering-overview" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Rendering Overview</h1>
|
||||
<p>Differentiable rendering is a relatively new and exciting research area in computer vision, bridging the gap between 2D and 3D by allowing 2D image pixels to be related back to 3D properties of a scene.</p>
|
||||
<p>For example, by rendering an image from a 3D shape predicted by a neural network, it is possible to compute a 2D loss with a reference image. Inverting the rendering step means we can relate the 2D loss from the pixels back to the 3D properties of the shape such as the positions of mesh vertices, enabling 3D shapes to be learnt without any explicit 3D supervision.</p>
|
||||
<p>We extensively researched existing codebases for differentiable rendering and found that:</p>
|
||||
<ul>
|
||||
<li>the rendering pipeline is complex with more than 7 separate components which need to interoperate and be differentiable</li>
|
||||
<li>popular existing approaches [<a href="#1">1</a>, <a href="#2">2</a>] are based on the same core implementation which bundles many of the key components into large CUDA kernels which require significant expertise to understand, and has limited scope for extensions</li>
|
||||
<li>existing methods either do not support batching or assume that meshes in a batch have the same number of vertices and faces</li>
|
||||
<li>existing projects only provide CUDA implementations so they cannot be used without GPUs</li>
|
||||
</ul>
|
||||
<p>In order to experiment with different approaches, we wanted a modular implementation that is easy to use and extend, and supports <a href="/docs/batching">heterogeneous batching</a>.</p>
|
||||
<p>Taking inspiration from existing work [<a href="#1">1</a>, <a href="#2">2</a>], we have created a new, modular, differentiable renderer with <strong>parallel implementations in PyTorch, C++ and CUDA</strong>, as well as comprehensive documentation and tests, with the aim of helping to further research in this field.</p>
|
||||
<p>Our implementation decouples the rasterization and shading steps of rendering. The core rasterization step (based on <a href="#2">[2]</a>) returns several intermediate variables and has an optimized implementation in CUDA. The rest of the pipeline is implemented purely in PyTorch, and is designed to be customized and extended. With this approach, the PyTorch3d differentiable renderer can be imported as a library.</p>
|
||||
<h2><a class="anchor" aria-hidden="true" id="uget-startedu"></a><a href="#uget-startedu" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><u>Get started</u></h2>
|
||||
<p>To learn about more the implementation and start using the renderer refer to <a href="renderer_getting_started.md">/docs/renderer_getting_started</a>, which also contains the <a href="/docs/assets/architecture_overview.png">architecture overview</a> and <a href="/docs/assets/transformations_overview.png">coordinate transformation conventions</a>.</p>
|
||||
<h2><a class="anchor" aria-hidden="true" id="ukey-featuresu"></a><a href="#ukey-featuresu" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><u>Key features</u></h2>
|
||||
<h3><a class="anchor" aria-hidden="true" id="1-cuda-support-for-fast-rasterization-of-large-meshes"></a><a href="#1-cuda-support-for-fast-rasterization-of-large-meshes" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>1. CUDA support for fast rasterization of large meshes</h3>
|
||||
<p>We implemented modular CUDA kernels for the forward and backward pass of rasterization, adaptating a traditional graphics approach known as "coarse-to-fine" rasterization.</p>
|
||||
<p>First, the image is divided into a coarse grid and mesh faces are allocated to the grid cell in which they occur. This is followed by a refinement step which does pixel wise rasterization of the reduced subset of faces per grid cell. The grid cell size is a parameter which can be varied (<code>bin_size</code>).</p>
|
||||
<p>We additionally introduce a parameter <code>faces_per_pixel</code> which allows users to specify the top K faces which should be returned per pixel in the image (as opposed to traditional rasterization which returns only the index of the closest face in the mesh per pixel). The top K face properties can then be aggregated using different methods (such as the sigmoid/softmax approach proposed by Li et at in SoftRasterizer <a href="#2">[2]</a>).</p>
|
||||
<p>We compared PyTorch3d with SoftRasterizer to measure the effect of both these design changes on the speed of rasterization. We selected a set of meshes of different sizes from ShapeNetV1 core, and rasterized one mesh in each batch to produce images of different sizes. We report the speed of the forward and backward passes.</p>
|
||||
<p><strong>Fig 1: PyTorch3d Naive vs Coarse-to-fine</strong></p>
|
||||
<p>This figure shows how the coarse-to-fine strategy for rasterization results in significant speed up compared to naive rasterization for large image size and large mesh sizes.</p>
|
||||
<p><img src="assets/p3d_naive_vs_coarse.png" width="1000"></p>
|
||||
<p>For small mesh and image sizes, the naive approach is slightly faster. We advise that you understand the data you are using and choose the rasterization setting which suits your performance requirements. It is easy to switch between the naive and coarse-to-fine options by adjusting the <code>bin_size</code> value when initializing the <a href="https://github.com/facebookresearch/pytorch3d/blob/master/pytorch3d/renderer/mesh/rasterizer.py#L26">rasterization settings</a>.</p>
|
||||
<p>Setting <code>bin_size = 0</code> will enable naive rasterization. If <code>bin_size > 0</code>, the coarse-to-fine approach is used. The default is <code>bin_size = None</code> in which case we set the bin size based on <a href="https://github.com/facebookresearch/pytorch3d/blob/master/pytorch3d/renderer/mesh/rasterize_meshes.py#L92">heuristics</a>.</p>
|
||||
<p><strong>Fig 2: PyTorch3d Coarse-to-fine vs SoftRasterizer</strong></p>
|
||||
<p>This figure shows the effect of the <em>combination</em> of coarse-to-fine rasterization and caching the faces rasterized per pixel returned from the forward pass. For large meshes and image sizes, we again observe that the PyTorch3d rasterizer is significantly faster, noting that the speed is dominated by the forward pass and the backward pass is very fast.</p>
|
||||
<p>In the SoftRasterizer implementation, in both the forward and backward pass, there is a loop over every single face in the mesh for every pixel in the image. Therefore, the time for the full forward plus backward pass is ~2x the time for the forward pass. For small mesh and image sizes, the SoftRasterizer approach is slightly faster.</p>
|
||||
<p><img src="assets/p3d_vs_softras.png" width="1000"></p>
|
||||
<h3><a class="anchor" aria-hidden="true" id="2-support-for-heterogeneous-batches"></a><a href="#2-support-for-heterogeneous-batches" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>2. Support for Heterogeneous Batches</h3>
|
||||
<p>PyTorch3d supports efficient rendering of batches of meshes where each mesh has different numbers of vertices and faces. This is done without using padded inputs.</p>
|
||||
<p>We again compare with SoftRasterizer which only supports batches of homogeneous meshes and test two cases: 1) a for loop over meshes in the batch, 2) padded inputs, and compare with the native heterogeneous batching support in PyTorch3d.</p>
|
||||
<p>We group meshes from ShapeNet into bins based on the number of faces in the mesh, and sample to compose a batch. We then render images of fixed size and measure the speed of the forward and backward passes.</p>
|
||||
<p>We tested with a range of increasingly large meshes and bin sizes.</p>
|
||||
<p><strong>Fig 3: PyTorch3d heterogeneous batching compared with SoftRasterizer</strong></p>
|
||||
<p><img src="assets/fullset_batch_size_16.png" width="700"/></p>
|
||||
<p>This shows that for large meshes and large bin width (i.e. more variation in mesh size in the batch) the heterogeneous batching approach in PyTorch3d is faster than either of the workarounds with SoftRasterizer.</p>
|
||||
<p>(settings: batch size = 16, mesh sizes in bins ranging from 500-350k faces, image size = 64, faces per pixel = 100)</p>
|
||||
<hr>
|
||||
<p><strong>NOTE: CUDA Memory usage</strong></p>
|
||||
<p>The SoftRasterizer forward CUDA kernel only outputs one <code>(N, H, W, 4)</code> FloatTensor compared with the PyTorch3d rasterizer forward CUDA kernel which outputs 4 tensors:</p>
|
||||
<ul>
|
||||
<li><code>pix_to_face</code>, LongTensor <code>(N, H, W, K)</code></li>
|
||||
<li><code>zbuf</code>, FloatTensor <code>(N, H, W, K)</code></li>
|
||||
<li><code>dist</code>, FloatTensor <code>(N, H, W, K)</code></li>
|
||||
<li><code>bary_coords</code>, FloatTensor <code>(N, H, W, K, 3)</code></li>
|
||||
</ul>
|
||||
<p>where <strong>N</strong> = batch size, <strong>H/W</strong> are image height/width, <strong>K</strong> is the faces per pixel. The PyTorch3d backward pass returns gradients for <code>zbuf</code>, <code>dist</code> and <code>bary_coords</code>.</p>
|
||||
<p>Returning intermediate variables from rasterization has an associated memory cost. We can calculate the theoretical lower bound on the memory usage for the forward and backward pass as follows:</p>
|
||||
<pre><code class="hljs"># Assume <span class="hljs-number">4</span> bytes per <span class="hljs-built_in">float</span>, <span class="hljs-keyword">and</span> <span class="hljs-number">8</span> bytes <span class="hljs-keyword">for</span> long
|
||||
|
||||
memory_forward_pass = ((N * H * W * K) * <span class="hljs-number">2</span> + (N * H * W * K * <span class="hljs-number">3</span>)) * <span class="hljs-number">4</span> + (N * H * W * K) * <span class="hljs-number">8</span>
|
||||
memory_backward_pass = ((N * H * W * K) * <span class="hljs-number">2</span> + (N * H * W * K * <span class="hljs-number">3</span>)) * <span class="hljs-number">4</span>
|
||||
|
||||
total_memory = memory_forward_pass + memory_backward_pass
|
||||
= (N * H * W * K) * (<span class="hljs-number">5</span> * <span class="hljs-number">4</span> * <span class="hljs-number">2</span> + <span class="hljs-number">8</span>)
|
||||
= (N * H * W * K) * <span class="hljs-number">48</span>
|
||||
</code></pre>
|
||||
<p>We need 48 bytes per face per pixel of the rasterized output. In order to remain within bounds for memory usage we can vary the batch size (<strong>N</strong>), image size (<strong>H/W</strong>) and faces per pixel (<strong>K</strong>). For example, for a fixed batch size, if using a larger image size, try reducing the faces per pixel.</p>
|
||||
<hr>
|
||||
<h3><a class="anchor" aria-hidden="true" id="3-modular-design-for-easy-experimentation-and-extensibility"></a><a href="#3-modular-design-for-easy-experimentation-and-extensibility" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>3. Modular design for easy experimentation and extensibility.</h3>
|
||||
<p>We redesigned the rendering pipeline from the ground up to be modular and extensible and challenged many of the limitations in existing libraries. Refer to <a href="renderer_getting_started.md">/docs/renderer_getting_started</a> for a detailed description of the architecture.</p>
|
||||
<h3><a class="anchor" aria-hidden="true" id="references"></a><a href="#references" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>References</h3>
|
||||
<p><a id="1">[1]</a> Kato et al, 'Neural 3D Mesh Renderer', CVPR 2018</p>
|
||||
<p><a id="2">[2]</a> Liu et al, 'Soft Rasterizer: A Differentiable Renderer for Image-based 3D Reasoning', ICCV 2019</p>
|
||||
</span></div></article></div><div class="docLastUpdate"><em>Last updated by Nikhila Ravi</em></div><div class="docs-prevnext"><a class="docs-prev button" href="/docs/meshes_io"><span class="arrow-prev">← </span><span>Loading from file</span></a><a class="docs-next button" href="/docs/renderer_getting_started"><span>Getting Started</span><span class="arrow-next"> →</span></a></div></div></div><nav class="onPageNav"><ul class="toc-headings"><li><a href="#uget-startedu"><u>Get started</u></a></li><li><a href="#ukey-featuresu"><u>Key features</u></a><ul class="toc-headings"><li><a href="#1-cuda-support-for-fast-rasterization-of-large-meshes">1. CUDA support for fast rasterization of large meshes</a></li><li><a href="#2-support-for-heterogeneous-batches">2. Support for Heterogeneous Batches</a></li><li><a href="#3-modular-design-for-easy-experimentation-and-extensibility">3. Modular design for easy experimentation and extensibility.</a></li><li><a href="#references">References</a></li></ul></li></ul></nav></div><footer class="nav-footer" id="footer"><section class="sitemap"><div class="footerSection"><div class="social"><a class="github-button" href="https://github.com/facebookresearch/pytorch3d" data-count-href="https://github.com/facebookresearch/pytorch3d/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star PyTorch3d on GitHub">pytorch3d</a></div></div></section><a href="https://opensource.facebook.com/" target="_blank" rel="noreferrer noopener" class="fbOpenSource"><img src="/img/oss_logo.png" alt="Facebook Open Source" width="170" height="45"/></a><section class="copyright">Copyright "©" 2020 Facebook Inc</section></footer></div></body></html>
|
131
docs/renderer/index.html
Normal file
@ -0,0 +1,131 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>renderer · PyTorch3d</title><meta name="viewport" content="width=device-width"/><meta name="generator" content="Docusaurus"/><meta name="description" content="# Rendering Overview"/><meta name="docsearch:language" content="en"/><meta property="og:title" content="renderer · PyTorch3d"/><meta property="og:type" content="website"/><meta property="og:url" content="https://pytorch3d.org/"/><meta property="og:description" content="# Rendering Overview"/><meta property="og:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><meta name="twitter:card" content="summary"/><meta name="twitter:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><link rel="shortcut icon" href="/img/pytorch3dfavicon.png"/><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css"/><script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-157376881-1', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script><script type="text/javascript" src="https://buttons.github.io/buttons.js"></script><script src="/js/scrollSpy.js"></script><link rel="stylesheet" href="/css/main.css"/><script src="/js/codetabs.js"></script></head><body class="sideNavVisible separateOnPageNav"><div class="fixedHeaderContainer"><div class="headerWrapper wrapper"><header><a href="/"><img class="logo" src="/img/pytorch3dfavicon.png" alt="PyTorch3d"/><h2 class="headerTitleWithLogo">PyTorch3d</h2></a><div class="navigationWrapper navigationSlider"><nav class="slidingNav"><ul class="nav-site nav-site-internal"><li class="siteNavGroupActive"><a href="/docs/why_pytorch3d" target="_self">Docs</a></li><li class=""><a href="/tutorials" target="_self">Tutorials</a></li><li class=""><a href="https://pytorch3d.readthedocs.io/" target="_self">API</a></li><li class=""><a href="https://github.com/facebookresearch/pytorch3d" target="_self">GitHub</a></li></ul></nav></div></header></div></div><div class="navPusher"><div class="docMainWrapper wrapper"><div class="docsNavContainer" id="docsNav"><nav class="toc"><div class="toggleNav"><section class="navWrapper wrapper"><div class="navBreadcrumb wrapper"><div class="navToggle" id="navToggler"><div class="hamburger-menu"><div class="line1"></div><div class="line2"></div><div class="line3"></div></div></div><h2><i>›</i><span>Differentiable Renderer</span></h2><div class="tocToggler" id="tocToggler"><i class="icon-toc"></i></div></div><div class="navGroups"><div class="navGroup"><h3 class="navGroupCategoryTitle">Introduction</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/why_pytorch3d">Why PyTorch3d</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Meshes</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/batching">Batching</a></li><li class="navListItem"><a class="navItem" href="/docs/meshes_io">Loading from file</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Differentiable Renderer</h3><ul class=""><li class="navListItem navListItemActive"><a class="navItem" href="/docs/renderer">Overview</a></li><li class="navListItem"><a class="navItem" href="/docs/renderer_getting_started">Getting Started</a></li></ul></div></div></section></div><script>
|
||||
var coll = document.getElementsByClassName('collapsible');
|
||||
var checkActiveCategory = true;
|
||||
for (var i = 0; i < coll.length; i++) {
|
||||
var links = coll[i].nextElementSibling.getElementsByTagName('*');
|
||||
if (checkActiveCategory){
|
||||
for (var j = 0; j < links.length; j++) {
|
||||
if (links[j].classList.contains('navListItemActive')){
|
||||
coll[i].nextElementSibling.classList.toggle('hide');
|
||||
coll[i].childNodes[1].classList.toggle('rotate');
|
||||
checkActiveCategory = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
coll[i].addEventListener('click', function() {
|
||||
var arrow = this.childNodes[1];
|
||||
arrow.classList.toggle('rotate');
|
||||
var content = this.nextElementSibling;
|
||||
content.classList.toggle('hide');
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
createToggler('#navToggler', '#docsNav', 'docsSliderActive');
|
||||
createToggler('#tocToggler', 'body', 'tocActive');
|
||||
|
||||
var headings = document.querySelector('.toc-headings');
|
||||
headings && headings.addEventListener('click', function(event) {
|
||||
var el = event.target;
|
||||
while(el !== headings){
|
||||
if (el.tagName === 'A') {
|
||||
document.body.classList.remove('tocActive');
|
||||
break;
|
||||
} else{
|
||||
el = el.parentNode;
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
|
||||
function createToggler(togglerSelector, targetSelector, className) {
|
||||
var toggler = document.querySelector(togglerSelector);
|
||||
var target = document.querySelector(targetSelector);
|
||||
|
||||
if (!toggler) {
|
||||
return;
|
||||
}
|
||||
|
||||
toggler.onclick = function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
target.classList.toggle(className);
|
||||
};
|
||||
}
|
||||
});
|
||||
</script></nav></div><div class="container mainContainer docsContainer"><div class="wrapper"><div class="post"><header class="postHeader"></header><article><div><span><h1><a class="anchor" aria-hidden="true" id="rendering-overview"></a><a href="#rendering-overview" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Rendering Overview</h1>
|
||||
<p>Differentiable rendering is a relatively new and exciting research area in computer vision, bridging the gap between 2D and 3D by allowing 2D image pixels to be related back to 3D properties of a scene.</p>
|
||||
<p>For example, by rendering an image from a 3D shape predicted by a neural network, it is possible to compute a 2D loss with a reference image. Inverting the rendering step means we can relate the 2D loss from the pixels back to the 3D properties of the shape such as the positions of mesh vertices, enabling 3D shapes to be learnt without any explicit 3D supervision.</p>
|
||||
<p>We extensively researched existing codebases for differentiable rendering and found that:</p>
|
||||
<ul>
|
||||
<li>the rendering pipeline is complex with more than 7 separate components which need to interoperate and be differentiable</li>
|
||||
<li>popular existing approaches [<a href="#1">1</a>, <a href="#2">2</a>] are based on the same core implementation which bundles many of the key components into large CUDA kernels which require significant expertise to understand, and has limited scope for extensions</li>
|
||||
<li>existing methods either do not support batching or assume that meshes in a batch have the same number of vertices and faces</li>
|
||||
<li>existing projects only provide CUDA implementations so they cannot be used without GPUs</li>
|
||||
</ul>
|
||||
<p>In order to experiment with different approaches, we wanted a modular implementation that is easy to use and extend, and supports <a href="/docs/batching">heterogeneous batching</a>.</p>
|
||||
<p>Taking inspiration from existing work [<a href="#1">1</a>, <a href="#2">2</a>], we have created a new, modular, differentiable renderer with <strong>parallel implementations in PyTorch, C++ and CUDA</strong>, as well as comprehensive documentation and tests, with the aim of helping to further research in this field.</p>
|
||||
<p>Our implementation decouples the rasterization and shading steps of rendering. The core rasterization step (based on <a href="#2">[2]</a>) returns several intermediate variables and has an optimized implementation in CUDA. The rest of the pipeline is implemented purely in PyTorch, and is designed to be customized and extended. With this approach, the PyTorch3d differentiable renderer can be imported as a library.</p>
|
||||
<h2><a class="anchor" aria-hidden="true" id="uget-startedu"></a><a href="#uget-startedu" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><u>Get started</u></h2>
|
||||
<p>To learn about more the implementation and start using the renderer refer to <a href="renderer_getting_started.md">/docs/renderer_getting_started</a>, which also contains the <a href="/docs/assets/architecture_overview.png">architecture overview</a> and <a href="/docs/assets/transformations_overview.png">coordinate transformation conventions</a>.</p>
|
||||
<h2><a class="anchor" aria-hidden="true" id="ukey-featuresu"></a><a href="#ukey-featuresu" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a><u>Key features</u></h2>
|
||||
<h3><a class="anchor" aria-hidden="true" id="1-cuda-support-for-fast-rasterization-of-large-meshes"></a><a href="#1-cuda-support-for-fast-rasterization-of-large-meshes" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>1. CUDA support for fast rasterization of large meshes</h3>
|
||||
<p>We implemented modular CUDA kernels for the forward and backward pass of rasterization, adaptating a traditional graphics approach known as "coarse-to-fine" rasterization.</p>
|
||||
<p>First, the image is divided into a coarse grid and mesh faces are allocated to the grid cell in which they occur. This is followed by a refinement step which does pixel wise rasterization of the reduced subset of faces per grid cell. The grid cell size is a parameter which can be varied (<code>bin_size</code>).</p>
|
||||
<p>We additionally introduce a parameter <code>faces_per_pixel</code> which allows users to specify the top K faces which should be returned per pixel in the image (as opposed to traditional rasterization which returns only the index of the closest face in the mesh per pixel). The top K face properties can then be aggregated using different methods (such as the sigmoid/softmax approach proposed by Li et at in SoftRasterizer <a href="#2">[2]</a>).</p>
|
||||
<p>We compared PyTorch3d with SoftRasterizer to measure the effect of both these design changes on the speed of rasterization. We selected a set of meshes of different sizes from ShapeNetV1 core, and rasterized one mesh in each batch to produce images of different sizes. We report the speed of the forward and backward passes.</p>
|
||||
<p><strong>Fig 1: PyTorch3d Naive vs Coarse-to-fine</strong></p>
|
||||
<p>This figure shows how the coarse-to-fine strategy for rasterization results in significant speed up compared to naive rasterization for large image size and large mesh sizes.</p>
|
||||
<p><img src="assets/p3d_naive_vs_coarse.png" width="1000"></p>
|
||||
<p>For small mesh and image sizes, the naive approach is slightly faster. We advise that you understand the data you are using and choose the rasterization setting which suits your performance requirements. It is easy to switch between the naive and coarse-to-fine options by adjusting the <code>bin_size</code> value when initializing the <a href="https://github.com/facebookresearch/pytorch3d/blob/master/pytorch3d/renderer/mesh/rasterizer.py#L26">rasterization settings</a>.</p>
|
||||
<p>Setting <code>bin_size = 0</code> will enable naive rasterization. If <code>bin_size > 0</code>, the coarse-to-fine approach is used. The default is <code>bin_size = None</code> in which case we set the bin size based on <a href="https://github.com/facebookresearch/pytorch3d/blob/master/pytorch3d/renderer/mesh/rasterize_meshes.py#L92">heuristics</a>.</p>
|
||||
<p><strong>Fig 2: PyTorch3d Coarse-to-fine vs SoftRasterizer</strong></p>
|
||||
<p>This figure shows the effect of the <em>combination</em> of coarse-to-fine rasterization and caching the faces rasterized per pixel returned from the forward pass. For large meshes and image sizes, we again observe that the PyTorch3d rasterizer is significantly faster, noting that the speed is dominated by the forward pass and the backward pass is very fast.</p>
|
||||
<p>In the SoftRasterizer implementation, in both the forward and backward pass, there is a loop over every single face in the mesh for every pixel in the image. Therefore, the time for the full forward plus backward pass is ~2x the time for the forward pass. For small mesh and image sizes, the SoftRasterizer approach is slightly faster.</p>
|
||||
<p><img src="assets/p3d_vs_softras.png" width="1000"></p>
|
||||
<h3><a class="anchor" aria-hidden="true" id="2-support-for-heterogeneous-batches"></a><a href="#2-support-for-heterogeneous-batches" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>2. Support for Heterogeneous Batches</h3>
|
||||
<p>PyTorch3d supports efficient rendering of batches of meshes where each mesh has different numbers of vertices and faces. This is done without using padded inputs.</p>
|
||||
<p>We again compare with SoftRasterizer which only supports batches of homogeneous meshes and test two cases: 1) a for loop over meshes in the batch, 2) padded inputs, and compare with the native heterogeneous batching support in PyTorch3d.</p>
|
||||
<p>We group meshes from ShapeNet into bins based on the number of faces in the mesh, and sample to compose a batch. We then render images of fixed size and measure the speed of the forward and backward passes.</p>
|
||||
<p>We tested with a range of increasingly large meshes and bin sizes.</p>
|
||||
<p><strong>Fig 3: PyTorch3d heterogeneous batching compared with SoftRasterizer</strong></p>
|
||||
<p><img src="assets/fullset_batch_size_16.png" width="700"/></p>
|
||||
<p>This shows that for large meshes and large bin width (i.e. more variation in mesh size in the batch) the heterogeneous batching approach in PyTorch3d is faster than either of the workarounds with SoftRasterizer.</p>
|
||||
<p>(settings: batch size = 16, mesh sizes in bins ranging from 500-350k faces, image size = 64, faces per pixel = 100)</p>
|
||||
<hr>
|
||||
<p><strong>NOTE: CUDA Memory usage</strong></p>
|
||||
<p>The SoftRasterizer forward CUDA kernel only outputs one <code>(N, H, W, 4)</code> FloatTensor compared with the PyTorch3d rasterizer forward CUDA kernel which outputs 4 tensors:</p>
|
||||
<ul>
|
||||
<li><code>pix_to_face</code>, LongTensor <code>(N, H, W, K)</code></li>
|
||||
<li><code>zbuf</code>, FloatTensor <code>(N, H, W, K)</code></li>
|
||||
<li><code>dist</code>, FloatTensor <code>(N, H, W, K)</code></li>
|
||||
<li><code>bary_coords</code>, FloatTensor <code>(N, H, W, K, 3)</code></li>
|
||||
</ul>
|
||||
<p>where <strong>N</strong> = batch size, <strong>H/W</strong> are image height/width, <strong>K</strong> is the faces per pixel. The PyTorch3d backward pass returns gradients for <code>zbuf</code>, <code>dist</code> and <code>bary_coords</code>.</p>
|
||||
<p>Returning intermediate variables from rasterization has an associated memory cost. We can calculate the theoretical lower bound on the memory usage for the forward and backward pass as follows:</p>
|
||||
<pre><code class="hljs"># Assume <span class="hljs-number">4</span> bytes per <span class="hljs-built_in">float</span>, <span class="hljs-keyword">and</span> <span class="hljs-number">8</span> bytes <span class="hljs-keyword">for</span> long
|
||||
|
||||
memory_forward_pass = ((N * H * W * K) * <span class="hljs-number">2</span> + (N * H * W * K * <span class="hljs-number">3</span>)) * <span class="hljs-number">4</span> + (N * H * W * K) * <span class="hljs-number">8</span>
|
||||
memory_backward_pass = ((N * H * W * K) * <span class="hljs-number">2</span> + (N * H * W * K * <span class="hljs-number">3</span>)) * <span class="hljs-number">4</span>
|
||||
|
||||
total_memory = memory_forward_pass + memory_backward_pass
|
||||
= (N * H * W * K) * (<span class="hljs-number">5</span> * <span class="hljs-number">4</span> * <span class="hljs-number">2</span> + <span class="hljs-number">8</span>)
|
||||
= (N * H * W * K) * <span class="hljs-number">48</span>
|
||||
</code></pre>
|
||||
<p>We need 48 bytes per face per pixel of the rasterized output. In order to remain within bounds for memory usage we can vary the batch size (<strong>N</strong>), image size (<strong>H/W</strong>) and faces per pixel (<strong>K</strong>). For example, for a fixed batch size, if using a larger image size, try reducing the faces per pixel.</p>
|
||||
<hr>
|
||||
<h3><a class="anchor" aria-hidden="true" id="3-modular-design-for-easy-experimentation-and-extensibility"></a><a href="#3-modular-design-for-easy-experimentation-and-extensibility" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>3. Modular design for easy experimentation and extensibility.</h3>
|
||||
<p>We redesigned the rendering pipeline from the ground up to be modular and extensible and challenged many of the limitations in existing libraries. Refer to <a href="renderer_getting_started.md">/docs/renderer_getting_started</a> for a detailed description of the architecture.</p>
|
||||
<h3><a class="anchor" aria-hidden="true" id="references"></a><a href="#references" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>References</h3>
|
||||
<p><a id="1">[1]</a> Kato et al, 'Neural 3D Mesh Renderer', CVPR 2018</p>
|
||||
<p><a id="2">[2]</a> Liu et al, 'Soft Rasterizer: A Differentiable Renderer for Image-based 3D Reasoning', ICCV 2019</p>
|
||||
</span></div></article></div><div class="docLastUpdate"><em>Last updated by Nikhila Ravi</em></div><div class="docs-prevnext"><a class="docs-prev button" href="/docs/meshes_io"><span class="arrow-prev">← </span><span>Loading from file</span></a><a class="docs-next button" href="/docs/renderer_getting_started"><span>Getting Started</span><span class="arrow-next"> →</span></a></div></div></div><nav class="onPageNav"><ul class="toc-headings"><li><a href="#uget-startedu"><u>Get started</u></a></li><li><a href="#ukey-featuresu"><u>Key features</u></a><ul class="toc-headings"><li><a href="#1-cuda-support-for-fast-rasterization-of-large-meshes">1. CUDA support for fast rasterization of large meshes</a></li><li><a href="#2-support-for-heterogeneous-batches">2. Support for Heterogeneous Batches</a></li><li><a href="#3-modular-design-for-easy-experimentation-and-extensibility">3. Modular design for easy experimentation and extensibility.</a></li><li><a href="#references">References</a></li></ul></li></ul></nav></div><footer class="nav-footer" id="footer"><section class="sitemap"><div class="footerSection"><div class="social"><a class="github-button" href="https://github.com/facebookresearch/pytorch3d" data-count-href="https://github.com/facebookresearch/pytorch3d/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star PyTorch3d on GitHub">pytorch3d</a></div></div></section><a href="https://opensource.facebook.com/" target="_blank" rel="noreferrer noopener" class="fbOpenSource"><img src="/img/oss_logo.png" alt="Facebook Open Source" width="170" height="45"/></a><section class="copyright">Copyright "©" 2020 Facebook Inc</section></footer></div></body></html>
|
122
docs/renderer_getting_started.html
Normal file
@ -0,0 +1,122 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>renderer_getting_started · PyTorch3d</title><meta name="viewport" content="width=device-width"/><meta name="generator" content="Docusaurus"/><meta name="description" content="# Renderer Getting Started"/><meta name="docsearch:language" content="en"/><meta property="og:title" content="renderer_getting_started · PyTorch3d"/><meta property="og:type" content="website"/><meta property="og:url" content="https://pytorch3d.org/"/><meta property="og:description" content="# Renderer Getting Started"/><meta property="og:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><meta name="twitter:card" content="summary"/><meta name="twitter:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><link rel="shortcut icon" href="/img/pytorch3dfavicon.png"/><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css"/><script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-157376881-1', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script><script type="text/javascript" src="https://buttons.github.io/buttons.js"></script><script src="/js/scrollSpy.js"></script><link rel="stylesheet" href="/css/main.css"/><script src="/js/codetabs.js"></script></head><body class="sideNavVisible separateOnPageNav"><div class="fixedHeaderContainer"><div class="headerWrapper wrapper"><header><a href="/"><img class="logo" src="/img/pytorch3dfavicon.png" alt="PyTorch3d"/><h2 class="headerTitleWithLogo">PyTorch3d</h2></a><div class="navigationWrapper navigationSlider"><nav class="slidingNav"><ul class="nav-site nav-site-internal"><li class="siteNavGroupActive"><a href="/docs/why_pytorch3d" target="_self">Docs</a></li><li class=""><a href="/tutorials" target="_self">Tutorials</a></li><li class=""><a href="https://pytorch3d.readthedocs.io/" target="_self">API</a></li><li class=""><a href="https://github.com/facebookresearch/pytorch3d" target="_self">GitHub</a></li></ul></nav></div></header></div></div><div class="navPusher"><div class="docMainWrapper wrapper"><div class="docsNavContainer" id="docsNav"><nav class="toc"><div class="toggleNav"><section class="navWrapper wrapper"><div class="navBreadcrumb wrapper"><div class="navToggle" id="navToggler"><div class="hamburger-menu"><div class="line1"></div><div class="line2"></div><div class="line3"></div></div></div><h2><i>›</i><span>Differentiable Renderer</span></h2><div class="tocToggler" id="tocToggler"><i class="icon-toc"></i></div></div><div class="navGroups"><div class="navGroup"><h3 class="navGroupCategoryTitle">Introduction</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/why_pytorch3d">Why PyTorch3d</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Meshes</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/batching">Batching</a></li><li class="navListItem"><a class="navItem" href="/docs/meshes_io">Loading from file</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Differentiable Renderer</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/renderer">Overview</a></li><li class="navListItem navListItemActive"><a class="navItem" href="/docs/renderer_getting_started">Getting Started</a></li></ul></div></div></section></div><script>
|
||||
var coll = document.getElementsByClassName('collapsible');
|
||||
var checkActiveCategory = true;
|
||||
for (var i = 0; i < coll.length; i++) {
|
||||
var links = coll[i].nextElementSibling.getElementsByTagName('*');
|
||||
if (checkActiveCategory){
|
||||
for (var j = 0; j < links.length; j++) {
|
||||
if (links[j].classList.contains('navListItemActive')){
|
||||
coll[i].nextElementSibling.classList.toggle('hide');
|
||||
coll[i].childNodes[1].classList.toggle('rotate');
|
||||
checkActiveCategory = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
coll[i].addEventListener('click', function() {
|
||||
var arrow = this.childNodes[1];
|
||||
arrow.classList.toggle('rotate');
|
||||
var content = this.nextElementSibling;
|
||||
content.classList.toggle('hide');
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
createToggler('#navToggler', '#docsNav', 'docsSliderActive');
|
||||
createToggler('#tocToggler', 'body', 'tocActive');
|
||||
|
||||
var headings = document.querySelector('.toc-headings');
|
||||
headings && headings.addEventListener('click', function(event) {
|
||||
var el = event.target;
|
||||
while(el !== headings){
|
||||
if (el.tagName === 'A') {
|
||||
document.body.classList.remove('tocActive');
|
||||
break;
|
||||
} else{
|
||||
el = el.parentNode;
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
|
||||
function createToggler(togglerSelector, targetSelector, className) {
|
||||
var toggler = document.querySelector(togglerSelector);
|
||||
var target = document.querySelector(targetSelector);
|
||||
|
||||
if (!toggler) {
|
||||
return;
|
||||
}
|
||||
|
||||
toggler.onclick = function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
target.classList.toggle(className);
|
||||
};
|
||||
}
|
||||
});
|
||||
</script></nav></div><div class="container mainContainer docsContainer"><div class="wrapper"><div class="post"><header class="postHeader"></header><article><div><span><h1><a class="anchor" aria-hidden="true" id="renderer-getting-started"></a><a href="#renderer-getting-started" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Renderer Getting Started</h1>
|
||||
<h3><a class="anchor" aria-hidden="true" id="architecture-overview"></a><a href="#architecture-overview" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Architecture Overview</h3>
|
||||
<p>The renderer is designed to be modular, extensible and support batching and gradients for all inputs. The following figure describes all the components of the rendering pipeline.</p>
|
||||
<p><img src="assets/architecture_overview.png" width="1000"></p>
|
||||
<h5><a class="anchor" aria-hidden="true" id="fragments"></a><a href="#fragments" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Fragments</h5>
|
||||
<p>The <strong>rasterizer</strong> returns 4 output tensors in a named tuple.</p>
|
||||
<ul>
|
||||
<li><strong><code>pix_to_face</code></strong>: LongTensor of shape <code>(N, image_size, image_size, faces_per_pixel)</code> specifying the indices of the faces (in the packed faces) which overlap each pixel in the image.</li>
|
||||
<li><strong><code>zbuf</code></strong>: FloatTensor of shape <code>(N, image_size, image_size, faces_per_pixel)</code> giving the z-coordinates of the nearest faces at each pixel in world coordinates, sorted in ascending z-order.</li>
|
||||
<li><strong><code>bary_coords</code></strong>: FloatTensor of shape <code>(N, image_size, image_size, faces_per_pixel, 3)</code>
|
||||
giving the barycentric coordinates in NDC units of the nearest faces at each pixel, sorted in ascending z-order.</li>
|
||||
<li><strong><code>pix_dists</code></strong>: FloatTensor of shape <code>(N, image_size, image_size, faces_per_pixel)</code> giving the signed Euclidean distance (in NDC units) in the x/y plane of each point closest to the pixel.</li>
|
||||
</ul>
|
||||
<p>See the renderer API reference for more details about each component in the pipeline.</p>
|
||||
<hr>
|
||||
<p><strong>NOTE:</strong></p>
|
||||
<p>The differentiable renderer API is experimental and subject to change!.</p>
|
||||
<hr>
|
||||
<h3><a class="anchor" aria-hidden="true" id="coordinate-transformation-conventions"></a><a href="#coordinate-transformation-conventions" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Coordinate transformation conventions</h3>
|
||||
<p>Rendering requires transformations between several different coordinate frames: world space, view/camera space, NDC space and screen space. At each step it is important to know where the camera is located, how the x,y,z axes are aligned and the possible range of values. The following figure outlines the conventions used PyTorch3d.</p>
|
||||
<p><img src="assets/transformations_overview.png" width="1000"></p>
|
||||
<hr>
|
||||
<p><strong>NOTE: PyTorch3d vs OpenGL</strong></p>
|
||||
<p>While we tried to emulate several aspects of OpenGL, the NDC coordinate system in PyTorch3d is <strong>right-handed</strong> compared with a <strong>left-handed</strong> NDC coordinate system in OpenGL (the projection matrix switches the handedness).</p>
|
||||
<p>In OpenGL, the camera at the origin is looking along <code>-z</code> axis in camera space, but it is looking along the <code>+z</code> axis in NDC space.</p>
|
||||
<p><img align="center" src="assets/opengl_coordframes.png" width="300"></p>
|
||||
<hr>
|
||||
<h3><a class="anchor" aria-hidden="true" id="a-simple-renderer"></a><a href="#a-simple-renderer" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>A simple renderer</h3>
|
||||
<p>A renderer in PyTorch3d is composed of a <strong>rasterizer</strong> and a <strong>shader</strong>. Create a renderer in a few simple steps:</p>
|
||||
<pre><code class="hljs"><span class="hljs-comment"># Imports</span>
|
||||
<span class="hljs-keyword">from</span> pytorch3d.renderer import (
|
||||
OpenGLPerspectiveCameras, look_at_view_transform,
|
||||
RasterizationSettings, BlendParams,
|
||||
MeshRenderer, MeshRasterizer, PhongShader
|
||||
)
|
||||
|
||||
<span class="hljs-comment"># Initialize an OpenGL perspective camera.</span>
|
||||
R, T = look_at_view_transform(2.7, 10, 20)
|
||||
cameras = OpenGLPerspectiveCameras(<span class="hljs-attribute">device</span>=device, <span class="hljs-attribute">R</span>=R, <span class="hljs-attribute">T</span>=T)
|
||||
|
||||
<span class="hljs-comment"># Define the settings for rasterization and shading. Here we set the output image to be of size</span>
|
||||
<span class="hljs-comment"># 512x512. As we are rendering images for visualization purposes only we will set faces_per_pixel=1</span>
|
||||
<span class="hljs-comment"># and blur_radius=0.0. Refer to rasterize_meshes.py for explanations of these parameters.</span>
|
||||
raster_settings = RasterizationSettings(
|
||||
<span class="hljs-attribute">image_size</span>=512,
|
||||
<span class="hljs-attribute">blur_radius</span>=0.0,
|
||||
<span class="hljs-attribute">faces_per_pixel</span>=1,
|
||||
<span class="hljs-attribute">bin_size</span>=0
|
||||
)
|
||||
|
||||
<span class="hljs-comment"># Create a phong renderer by composing a rasterizer and a shader. Here we can use a predefined</span>
|
||||
<span class="hljs-comment"># PhongShader, passing in the device on which to initialize the default parameters</span>
|
||||
renderer = MeshRenderer(
|
||||
<span class="hljs-attribute">rasterizer</span>=MeshRasterizer(cameras=cameras, <span class="hljs-attribute">raster_settings</span>=raster_settings),
|
||||
<span class="hljs-attribute">shader</span>=PhongShader(device=device, <span class="hljs-attribute">cameras</span>=cameras)
|
||||
)
|
||||
</code></pre>
|
||||
</span></div></article></div><div class="docLastUpdate"><em>Last updated by Nikhila Ravi</em></div><div class="docs-prevnext"><a class="docs-prev button" href="/docs/renderer"><span class="arrow-prev">← </span><span>Overview</span></a></div></div></div><nav class="onPageNav"></nav></div><footer class="nav-footer" id="footer"><section class="sitemap"><div class="footerSection"><div class="social"><a class="github-button" href="https://github.com/facebookresearch/pytorch3d" data-count-href="https://github.com/facebookresearch/pytorch3d/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star PyTorch3d on GitHub">pytorch3d</a></div></div></section><a href="https://opensource.facebook.com/" target="_blank" rel="noreferrer noopener" class="fbOpenSource"><img src="/img/oss_logo.png" alt="Facebook Open Source" width="170" height="45"/></a><section class="copyright">Copyright "©" 2020 Facebook Inc</section></footer></div></body></html>
|
122
docs/renderer_getting_started/index.html
Normal file
@ -0,0 +1,122 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>renderer_getting_started · PyTorch3d</title><meta name="viewport" content="width=device-width"/><meta name="generator" content="Docusaurus"/><meta name="description" content="# Renderer Getting Started"/><meta name="docsearch:language" content="en"/><meta property="og:title" content="renderer_getting_started · PyTorch3d"/><meta property="og:type" content="website"/><meta property="og:url" content="https://pytorch3d.org/"/><meta property="og:description" content="# Renderer Getting Started"/><meta property="og:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><meta name="twitter:card" content="summary"/><meta name="twitter:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><link rel="shortcut icon" href="/img/pytorch3dfavicon.png"/><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css"/><script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-157376881-1', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script><script type="text/javascript" src="https://buttons.github.io/buttons.js"></script><script src="/js/scrollSpy.js"></script><link rel="stylesheet" href="/css/main.css"/><script src="/js/codetabs.js"></script></head><body class="sideNavVisible separateOnPageNav"><div class="fixedHeaderContainer"><div class="headerWrapper wrapper"><header><a href="/"><img class="logo" src="/img/pytorch3dfavicon.png" alt="PyTorch3d"/><h2 class="headerTitleWithLogo">PyTorch3d</h2></a><div class="navigationWrapper navigationSlider"><nav class="slidingNav"><ul class="nav-site nav-site-internal"><li class="siteNavGroupActive"><a href="/docs/why_pytorch3d" target="_self">Docs</a></li><li class=""><a href="/tutorials" target="_self">Tutorials</a></li><li class=""><a href="https://pytorch3d.readthedocs.io/" target="_self">API</a></li><li class=""><a href="https://github.com/facebookresearch/pytorch3d" target="_self">GitHub</a></li></ul></nav></div></header></div></div><div class="navPusher"><div class="docMainWrapper wrapper"><div class="docsNavContainer" id="docsNav"><nav class="toc"><div class="toggleNav"><section class="navWrapper wrapper"><div class="navBreadcrumb wrapper"><div class="navToggle" id="navToggler"><div class="hamburger-menu"><div class="line1"></div><div class="line2"></div><div class="line3"></div></div></div><h2><i>›</i><span>Differentiable Renderer</span></h2><div class="tocToggler" id="tocToggler"><i class="icon-toc"></i></div></div><div class="navGroups"><div class="navGroup"><h3 class="navGroupCategoryTitle">Introduction</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/why_pytorch3d">Why PyTorch3d</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Meshes</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/batching">Batching</a></li><li class="navListItem"><a class="navItem" href="/docs/meshes_io">Loading from file</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Differentiable Renderer</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/renderer">Overview</a></li><li class="navListItem navListItemActive"><a class="navItem" href="/docs/renderer_getting_started">Getting Started</a></li></ul></div></div></section></div><script>
|
||||
var coll = document.getElementsByClassName('collapsible');
|
||||
var checkActiveCategory = true;
|
||||
for (var i = 0; i < coll.length; i++) {
|
||||
var links = coll[i].nextElementSibling.getElementsByTagName('*');
|
||||
if (checkActiveCategory){
|
||||
for (var j = 0; j < links.length; j++) {
|
||||
if (links[j].classList.contains('navListItemActive')){
|
||||
coll[i].nextElementSibling.classList.toggle('hide');
|
||||
coll[i].childNodes[1].classList.toggle('rotate');
|
||||
checkActiveCategory = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
coll[i].addEventListener('click', function() {
|
||||
var arrow = this.childNodes[1];
|
||||
arrow.classList.toggle('rotate');
|
||||
var content = this.nextElementSibling;
|
||||
content.classList.toggle('hide');
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
createToggler('#navToggler', '#docsNav', 'docsSliderActive');
|
||||
createToggler('#tocToggler', 'body', 'tocActive');
|
||||
|
||||
var headings = document.querySelector('.toc-headings');
|
||||
headings && headings.addEventListener('click', function(event) {
|
||||
var el = event.target;
|
||||
while(el !== headings){
|
||||
if (el.tagName === 'A') {
|
||||
document.body.classList.remove('tocActive');
|
||||
break;
|
||||
} else{
|
||||
el = el.parentNode;
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
|
||||
function createToggler(togglerSelector, targetSelector, className) {
|
||||
var toggler = document.querySelector(togglerSelector);
|
||||
var target = document.querySelector(targetSelector);
|
||||
|
||||
if (!toggler) {
|
||||
return;
|
||||
}
|
||||
|
||||
toggler.onclick = function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
target.classList.toggle(className);
|
||||
};
|
||||
}
|
||||
});
|
||||
</script></nav></div><div class="container mainContainer docsContainer"><div class="wrapper"><div class="post"><header class="postHeader"></header><article><div><span><h1><a class="anchor" aria-hidden="true" id="renderer-getting-started"></a><a href="#renderer-getting-started" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Renderer Getting Started</h1>
|
||||
<h3><a class="anchor" aria-hidden="true" id="architecture-overview"></a><a href="#architecture-overview" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Architecture Overview</h3>
|
||||
<p>The renderer is designed to be modular, extensible and support batching and gradients for all inputs. The following figure describes all the components of the rendering pipeline.</p>
|
||||
<p><img src="assets/architecture_overview.png" width="1000"></p>
|
||||
<h5><a class="anchor" aria-hidden="true" id="fragments"></a><a href="#fragments" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Fragments</h5>
|
||||
<p>The <strong>rasterizer</strong> returns 4 output tensors in a named tuple.</p>
|
||||
<ul>
|
||||
<li><strong><code>pix_to_face</code></strong>: LongTensor of shape <code>(N, image_size, image_size, faces_per_pixel)</code> specifying the indices of the faces (in the packed faces) which overlap each pixel in the image.</li>
|
||||
<li><strong><code>zbuf</code></strong>: FloatTensor of shape <code>(N, image_size, image_size, faces_per_pixel)</code> giving the z-coordinates of the nearest faces at each pixel in world coordinates, sorted in ascending z-order.</li>
|
||||
<li><strong><code>bary_coords</code></strong>: FloatTensor of shape <code>(N, image_size, image_size, faces_per_pixel, 3)</code>
|
||||
giving the barycentric coordinates in NDC units of the nearest faces at each pixel, sorted in ascending z-order.</li>
|
||||
<li><strong><code>pix_dists</code></strong>: FloatTensor of shape <code>(N, image_size, image_size, faces_per_pixel)</code> giving the signed Euclidean distance (in NDC units) in the x/y plane of each point closest to the pixel.</li>
|
||||
</ul>
|
||||
<p>See the renderer API reference for more details about each component in the pipeline.</p>
|
||||
<hr>
|
||||
<p><strong>NOTE:</strong></p>
|
||||
<p>The differentiable renderer API is experimental and subject to change!.</p>
|
||||
<hr>
|
||||
<h3><a class="anchor" aria-hidden="true" id="coordinate-transformation-conventions"></a><a href="#coordinate-transformation-conventions" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Coordinate transformation conventions</h3>
|
||||
<p>Rendering requires transformations between several different coordinate frames: world space, view/camera space, NDC space and screen space. At each step it is important to know where the camera is located, how the x,y,z axes are aligned and the possible range of values. The following figure outlines the conventions used PyTorch3d.</p>
|
||||
<p><img src="assets/transformations_overview.png" width="1000"></p>
|
||||
<hr>
|
||||
<p><strong>NOTE: PyTorch3d vs OpenGL</strong></p>
|
||||
<p>While we tried to emulate several aspects of OpenGL, the NDC coordinate system in PyTorch3d is <strong>right-handed</strong> compared with a <strong>left-handed</strong> NDC coordinate system in OpenGL (the projection matrix switches the handedness).</p>
|
||||
<p>In OpenGL, the camera at the origin is looking along <code>-z</code> axis in camera space, but it is looking along the <code>+z</code> axis in NDC space.</p>
|
||||
<p><img align="center" src="assets/opengl_coordframes.png" width="300"></p>
|
||||
<hr>
|
||||
<h3><a class="anchor" aria-hidden="true" id="a-simple-renderer"></a><a href="#a-simple-renderer" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>A simple renderer</h3>
|
||||
<p>A renderer in PyTorch3d is composed of a <strong>rasterizer</strong> and a <strong>shader</strong>. Create a renderer in a few simple steps:</p>
|
||||
<pre><code class="hljs"><span class="hljs-comment"># Imports</span>
|
||||
<span class="hljs-keyword">from</span> pytorch3d.renderer import (
|
||||
OpenGLPerspectiveCameras, look_at_view_transform,
|
||||
RasterizationSettings, BlendParams,
|
||||
MeshRenderer, MeshRasterizer, PhongShader
|
||||
)
|
||||
|
||||
<span class="hljs-comment"># Initialize an OpenGL perspective camera.</span>
|
||||
R, T = look_at_view_transform(2.7, 10, 20)
|
||||
cameras = OpenGLPerspectiveCameras(<span class="hljs-attribute">device</span>=device, <span class="hljs-attribute">R</span>=R, <span class="hljs-attribute">T</span>=T)
|
||||
|
||||
<span class="hljs-comment"># Define the settings for rasterization and shading. Here we set the output image to be of size</span>
|
||||
<span class="hljs-comment"># 512x512. As we are rendering images for visualization purposes only we will set faces_per_pixel=1</span>
|
||||
<span class="hljs-comment"># and blur_radius=0.0. Refer to rasterize_meshes.py for explanations of these parameters.</span>
|
||||
raster_settings = RasterizationSettings(
|
||||
<span class="hljs-attribute">image_size</span>=512,
|
||||
<span class="hljs-attribute">blur_radius</span>=0.0,
|
||||
<span class="hljs-attribute">faces_per_pixel</span>=1,
|
||||
<span class="hljs-attribute">bin_size</span>=0
|
||||
)
|
||||
|
||||
<span class="hljs-comment"># Create a phong renderer by composing a rasterizer and a shader. Here we can use a predefined</span>
|
||||
<span class="hljs-comment"># PhongShader, passing in the device on which to initialize the default parameters</span>
|
||||
renderer = MeshRenderer(
|
||||
<span class="hljs-attribute">rasterizer</span>=MeshRasterizer(cameras=cameras, <span class="hljs-attribute">raster_settings</span>=raster_settings),
|
||||
<span class="hljs-attribute">shader</span>=PhongShader(device=device, <span class="hljs-attribute">cameras</span>=cameras)
|
||||
)
|
||||
</code></pre>
|
||||
</span></div></article></div><div class="docLastUpdate"><em>Last updated by Nikhila Ravi</em></div><div class="docs-prevnext"><a class="docs-prev button" href="/docs/renderer"><span class="arrow-prev">← </span><span>Overview</span></a></div></div></div><nav class="onPageNav"></nav></div><footer class="nav-footer" id="footer"><section class="sitemap"><div class="footerSection"><div class="social"><a class="github-button" href="https://github.com/facebookresearch/pytorch3d" data-count-href="https://github.com/facebookresearch/pytorch3d/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star PyTorch3d on GitHub">pytorch3d</a></div></div></section><a href="https://opensource.facebook.com/" target="_blank" rel="noreferrer noopener" class="fbOpenSource"><img src="/img/oss_logo.png" alt="Facebook Open Source" width="170" height="45"/></a><section class="copyright">Copyright "©" 2020 Facebook Inc</section></footer></div></body></html>
|
68
docs/why_pytorch3d.html
Normal file
@ -0,0 +1,68 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>why_pytorch3d · PyTorch3d</title><meta name="viewport" content="width=device-width"/><meta name="generator" content="Docusaurus"/><meta name="description" content="# Why PyTorch3d"/><meta name="docsearch:language" content="en"/><meta property="og:title" content="why_pytorch3d · PyTorch3d"/><meta property="og:type" content="website"/><meta property="og:url" content="https://pytorch3d.org/"/><meta property="og:description" content="# Why PyTorch3d"/><meta property="og:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><meta name="twitter:card" content="summary"/><meta name="twitter:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><link rel="shortcut icon" href="/img/pytorch3dfavicon.png"/><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css"/><script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-157376881-1', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script><script type="text/javascript" src="https://buttons.github.io/buttons.js"></script><script src="/js/scrollSpy.js"></script><link rel="stylesheet" href="/css/main.css"/><script src="/js/codetabs.js"></script></head><body class="sideNavVisible separateOnPageNav"><div class="fixedHeaderContainer"><div class="headerWrapper wrapper"><header><a href="/"><img class="logo" src="/img/pytorch3dfavicon.png" alt="PyTorch3d"/><h2 class="headerTitleWithLogo">PyTorch3d</h2></a><div class="navigationWrapper navigationSlider"><nav class="slidingNav"><ul class="nav-site nav-site-internal"><li class="siteNavGroupActive siteNavItemActive"><a href="/docs/why_pytorch3d" target="_self">Docs</a></li><li class=""><a href="/tutorials" target="_self">Tutorials</a></li><li class=""><a href="https://pytorch3d.readthedocs.io/" target="_self">API</a></li><li class=""><a href="https://github.com/facebookresearch/pytorch3d" target="_self">GitHub</a></li></ul></nav></div></header></div></div><div class="navPusher"><div class="docMainWrapper wrapper"><div class="docsNavContainer" id="docsNav"><nav class="toc"><div class="toggleNav"><section class="navWrapper wrapper"><div class="navBreadcrumb wrapper"><div class="navToggle" id="navToggler"><div class="hamburger-menu"><div class="line1"></div><div class="line2"></div><div class="line3"></div></div></div><h2><i>›</i><span>Introduction</span></h2><div class="tocToggler" id="tocToggler"><i class="icon-toc"></i></div></div><div class="navGroups"><div class="navGroup"><h3 class="navGroupCategoryTitle">Introduction</h3><ul class=""><li class="navListItem navListItemActive"><a class="navItem" href="/docs/why_pytorch3d">Why PyTorch3d</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Meshes</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/batching">Batching</a></li><li class="navListItem"><a class="navItem" href="/docs/meshes_io">Loading from file</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Differentiable Renderer</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/renderer">Overview</a></li><li class="navListItem"><a class="navItem" href="/docs/renderer_getting_started">Getting Started</a></li></ul></div></div></section></div><script>
|
||||
var coll = document.getElementsByClassName('collapsible');
|
||||
var checkActiveCategory = true;
|
||||
for (var i = 0; i < coll.length; i++) {
|
||||
var links = coll[i].nextElementSibling.getElementsByTagName('*');
|
||||
if (checkActiveCategory){
|
||||
for (var j = 0; j < links.length; j++) {
|
||||
if (links[j].classList.contains('navListItemActive')){
|
||||
coll[i].nextElementSibling.classList.toggle('hide');
|
||||
coll[i].childNodes[1].classList.toggle('rotate');
|
||||
checkActiveCategory = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
coll[i].addEventListener('click', function() {
|
||||
var arrow = this.childNodes[1];
|
||||
arrow.classList.toggle('rotate');
|
||||
var content = this.nextElementSibling;
|
||||
content.classList.toggle('hide');
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
createToggler('#navToggler', '#docsNav', 'docsSliderActive');
|
||||
createToggler('#tocToggler', 'body', 'tocActive');
|
||||
|
||||
var headings = document.querySelector('.toc-headings');
|
||||
headings && headings.addEventListener('click', function(event) {
|
||||
var el = event.target;
|
||||
while(el !== headings){
|
||||
if (el.tagName === 'A') {
|
||||
document.body.classList.remove('tocActive');
|
||||
break;
|
||||
} else{
|
||||
el = el.parentNode;
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
|
||||
function createToggler(togglerSelector, targetSelector, className) {
|
||||
var toggler = document.querySelector(togglerSelector);
|
||||
var target = document.querySelector(targetSelector);
|
||||
|
||||
if (!toggler) {
|
||||
return;
|
||||
}
|
||||
|
||||
toggler.onclick = function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
target.classList.toggle(className);
|
||||
};
|
||||
}
|
||||
});
|
||||
</script></nav></div><div class="container mainContainer docsContainer"><div class="wrapper"><div class="post"><header class="postHeader"></header><article><div><span><h1><a class="anchor" aria-hidden="true" id="why-pytorch3d"></a><a href="#why-pytorch3d" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Why PyTorch3d</h1>
|
||||
<p>Our goal with PyTorch3D is to help accelerate research at the intersection of deep learning and 3D. 3D data is more complex than 2D images and while working on projects such as <a href="https://github.com/facebookresearch/meshrcnn">Mesh R-CNN</a> and <a href="https://github.com/facebookresearch/c3dpo_nrsfm">C3DPO</a>, we encountered several challenges including 3D data representation, batching, and speed. We have developed many useful operators and abstractions for working on 3D deep learning and want to share this with the community to drive novel research in this area.</p>
|
||||
<p>In PyTorch3D we have included efficient 3D operators, heterogeneous batching capabilities, and a modular differentiable rendering API, to equip researchers in this field with a much needed toolkit to implement cutting-edge research with complex 3D inputs.</p>
|
||||
</span></div></article></div><div class="docLastUpdate"><em>Last updated by Nikhila Ravi</em></div><div class="docs-prevnext"><a class="docs-next button" href="/docs/batching"><span>Batching</span><span class="arrow-next"> →</span></a></div></div></div><nav class="onPageNav"></nav></div><footer class="nav-footer" id="footer"><section class="sitemap"><div class="footerSection"><div class="social"><a class="github-button" href="https://github.com/facebookresearch/pytorch3d" data-count-href="https://github.com/facebookresearch/pytorch3d/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star PyTorch3d on GitHub">pytorch3d</a></div></div></section><a href="https://opensource.facebook.com/" target="_blank" rel="noreferrer noopener" class="fbOpenSource"><img src="/img/oss_logo.png" alt="Facebook Open Source" width="170" height="45"/></a><section class="copyright">Copyright "©" 2020 Facebook Inc</section></footer></div></body></html>
|
68
docs/why_pytorch3d/index.html
Normal file
@ -0,0 +1,68 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>why_pytorch3d · PyTorch3d</title><meta name="viewport" content="width=device-width"/><meta name="generator" content="Docusaurus"/><meta name="description" content="# Why PyTorch3d"/><meta name="docsearch:language" content="en"/><meta property="og:title" content="why_pytorch3d · PyTorch3d"/><meta property="og:type" content="website"/><meta property="og:url" content="https://pytorch3d.org/"/><meta property="og:description" content="# Why PyTorch3d"/><meta property="og:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><meta name="twitter:card" content="summary"/><meta name="twitter:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><link rel="shortcut icon" href="/img/pytorch3dfavicon.png"/><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css"/><script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-157376881-1', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script><script type="text/javascript" src="https://buttons.github.io/buttons.js"></script><script src="/js/scrollSpy.js"></script><link rel="stylesheet" href="/css/main.css"/><script src="/js/codetabs.js"></script></head><body class="sideNavVisible separateOnPageNav"><div class="fixedHeaderContainer"><div class="headerWrapper wrapper"><header><a href="/"><img class="logo" src="/img/pytorch3dfavicon.png" alt="PyTorch3d"/><h2 class="headerTitleWithLogo">PyTorch3d</h2></a><div class="navigationWrapper navigationSlider"><nav class="slidingNav"><ul class="nav-site nav-site-internal"><li class="siteNavGroupActive siteNavItemActive"><a href="/docs/why_pytorch3d" target="_self">Docs</a></li><li class=""><a href="/tutorials" target="_self">Tutorials</a></li><li class=""><a href="https://pytorch3d.readthedocs.io/" target="_self">API</a></li><li class=""><a href="https://github.com/facebookresearch/pytorch3d" target="_self">GitHub</a></li></ul></nav></div></header></div></div><div class="navPusher"><div class="docMainWrapper wrapper"><div class="docsNavContainer" id="docsNav"><nav class="toc"><div class="toggleNav"><section class="navWrapper wrapper"><div class="navBreadcrumb wrapper"><div class="navToggle" id="navToggler"><div class="hamburger-menu"><div class="line1"></div><div class="line2"></div><div class="line3"></div></div></div><h2><i>›</i><span>Introduction</span></h2><div class="tocToggler" id="tocToggler"><i class="icon-toc"></i></div></div><div class="navGroups"><div class="navGroup"><h3 class="navGroupCategoryTitle">Introduction</h3><ul class=""><li class="navListItem navListItemActive"><a class="navItem" href="/docs/why_pytorch3d">Why PyTorch3d</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Meshes</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/batching">Batching</a></li><li class="navListItem"><a class="navItem" href="/docs/meshes_io">Loading from file</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Differentiable Renderer</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/renderer">Overview</a></li><li class="navListItem"><a class="navItem" href="/docs/renderer_getting_started">Getting Started</a></li></ul></div></div></section></div><script>
|
||||
var coll = document.getElementsByClassName('collapsible');
|
||||
var checkActiveCategory = true;
|
||||
for (var i = 0; i < coll.length; i++) {
|
||||
var links = coll[i].nextElementSibling.getElementsByTagName('*');
|
||||
if (checkActiveCategory){
|
||||
for (var j = 0; j < links.length; j++) {
|
||||
if (links[j].classList.contains('navListItemActive')){
|
||||
coll[i].nextElementSibling.classList.toggle('hide');
|
||||
coll[i].childNodes[1].classList.toggle('rotate');
|
||||
checkActiveCategory = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
coll[i].addEventListener('click', function() {
|
||||
var arrow = this.childNodes[1];
|
||||
arrow.classList.toggle('rotate');
|
||||
var content = this.nextElementSibling;
|
||||
content.classList.toggle('hide');
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
createToggler('#navToggler', '#docsNav', 'docsSliderActive');
|
||||
createToggler('#tocToggler', 'body', 'tocActive');
|
||||
|
||||
var headings = document.querySelector('.toc-headings');
|
||||
headings && headings.addEventListener('click', function(event) {
|
||||
var el = event.target;
|
||||
while(el !== headings){
|
||||
if (el.tagName === 'A') {
|
||||
document.body.classList.remove('tocActive');
|
||||
break;
|
||||
} else{
|
||||
el = el.parentNode;
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
|
||||
function createToggler(togglerSelector, targetSelector, className) {
|
||||
var toggler = document.querySelector(togglerSelector);
|
||||
var target = document.querySelector(targetSelector);
|
||||
|
||||
if (!toggler) {
|
||||
return;
|
||||
}
|
||||
|
||||
toggler.onclick = function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
target.classList.toggle(className);
|
||||
};
|
||||
}
|
||||
});
|
||||
</script></nav></div><div class="container mainContainer docsContainer"><div class="wrapper"><div class="post"><header class="postHeader"></header><article><div><span><h1><a class="anchor" aria-hidden="true" id="why-pytorch3d"></a><a href="#why-pytorch3d" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Why PyTorch3d</h1>
|
||||
<p>Our goal with PyTorch3D is to help accelerate research at the intersection of deep learning and 3D. 3D data is more complex than 2D images and while working on projects such as <a href="https://github.com/facebookresearch/meshrcnn">Mesh R-CNN</a> and <a href="https://github.com/facebookresearch/c3dpo_nrsfm">C3DPO</a>, we encountered several challenges including 3D data representation, batching, and speed. We have developed many useful operators and abstractions for working on 3D deep learning and want to share this with the community to drive novel research in this area.</p>
|
||||
<p>In PyTorch3D we have included efficient 3D operators, heterogeneous batching capabilities, and a modular differentiable rendering API, to equip researchers in this field with a much needed toolkit to implement cutting-edge research with complex 3D inputs.</p>
|
||||
</span></div></article></div><div class="docLastUpdate"><em>Last updated by Nikhila Ravi</em></div><div class="docs-prevnext"><a class="docs-next button" href="/docs/batching"><span>Batching</span><span class="arrow-next"> →</span></a></div></div></div><nav class="onPageNav"></nav></div><footer class="nav-footer" id="footer"><section class="sitemap"><div class="footerSection"><div class="social"><a class="github-button" href="https://github.com/facebookresearch/pytorch3d" data-count-href="https://github.com/facebookresearch/pytorch3d/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star PyTorch3d on GitHub">pytorch3d</a></div></div></section><a href="https://opensource.facebook.com/" target="_blank" rel="noreferrer noopener" class="fbOpenSource"><img src="/img/oss_logo.png" alt="Facebook Open Source" width="170" height="45"/></a><section class="copyright">Copyright "©" 2020 Facebook Inc</section></footer></div></body></html>
|
15
en/help.html
Normal file
@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>PyTorch3d · A library for deep learning with 3D data</title><meta name="viewport" content="width=device-width"/><meta name="generator" content="Docusaurus"/><meta name="description" content="A library for deep learning with 3D data"/><meta name="docsearch:language" content="en"/><meta property="og:title" content="PyTorch3d · A library for deep learning with 3D data"/><meta property="og:type" content="website"/><meta property="og:url" content="https://pytorch3d.org/"/><meta property="og:description" content="A library for deep learning with 3D data"/><meta property="og:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><meta name="twitter:card" content="summary"/><meta name="twitter:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><link rel="shortcut icon" href="/img/pytorch3dfavicon.png"/><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css"/><script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-157376881-1', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script><script type="text/javascript" src="https://buttons.github.io/buttons.js"></script><script src="/js/scrollSpy.js"></script><link rel="stylesheet" href="/css/main.css"/><script src="/js/codetabs.js"></script></head><body><div class="fixedHeaderContainer"><div class="headerWrapper wrapper"><header><a href="/"><img class="logo" src="/img/pytorch3dfavicon.png" alt="PyTorch3d"/><h2 class="headerTitleWithLogo">PyTorch3d</h2></a><div class="navigationWrapper navigationSlider"><nav class="slidingNav"><ul class="nav-site nav-site-internal"><li class=""><a href="/docs/why_pytorch3d" target="_self">Docs</a></li><li class=""><a href="/tutorials" target="_self">Tutorials</a></li><li class=""><a href="https://pytorch3d.readthedocs.io/" target="_self">API</a></li><li class=""><a href="https://github.com/facebookresearch/pytorch3d" target="_self">GitHub</a></li></ul></nav></div></header></div></div><div class="navPusher"><div class="docMainWrapper wrapper"><div class="container mainContainer documentContainer postContainer"><div class="wrapper"><div class="post"><header class="postHeader"><h1>Need help?</h1></header><p>This project is maintained by a dedicated group of people.</p><div class="gridBlock"><div class="blockElement threeByGridBlock"><div class="blockContent"><h2><div><span><p>Browse Docs</p>
|
||||
</span></div></h2><div><span><p>Learn more using the <a href="/docs/en/doc1.html">documentation on this site.</a></p>
|
||||
</span></div></div></div><div class="blockElement threeByGridBlock"><div class="blockContent"><h2><div><span><p>Join the community</p>
|
||||
</span></div></h2><div><span><p>Ask questions about the documentation and project</p>
|
||||
</span></div></div></div><div class="blockElement threeByGridBlock"><div class="blockContent"><h2><div><span><p>Stay up to date</p>
|
||||
</span></div></h2><div><span><p>Find out what's new with this project</p>
|
||||
</span></div></div></div></div></div></div></div></div><footer class="nav-footer" id="footer"><section class="sitemap"><div class="footerSection"><div class="social"><a class="github-button" href="https://github.com/facebookresearch/pytorch3d" data-count-href="https://github.com/facebookresearch/pytorch3d/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star PyTorch3d on GitHub">pytorch3d</a></div></div></section><a href="https://opensource.facebook.com/" target="_blank" rel="noreferrer noopener" class="fbOpenSource"><img src="/img/oss_logo.png" alt="Facebook Open Source" width="170" height="45"/></a><section class="copyright">Copyright "©" 2020 Facebook Inc</section></footer></div></body></html>
|
15
en/help/index.html
Normal file
@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>PyTorch3d · A library for deep learning with 3D data</title><meta name="viewport" content="width=device-width"/><meta name="generator" content="Docusaurus"/><meta name="description" content="A library for deep learning with 3D data"/><meta name="docsearch:language" content="en"/><meta property="og:title" content="PyTorch3d · A library for deep learning with 3D data"/><meta property="og:type" content="website"/><meta property="og:url" content="https://pytorch3d.org/"/><meta property="og:description" content="A library for deep learning with 3D data"/><meta property="og:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><meta name="twitter:card" content="summary"/><meta name="twitter:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><link rel="shortcut icon" href="/img/pytorch3dfavicon.png"/><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css"/><script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-157376881-1', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script><script type="text/javascript" src="https://buttons.github.io/buttons.js"></script><script src="/js/scrollSpy.js"></script><link rel="stylesheet" href="/css/main.css"/><script src="/js/codetabs.js"></script></head><body><div class="fixedHeaderContainer"><div class="headerWrapper wrapper"><header><a href="/"><img class="logo" src="/img/pytorch3dfavicon.png" alt="PyTorch3d"/><h2 class="headerTitleWithLogo">PyTorch3d</h2></a><div class="navigationWrapper navigationSlider"><nav class="slidingNav"><ul class="nav-site nav-site-internal"><li class=""><a href="/docs/why_pytorch3d" target="_self">Docs</a></li><li class=""><a href="/tutorials" target="_self">Tutorials</a></li><li class=""><a href="https://pytorch3d.readthedocs.io/" target="_self">API</a></li><li class=""><a href="https://github.com/facebookresearch/pytorch3d" target="_self">GitHub</a></li></ul></nav></div></header></div></div><div class="navPusher"><div class="docMainWrapper wrapper"><div class="container mainContainer documentContainer postContainer"><div class="wrapper"><div class="post"><header class="postHeader"><h1>Need help?</h1></header><p>This project is maintained by a dedicated group of people.</p><div class="gridBlock"><div class="blockElement threeByGridBlock"><div class="blockContent"><h2><div><span><p>Browse Docs</p>
|
||||
</span></div></h2><div><span><p>Learn more using the <a href="/docs/en/doc1.html">documentation on this site.</a></p>
|
||||
</span></div></div></div><div class="blockElement threeByGridBlock"><div class="blockContent"><h2><div><span><p>Join the community</p>
|
||||
</span></div></h2><div><span><p>Ask questions about the documentation and project</p>
|
||||
</span></div></div></div><div class="blockElement threeByGridBlock"><div class="blockContent"><h2><div><span><p>Stay up to date</p>
|
||||
</span></div></h2><div><span><p>Find out what's new with this project</p>
|
||||
</span></div></div></div></div></div></div></div></div><footer class="nav-footer" id="footer"><section class="sitemap"><div class="footerSection"><div class="social"><a class="github-button" href="https://github.com/facebookresearch/pytorch3d" data-count-href="https://github.com/facebookresearch/pytorch3d/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star PyTorch3d on GitHub">pytorch3d</a></div></div></section><a href="https://opensource.facebook.com/" target="_blank" rel="noreferrer noopener" class="fbOpenSource"><img src="/img/oss_logo.png" alt="Facebook Open Source" width="170" height="45"/></a><section class="copyright">Copyright "©" 2020 Facebook Inc</section></footer></div></body></html>
|
34
en/index.html
Normal file
@ -0,0 +1,34 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>PyTorch3d · A library for deep learning with 3D data</title><meta name="viewport" content="width=device-width"/><meta name="generator" content="Docusaurus"/><meta name="description" content="A library for deep learning with 3D data"/><meta name="docsearch:language" content="en"/><meta property="og:title" content="PyTorch3d · A library for deep learning with 3D data"/><meta property="og:type" content="website"/><meta property="og:url" content="https://pytorch3d.org/"/><meta property="og:description" content="A library for deep learning with 3D data"/><meta property="og:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><meta name="twitter:card" content="summary"/><meta name="twitter:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><link rel="shortcut icon" href="/img/pytorch3dfavicon.png"/><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css"/><script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-157376881-1', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script><script type="text/javascript" src="https://buttons.github.io/buttons.js"></script><script src="/js/scrollSpy.js"></script><link rel="stylesheet" href="/css/main.css"/><script src="/js/codetabs.js"></script></head><body><div class="fixedHeaderContainer"><div class="headerWrapper wrapper"><header><a href="/"><img class="logo" src="/img/pytorch3dfavicon.png" alt="PyTorch3d"/><h2 class="headerTitleWithLogo">PyTorch3d</h2></a><div class="navigationWrapper navigationSlider"><nav class="slidingNav"><ul class="nav-site nav-site-internal"><li class=""><a href="/docs/why_pytorch3d" target="_self">Docs</a></li><li class=""><a href="/tutorials" target="_self">Tutorials</a></li><li class=""><a href="https://pytorch3d.readthedocs.io/" target="_self">API</a></li><li class=""><a href="https://github.com/facebookresearch/pytorch3d" target="_self">GitHub</a></li></ul></nav></div></header></div></div><div class="navPusher"><div><div class="homeContainer"><div class="homeSplashFade"><div class="wrapper homeWrapper"><div class="splashLogo"><img src="/img/pytorch3dlogowhite.svg" alt="Project Logo"/></div><div class="inner"><h2 class="projectTitle"><small>A library for deep learning with 3D data</small></h2><div class="section promoSection"><div class="promoRow"><div class="pluginRowBlock"><div class="pluginWrapper buttonWrapper"><a class="button" href="/docs/en/why_pytorch3d.html">Docs</a></div><div class="pluginWrapper buttonWrapper"><a class="button" href="/tutorials/">Tutorials</a></div><div class="pluginWrapper buttonWrapper"><a class="button" href="#quickstart">Get Started</a></div></div></div></div></div></div></div></div><div class="landingPage mainContainer"><div class="productShowcaseSection" style="text-align:center"><div class="container paddingBottom paddingTop"><div class="wrapper"><div class="gridBlock"><div class="blockElement alignCenter fourByGridBlock imageAlignTop"><div class="blockImage"><img src="/img/batching.svg"/></div><div class="blockContent"><h2><div><span><p>Heterogeneous Batching</p>
|
||||
</span></div></h2><div><span><p>Supports batching of 3D inputs of different sizes such as meshes</p>
|
||||
</span></div></div></div><div class="blockElement alignCenter fourByGridBlock imageAlignTop"><div class="blockImage"><img src="/img/ops.png"/></div><div class="blockContent"><h2><div><span><p>Fast 3D Operators</p>
|
||||
</span></div></h2><div><span><p>Supports optimized implementations of several common functions for 3D data</p>
|
||||
</span></div></div></div><div class="blockElement alignCenter fourByGridBlock imageAlignTop"><div class="blockImage"><img src="/img/rendering.svg"/></div><div class="blockContent"><h2><div><span><p>Differentiable Rendering</p>
|
||||
</span></div></h2><div><span><p>Modular differentiable rendering API with parallel implementations in PyTorch, C++ and CUDA</p>
|
||||
</span></div></div></div></div></div></div></div><div class="productShowcaseSection" id="quickstart" style="text-align:center"><h2>Get Started</h2><div class="container"><div class="wrapper"><ol><li><strong>Install PyTorch3D:</strong><div><span><pre><code class="hljs css language-bash">conda install pytorch torchvision -c pytorch <span class="hljs-comment"># OSX only</span>
|
||||
conda install pytorch3d -c pytorch3d <span class="hljs-comment"># all systems</span>
|
||||
</code></pre>
|
||||
</span></div></li><li><strong>Try a few 3D operators </strong>e.g. compute the chamfer loss between two meshes:<div><span><pre><code class="hljs css language-python"><span class="hljs-keyword">from</span> pytorch3d.utils <span class="hljs-keyword">import</span> ico_sphere
|
||||
<span class="hljs-keyword">from</span> pytorch3d.io <span class="hljs-keyword">import</span> load_obj
|
||||
<span class="hljs-keyword">from</span> pytorch3d.structures <span class="hljs-keyword">import</span> Meshes
|
||||
<span class="hljs-keyword">from</span> pytorch3d.ops <span class="hljs-keyword">import</span> sample_points_from_meshes
|
||||
<span class="hljs-keyword">from</span> pytorch3d.loss <span class="hljs-keyword">import</span> chamfer_distance
|
||||
|
||||
<span class="hljs-comment"># Use an ico_sphere mesh and load a mesh from an .obj e.g. model.obj</span>
|
||||
sphere_mesh = ico_sphere(level=<span class="hljs-number">3</span>)
|
||||
verts, faces, _ = load_obj(<span class="hljs-string">"model.obj"</span>)
|
||||
test_mesh = Meshes(verts=[verts], faces=[faces.verts_idx])
|
||||
|
||||
<span class="hljs-comment"># Differentiably sample 5k points from the surface of each mesh and then compute the loss.</span>
|
||||
sample_sphere = sample_points_from_meshes(sphere_mesh, <span class="hljs-number">5000</span>)
|
||||
sample_test = sample_points_from_meshes(test_mesh, <span class="hljs-number">5000</span>)
|
||||
loss_chamfer, _ = chamfer_distance(sample_sphere, sample_test)
|
||||
</code></pre>
|
||||
</span></div></li></ol></div></div></div></div></div><footer class="nav-footer" id="footer"><section class="sitemap"><div class="footerSection"><div class="social"><a class="github-button" href="https://github.com/facebookresearch/pytorch3d" data-count-href="https://github.com/facebookresearch/pytorch3d/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star PyTorch3d on GitHub">pytorch3d</a></div></div></section><a href="https://opensource.facebook.com/" target="_blank" rel="noreferrer noopener" class="fbOpenSource"><img src="/img/oss_logo.png" alt="Facebook Open Source" width="170" height="45"/></a><section class="copyright">Copyright "©" 2020 Facebook Inc</section></footer></div></body></html>
|
9
en/users.html
Normal file
@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>PyTorch3d · A library for deep learning with 3D data</title><meta name="viewport" content="width=device-width"/><meta name="generator" content="Docusaurus"/><meta name="description" content="A library for deep learning with 3D data"/><meta name="docsearch:language" content="en"/><meta property="og:title" content="PyTorch3d · A library for deep learning with 3D data"/><meta property="og:type" content="website"/><meta property="og:url" content="https://pytorch3d.org/"/><meta property="og:description" content="A library for deep learning with 3D data"/><meta property="og:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><meta name="twitter:card" content="summary"/><meta name="twitter:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><link rel="shortcut icon" href="/img/pytorch3dfavicon.png"/><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css"/><script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-157376881-1', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script><script type="text/javascript" src="https://buttons.github.io/buttons.js"></script><script src="/js/scrollSpy.js"></script><link rel="stylesheet" href="/css/main.css"/><script src="/js/codetabs.js"></script></head><body><div class="fixedHeaderContainer"><div class="headerWrapper wrapper"><header><a href="/"><img class="logo" src="/img/pytorch3dfavicon.png" alt="PyTorch3d"/><h2 class="headerTitleWithLogo">PyTorch3d</h2></a><div class="navigationWrapper navigationSlider"><nav class="slidingNav"><ul class="nav-site nav-site-internal"><li class=""><a href="/docs/why_pytorch3d" target="_self">Docs</a></li><li class=""><a href="/tutorials" target="_self">Tutorials</a></li><li class=""><a href="https://pytorch3d.readthedocs.io/" target="_self">API</a></li><li class=""><a href="https://github.com/facebookresearch/pytorch3d" target="_self">GitHub</a></li></ul></nav></div></header></div></div><div class="navPusher"><div class="mainContainer"><div class="container paddingBottom paddingTop"><div class="wrapper"><div class="showcaseSection"><div class="prose"><h1>Who is Using This?</h1><p>This project is used by many folks</p></div><div class="logos"><a href="https://www.facebook.com"><img src="/img/undraw_open_source.svg" alt="User1" title="User1"/></a></div><p>Are you using this project?</p><a href="undefined/edit/master/website/siteConfig.js" class="button">Add your company</a></div></div></div></div><footer class="nav-footer" id="footer"><section class="sitemap"><div class="footerSection"><div class="social"><a class="github-button" href="https://github.com/facebookresearch/pytorch3d" data-count-href="https://github.com/facebookresearch/pytorch3d/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star PyTorch3d on GitHub">pytorch3d</a></div></div></section><a href="https://opensource.facebook.com/" target="_blank" rel="noreferrer noopener" class="fbOpenSource"><img src="/img/oss_logo.png" alt="Facebook Open Source" width="170" height="45"/></a><section class="copyright">Copyright "©" 2020 Facebook Inc</section></footer></div></body></html>
|
9
en/users/index.html
Normal file
@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>PyTorch3d · A library for deep learning with 3D data</title><meta name="viewport" content="width=device-width"/><meta name="generator" content="Docusaurus"/><meta name="description" content="A library for deep learning with 3D data"/><meta name="docsearch:language" content="en"/><meta property="og:title" content="PyTorch3d · A library for deep learning with 3D data"/><meta property="og:type" content="website"/><meta property="og:url" content="https://pytorch3d.org/"/><meta property="og:description" content="A library for deep learning with 3D data"/><meta property="og:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><meta name="twitter:card" content="summary"/><meta name="twitter:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><link rel="shortcut icon" href="/img/pytorch3dfavicon.png"/><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css"/><script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-157376881-1', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script><script type="text/javascript" src="https://buttons.github.io/buttons.js"></script><script src="/js/scrollSpy.js"></script><link rel="stylesheet" href="/css/main.css"/><script src="/js/codetabs.js"></script></head><body><div class="fixedHeaderContainer"><div class="headerWrapper wrapper"><header><a href="/"><img class="logo" src="/img/pytorch3dfavicon.png" alt="PyTorch3d"/><h2 class="headerTitleWithLogo">PyTorch3d</h2></a><div class="navigationWrapper navigationSlider"><nav class="slidingNav"><ul class="nav-site nav-site-internal"><li class=""><a href="/docs/why_pytorch3d" target="_self">Docs</a></li><li class=""><a href="/tutorials" target="_self">Tutorials</a></li><li class=""><a href="https://pytorch3d.readthedocs.io/" target="_self">API</a></li><li class=""><a href="https://github.com/facebookresearch/pytorch3d" target="_self">GitHub</a></li></ul></nav></div></header></div></div><div class="navPusher"><div class="mainContainer"><div class="container paddingBottom paddingTop"><div class="wrapper"><div class="showcaseSection"><div class="prose"><h1>Who is Using This?</h1><p>This project is used by many folks</p></div><div class="logos"><a href="https://www.facebook.com"><img src="/img/undraw_open_source.svg" alt="User1" title="User1"/></a></div><p>Are you using this project?</p><a href="undefined/edit/master/website/siteConfig.js" class="button">Add your company</a></div></div></div></div><footer class="nav-footer" id="footer"><section class="sitemap"><div class="footerSection"><div class="social"><a class="github-button" href="https://github.com/facebookresearch/pytorch3d" data-count-href="https://github.com/facebookresearch/pytorch3d/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star PyTorch3d on GitHub">pytorch3d</a></div></div></section><a href="https://opensource.facebook.com/" target="_blank" rel="noreferrer noopener" class="fbOpenSource"><img src="/img/oss_logo.png" alt="Facebook Open Source" width="170" height="45"/></a><section class="copyright">Copyright "©" 2020 Facebook Inc</section></footer></div></body></html>
|
439
files/bundle_adjustment.ipynb
Normal file
219
files/bundle_adjustment.py
Normal file
@ -0,0 +1,219 @@
|
||||
#!/usr/bin/env python
|
||||
# coding: utf-8
|
||||
|
||||
# In[1]:
|
||||
|
||||
|
||||
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||
|
||||
|
||||
# # Absolute camera orientation given set of relative camera pairs
|
||||
#
|
||||
# This tutorial showcases the `cameras`, `transforms` and `so3` API.
|
||||
#
|
||||
# The problem we deal with is defined as follows:
|
||||
#
|
||||
# Given an optical system of $N$ cameras with extrinsics $\{g_1, ..., g_N | g_i \in SE(3)\}$, and a set of relative camera positions $\{g_{ij} | g_{ij}\in SE(3)\}$ that map between coordinate frames of randomly selected pairs of cameras $(i, j)$, we search for the absolute extrinsic parameters $\{g_1, ..., g_N\}$ that are consistent with the relative camera motions.
|
||||
#
|
||||
# More formally:
|
||||
# $$
|
||||
# g_1, ..., g_N =
|
||||
# {\arg \min}_{g_1, ..., g_N} \sum_{g_{ij}} d(g_{ij}, g_i^{-1} g_j),
|
||||
# $$,
|
||||
# where $d(g_i, g_j)$ is a suitable metric that compares the extrinsics of cameras $g_i$ and $g_j$.
|
||||
#
|
||||
# Visually, the problem can be described as follows. The picture below depicts the situation at the beginning of our optimization. The ground truth cameras are plotted in green while the randomly initialized estimated cameras are plotted in blue:
|
||||
# 
|
||||
#
|
||||
# Our optimization seeks to align the estimated (blue) cameras with the ground truth (green) cameras, by minimizing the discrepancies between pairs of relative cameras. Thus, the solution to the problem should look as follows:
|
||||
# 
|
||||
#
|
||||
# In practice, the camera extrinsics $g_{ij}$ and $g_i$ are represented using objects from the `SfMPerspectiveCameras` class initialized with the corresponding rotation and translation matrices `R_absolute` and `T_absolute` that define the extrinsic parameters $g = (R, T); R \in SO(3); T \in \mathbb{R}^3$. In order to ensure that `R_absolute` is a valid rotation matrix, we represent it using an exponential map (implemented with `so3_exponential_map`) of the axis-angle representation of the rotation `log_R_absolute`.
|
||||
#
|
||||
# Note that the solution to this problem could only be recovered up to an unknown global rigid transformation $g_{glob} \in SE(3)$. Thus, for simplicity, we assume knowledge of the absolute extrinsics of the first camera $g_0$. We set $g_0$ as a trivial camera $g_0 = (I, \vec{0})$.
|
||||
#
|
||||
|
||||
# ## 0. Import Modules
|
||||
|
||||
# In[2]:
|
||||
|
||||
|
||||
# imports
|
||||
import torch
|
||||
from pytorch3d.transforms.so3 import (
|
||||
so3_exponential_map,
|
||||
so3_relative_angle,
|
||||
)
|
||||
from pytorch3d.renderer.cameras import (
|
||||
SfMPerspectiveCameras,
|
||||
)
|
||||
|
||||
# add path for demo utils
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.path.abspath(''))
|
||||
from utils import plot_camera_scene
|
||||
|
||||
# set for reproducibility
|
||||
torch.manual_seed(42)
|
||||
|
||||
|
||||
# ## 1. Set up Cameras and load ground truth positions
|
||||
|
||||
# In[3]:
|
||||
|
||||
|
||||
# load the SE3 graph of relative/absolute camera positions
|
||||
camera_graph_file = './data/camera_graph.pth'
|
||||
(R_absolute_gt, T_absolute_gt), (R_relative, T_relative), relative_edges = torch.load(camera_graph_file)
|
||||
|
||||
# create the relative cameras
|
||||
cameras_relative = SfMPerspectiveCameras(
|
||||
R = R_relative.cuda(),
|
||||
T = T_relative.cuda(),
|
||||
device = "cuda",
|
||||
)
|
||||
|
||||
# create the absolute ground truth cameras
|
||||
cameras_absolute_gt = SfMPerspectiveCameras(
|
||||
R = R_absolute_gt.cuda(),
|
||||
T = T_absolute_gt.cuda(),
|
||||
device = "cuda",
|
||||
)
|
||||
|
||||
# the number of absolute camera positions
|
||||
N = R_absolute_gt.shape[0]
|
||||
|
||||
|
||||
# ## 2. Define optimization functions
|
||||
#
|
||||
# ### Relative cameras and camera distance
|
||||
# We now define two functions crucial for the optimization.
|
||||
#
|
||||
# **`calc_camera_distance`** compares a pair of cameras. This function is important as it defines the loss that we are minimizing. The method utilizes the `so3_relative_angle` function from the SO3 API.
|
||||
#
|
||||
# **`get_relative_camera`** computes the parameters of a relative camera that maps between a pair of absolute cameras. Here we utilize the `compose` and `inverse` class methods from the PyTorch3d Transforms API.
|
||||
|
||||
# In[ ]:
|
||||
|
||||
|
||||
def calc_camera_distance(cam_1, cam_2):
|
||||
"""
|
||||
Calculates the divergence of a batch of pairs of cameras cam_1, cam_2.
|
||||
The distance is composed of the cosine of the relative angle between
|
||||
the rotation components of the camera extrinsics and the l2 distance
|
||||
between the translation vectors.
|
||||
"""
|
||||
# rotation distance
|
||||
R_distance = (1.-so3_relative_angle(cam_1.R, cam_2.R, cos_angle=True)).mean()
|
||||
# translation distance
|
||||
T_distance = ((cam_1.T - cam_2.T)**2).sum(1).mean()
|
||||
# the final distance is the sum
|
||||
return R_distance + T_distance
|
||||
|
||||
def get_relative_camera(cams, edges):
|
||||
"""
|
||||
For each pair of indices (i,j) in "edges" generate a camera
|
||||
that maps from the coordinates of the camera cams[i] to
|
||||
the coordinates of the camera cams[j]
|
||||
"""
|
||||
|
||||
# first generate the world-to-view Transform3d objects of each
|
||||
# camera pair (i, j) according to the edges argument
|
||||
trans_i, trans_j = [
|
||||
SfMPerspectiveCameras(
|
||||
R = cams.R[edges[:, i]],
|
||||
T = cams.T[edges[:, i]],
|
||||
device = "cuda",
|
||||
).get_world_to_view_transform()
|
||||
for i in (0, 1)
|
||||
]
|
||||
|
||||
# compose the relative transformation as g_i^{-1} g_j
|
||||
trans_rel = trans_i.inverse().compose(trans_j)
|
||||
|
||||
# generate a camera from the relative transform
|
||||
matrix_rel = trans_rel.get_matrix()
|
||||
cams_relative = SfMPerspectiveCameras(
|
||||
R = matrix_rel[:, :3, :3],
|
||||
T = matrix_rel[:, 3, :3],
|
||||
device = "cuda",
|
||||
)
|
||||
return cams_relative
|
||||
|
||||
|
||||
# ## 3. Optimization
|
||||
# Finally, we start the optimization of the absolute cameras.
|
||||
#
|
||||
# We use SGD with momentum and optimize over `log_R_absolute` and `T_absolute`.
|
||||
#
|
||||
# As mentioned earlier, `log_R_absolute` is the axis angle representation of the rotation part of our absolute cameras. We can obtain the 3x3 rotation matrix `R_absolute` that corresponds to `log_R_absolute` with:
|
||||
#
|
||||
# `R_absolute = so3_exponential_map(log_R_absolute)`
|
||||
#
|
||||
|
||||
# In[ ]:
|
||||
|
||||
|
||||
# initialize the absolute log-rotations/translations with random entries
|
||||
log_R_absolute_init = torch.randn(N, 3).float().cuda()
|
||||
T_absolute_init = torch.randn(N, 3).float().cuda()
|
||||
|
||||
# futhermore, we know that the first camera is a trivial one
|
||||
# (see the description above)
|
||||
log_R_absolute_init[0, :] = 0.
|
||||
T_absolute_init[0, :] = 0.
|
||||
|
||||
# instantiate a copy of the initialization of log_R / T
|
||||
log_R_absolute = log_R_absolute_init.clone().detach()
|
||||
log_R_absolute.requires_grad = True
|
||||
T_absolute = T_absolute_init.clone().detach()
|
||||
T_absolute.requires_grad = True
|
||||
|
||||
# the mask the specifies which cameras are going to be optimized
|
||||
# (since we know the first camera is already correct,
|
||||
# we only optimize over the 2nd-to-last cameras)
|
||||
camera_mask = torch.ones(N, 1).float().cuda()
|
||||
camera_mask[0] = 0.
|
||||
|
||||
# init the optimizer
|
||||
optimizer = torch.optim.SGD([log_R_absolute, T_absolute], lr=.1, momentum=0.9)
|
||||
|
||||
# run the optimization
|
||||
n_iter = 2000 # fix the number of iterations
|
||||
for it in range(n_iter):
|
||||
# re-init the optimizer gradients
|
||||
optimizer.zero_grad()
|
||||
|
||||
# compute the absolute camera rotations as
|
||||
# an exponential map of the logarithms (=axis-angles)
|
||||
# of the absolute rotations
|
||||
R_absolute = so3_exponential_map(log_R_absolute * camera_mask)
|
||||
|
||||
# get the current absolute cameras
|
||||
cameras_absolute = SfMPerspectiveCameras(
|
||||
R = R_absolute,
|
||||
T = T_absolute * camera_mask,
|
||||
device = "cuda",
|
||||
)
|
||||
|
||||
# compute the relative cameras as a compositon of the absolute cameras
|
||||
cameras_relative_composed = get_relative_camera(cameras_absolute, relative_edges)
|
||||
|
||||
# compare the composed cameras with the ground truth relative cameras
|
||||
# camera_distance corresponds to $d$ from the description
|
||||
camera_distance = calc_camera_distance(cameras_relative_composed, cameras_relative)
|
||||
|
||||
# our loss function is the camera_distance
|
||||
camera_distance.backward()
|
||||
|
||||
# apply the gradients
|
||||
optimizer.step()
|
||||
|
||||
# plot and print status message
|
||||
if it % 200==0 or it==n_iter-1:
|
||||
status = 'iteration=%3d; camera_distance=%1.3e' % (it, camera_distance)
|
||||
plot_camera_scene(cameras_absolute, cameras_absolute_gt, status)
|
||||
|
||||
print('Optimization finished.')
|
||||
|
@ -0,0 +1,280 @@
|
||||
#!/usr/bin/env python
|
||||
# coding: utf-8
|
||||
|
||||
# In[5]:
|
||||
|
||||
|
||||
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||
|
||||
|
||||
# # Camera position optimization using differentiable rendering
|
||||
#
|
||||
# In this tutorial we will learn the [x, y, z] position of a camera given a reference image using differentiable rendering.
|
||||
#
|
||||
# We will first initialize a renderer with a starting position for the camera. We will then use this to generate an image, compute a loss with the reference image, and finally backpropagate through the entire pipeline to update the position of the camera.
|
||||
#
|
||||
# This tutorial shows how to:
|
||||
# - load a mesh from an `.obj` file
|
||||
# - initialize a `Camera`, `Shader` and `Renderer`,
|
||||
# - render a mesh
|
||||
# - set up an optimization loop with a loss function and optimizer
|
||||
#
|
||||
|
||||
# ## Set up and imports
|
||||
|
||||
# In[5]:
|
||||
|
||||
|
||||
import os
|
||||
import torch
|
||||
import numpy as np
|
||||
from tqdm import tqdm_notebook
|
||||
import imageio
|
||||
import torch.nn as nn
|
||||
import torch.nn.functional as F
|
||||
import matplotlib.pyplot as plt
|
||||
from skimage import img_as_ubyte
|
||||
|
||||
# io utils
|
||||
from pytorch3d.io import load_obj
|
||||
|
||||
# datastructures
|
||||
from pytorch3d.structures import Meshes, Textures
|
||||
|
||||
# 3D transformations functions
|
||||
from pytorch3d.transforms import Rotate, Translate
|
||||
|
||||
# rendering components
|
||||
from pytorch3d.renderer import (
|
||||
OpenGLPerspectiveCameras, look_at_view_transform, look_at_rotation,
|
||||
RasterizationSettings, MeshRenderer, MeshRasterizer, BlendParams,
|
||||
SilhouetteShader, PhongShader, PointLights
|
||||
)
|
||||
|
||||
|
||||
# ### Load the Obj
|
||||
#
|
||||
# We will load an obj file and create a **Meshes** object. **Meshes** is a unique datastructure provided in PyTorch3d for working with **batches of meshes of different sizes**. It has several useful class methods which are used in the rendering pipeline.
|
||||
|
||||
# In[6]:
|
||||
|
||||
|
||||
# Set the cuda device
|
||||
device = torch.device("cuda:0")
|
||||
torch.cuda.set_device(device)
|
||||
|
||||
# Load the obj and ignore the textures and materials.
|
||||
verts, faces_idx, _ = load_obj("./data/teapot.obj")
|
||||
faces = faces_idx.verts_idx
|
||||
|
||||
# Initialize each vertex to be white in color.
|
||||
verts_rgb = torch.ones_like(verts)[None] # (1, V, 3)
|
||||
textures = Textures(verts_rgb=verts_rgb.to(device))
|
||||
|
||||
# Create a Meshes object for the teapot. Here we have only one mesh in the batch.
|
||||
teapot_mesh = Meshes(
|
||||
verts=[verts.to(device)],
|
||||
faces=[faces.to(device)],
|
||||
textures=textures
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
#
|
||||
# ## Optimization setup
|
||||
|
||||
# ### Create a renderer
|
||||
#
|
||||
# A **renderer** in PyTorch3d is composed of a **rasterizer** and a **shader** which each have a number of subcomponents such as a **camera** (orthgraphic/perspective). Here we initialize some of these components and use default values for the rest.
|
||||
#
|
||||
# For optimizing the camera position we will use a renderer which produces a **silhouette** of the object only and does not apply any **lighting** or **shading**. We will also initialize another renderer which applies full **phong shading** and use this for visualizing the outputs.
|
||||
|
||||
# In[7]:
|
||||
|
||||
|
||||
# Initialize an OpenGL perspective camera.
|
||||
cameras = OpenGLPerspectiveCameras(device=device)
|
||||
|
||||
# To blend the 100 faces we set a few parameters which control the opacity and the sharpness of
|
||||
# edges. Refer to blending.py for more details.
|
||||
blend_params = BlendParams(sigma=1e-4, gamma=1e-4)
|
||||
|
||||
# Define the settings for rasterization and shading. Here we set the output image to be of size
|
||||
# 256x256. To form the blended image we use 100 faces for each pixel. Refer to rasterize_meshes.py
|
||||
# for an explanation of this parameter.
|
||||
raster_settings = RasterizationSettings(
|
||||
image_size=256,
|
||||
blur_radius=np.log(1. / 1e-4 - 1.) * blend_params.sigma,
|
||||
faces_per_pixel=100,
|
||||
bin_size=0
|
||||
)
|
||||
|
||||
# Create a silhouette mesh renderer by composing a rasterizer and a shader.
|
||||
silhouette_renderer = MeshRenderer(
|
||||
rasterizer=MeshRasterizer(
|
||||
cameras=cameras,
|
||||
raster_settings=raster_settings
|
||||
),
|
||||
shader=SilhouetteShader(blend_params=blend_params)
|
||||
)
|
||||
|
||||
|
||||
# We will also create a phong renderer. This is simpler and only needs to render one face per pixel.
|
||||
raster_settings = RasterizationSettings(
|
||||
image_size=256,
|
||||
blur_radius=0.0,
|
||||
faces_per_pixel=1,
|
||||
bin_size=0
|
||||
)
|
||||
# We can add a point light in front of the object.
|
||||
lights = PointLights(device=device, location=((2.0, 2.0, -2.0),))
|
||||
phong_renderer = MeshRenderer(
|
||||
rasterizer=MeshRasterizer(
|
||||
cameras=cameras,
|
||||
raster_settings=raster_settings
|
||||
),
|
||||
shader=PhongShader(device=device, lights=lights)
|
||||
)
|
||||
|
||||
|
||||
# ### Create a reference image
|
||||
#
|
||||
# We will first position the teapot and generate an image. We use helper functions to rotate the teapot to a desired viewpoint. Then we can use the renderers to produce an image. Here we will use both renderers and visualize the silhouette and full shaded image.
|
||||
|
||||
# In[8]:
|
||||
|
||||
|
||||
# Select the viewpoint using spherical angles
|
||||
distance = 3 # distance from camera to the object
|
||||
elevation = 40.0 # angle of elevation in degrees
|
||||
azimuth = 10.0 # angle of azimuth rotation in degrees
|
||||
|
||||
# Get the position of the camera based on the spherical angles
|
||||
R, T = look_at_view_transform(distance, elevation, azimuth, device=device)
|
||||
|
||||
# Render the teapot providing the values of R and T.
|
||||
silhouete = silhouette_renderer(meshes_world=teapot_mesh, R=R, T=T)
|
||||
image_ref = phong_renderer(meshes_world=teapot_mesh, R=R, T=T)
|
||||
|
||||
silhouete = silhouete.cpu().numpy()
|
||||
image_ref = image_ref.cpu().numpy()
|
||||
|
||||
plt.figure(figsize=(10, 10))
|
||||
plt.subplot(1, 2, 1)
|
||||
plt.imshow(silhouete.squeeze()[..., 3]) # only plot the alpha channel of the RGBA image
|
||||
plt.grid("off")
|
||||
plt.subplot(1, 2, 2)
|
||||
plt.imshow(image_ref.squeeze())
|
||||
plt.grid("off")
|
||||
|
||||
|
||||
# ### Set up a basic model
|
||||
#
|
||||
# Here we create a simple model class and initialize a parameter for the camera position.
|
||||
|
||||
# In[10]:
|
||||
|
||||
|
||||
class Model(nn.Module):
|
||||
def __init__(self, meshes, renderer, image_ref):
|
||||
super().__init__()
|
||||
self.meshes = meshes
|
||||
self.device = meshes.device
|
||||
self.renderer = renderer
|
||||
|
||||
# Get the silhouette of the reference RGB image by finding all the non zero values.
|
||||
image_ref = torch.from_numpy((image_ref[..., :3].max(-1) != 0).astype(np.float32))
|
||||
self.register_buffer('image_ref', image_ref)
|
||||
|
||||
# Create an optimizable parameter for the x, y, z position of the camera.
|
||||
self.camera_position = nn.Parameter(
|
||||
torch.from_numpy(np.array([3.0, 6.9, -2.5], dtype=np.float32)).to(meshes.device))
|
||||
|
||||
def forward(self):
|
||||
|
||||
# Render the image using the updated camera position. Based on the new position of the
|
||||
# camer we calculate the rotation and translation matrices
|
||||
R = look_at_rotation(self.camera_position[None, :], device=self.device) # (1, 3, 3)
|
||||
T = -torch.bmm(R.transpose(1, 2), self.camera_position[None, :, None])[:, :, 0] # (1, 3)
|
||||
|
||||
image = self.renderer(meshes_world=self.meshes.clone(), R=R, T=T)
|
||||
|
||||
# Calculate the silhouette loss
|
||||
loss = torch.sum((image[..., 3] - self.image_ref) ** 2)
|
||||
return loss, image
|
||||
|
||||
|
||||
|
||||
# ## Initialize the model and optimizer
|
||||
#
|
||||
# Now we can create an instance of the **model** above and set up an **optimizer** for the camera position parameter.
|
||||
|
||||
# In[11]:
|
||||
|
||||
|
||||
# We will save images periodically and compose them into a GIF.
|
||||
filename_output = "./teapot_optimization_demo.gif"
|
||||
writer = imageio.get_writer(filename_output, mode='I', duration=0.3)
|
||||
|
||||
# Initialize a model using the renderer, mesh and reference image
|
||||
model = Model(meshes=teapot_mesh, renderer=silhouette_renderer, image_ref=image_ref).to(device)
|
||||
|
||||
# Create an optimizer. Here we are using Adam and we pass in the parameters of the model
|
||||
optimizer = torch.optim.Adam(model.parameters(), lr=0.05)
|
||||
|
||||
|
||||
# ## Visualise the starting position and the reference position
|
||||
|
||||
# In[12]:
|
||||
|
||||
|
||||
plt.figure(figsize=(10, 10))
|
||||
|
||||
_, image_init = model()
|
||||
plt.subplot(1, 2, 1)
|
||||
plt.imshow(image_init.detach().squeeze().cpu().numpy()[..., 3])
|
||||
plt.grid("off")
|
||||
plt.title("Starting position")
|
||||
|
||||
plt.subplot(1, 2, 2)
|
||||
plt.imshow(model.image_ref.cpu().numpy().squeeze())
|
||||
plt.grid("off")
|
||||
plt.title("Reference silhouette")
|
||||
|
||||
|
||||
# ## Run the optimization
|
||||
#
|
||||
# We run several iterations of the forward and backward pass and save outputs every 10 iterations. When this has finished take a look at `./teapot_optimization_demo.gif` for a cool gif of the optimization process!
|
||||
|
||||
# In[13]:
|
||||
|
||||
|
||||
loop = tqdm_notebook(range(200))
|
||||
for i in loop:
|
||||
optimizer.zero_grad()
|
||||
loss, _ = model()
|
||||
loss.backward()
|
||||
optimizer.step()
|
||||
|
||||
loop.set_description('Optimizing (loss %.4f)' % loss.data)
|
||||
|
||||
if loss.item() < 200:
|
||||
break
|
||||
|
||||
# Save outputs to create a GIF.
|
||||
if i % 10 == 0:
|
||||
R = look_at_rotation(model.camera_position[None, :], device=model.device)
|
||||
T = -torch.bmm(R.transpose(1, 2), model.camera_position[None, :, None])[:, :, 0] # (1, 3)
|
||||
image = phong_renderer(meshes_world=model.meshes.clone(), R=R, T=T)
|
||||
image = image[0, ..., :3].detach().squeeze().cpu().numpy()
|
||||
image = img_as_ubyte(image)
|
||||
writer.append_data(image)
|
||||
|
||||
plt.figure()
|
||||
plt.imshow(image[..., :3])
|
||||
plt.title("iter: %d, loss: %0.2f" % (i, loss.data))
|
||||
plt.grid("off")
|
||||
plt.axis("off")
|
||||
|
||||
writer.close()
|
||||
|
2149
files/deform_source_mesh_to_target_mesh.ipynb
Normal file
253
files/deform_source_mesh_to_target_mesh.py
Normal file
@ -0,0 +1,253 @@
|
||||
#!/usr/bin/env python
|
||||
# coding: utf-8
|
||||
|
||||
# In[1]:
|
||||
|
||||
|
||||
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||
|
||||
|
||||
# # Deform a source mesh to form a target mesh using 3D loss functions
|
||||
|
||||
# In this tutorial, we learn to deform an initial generic shape (e.g. sphere) to fit a target shape.
|
||||
#
|
||||
# We will cover:
|
||||
#
|
||||
# - How to **load a mesh** from an `.obj` file
|
||||
# - How to use the PyTorch3d **Meshes** datastructure
|
||||
# - How to use 4 different PyTorch3d **mesh loss functions**
|
||||
# - How to set up an **optimization loop**
|
||||
#
|
||||
#
|
||||
# Starting from a sphere mesh, we learn the offset to each vertex in the mesh such that
|
||||
# the predicted mesh is closer to the target mesh at each optimization step. To achieve this we minimize:
|
||||
#
|
||||
# + `chamfer_distance`, the distance between the predicted (deformed) and target mesh, defined as the chamfer distance between the set of pointclouds resulting from **differentiably sampling points** from their surfaces.
|
||||
#
|
||||
# However, solely minimizing the chamfer distance between the predicted and the target mesh will lead to a non-smooth shape (verify this by setting `w_chamfer=1.0` and all other weights to `0.0`).
|
||||
#
|
||||
# We enforce smoothness by adding **shape regularizers** to the objective. Namely, we add:
|
||||
#
|
||||
# + `mesh_edge_length`, which minimizes the length of the edges in the predicted mesh.
|
||||
# + `mesh_normal_consistency`, which enforces consistency across the normals of neighboring faces.
|
||||
# + `mesh_laplacian_smoothing`, which is the laplacian regularizer.
|
||||
|
||||
# ## 0. Import modules
|
||||
|
||||
# In[2]:
|
||||
|
||||
|
||||
import os
|
||||
import torch
|
||||
from pytorch3d.io import load_obj, save_obj
|
||||
from pytorch3d.structures import Meshes
|
||||
from pytorch3d.utils import ico_sphere
|
||||
from pytorch3d.ops import sample_points_from_meshes
|
||||
from pytorch3d.loss import (
|
||||
chamfer_distance,
|
||||
mesh_edge_loss,
|
||||
mesh_laplacian_smoothing,
|
||||
mesh_normal_consistency,
|
||||
)
|
||||
import numpy as np
|
||||
from tqdm import tqdm_notebook
|
||||
get_ipython().run_line_magic('matplotlib', 'notebook')
|
||||
from mpl_toolkits.mplot3d import Axes3D
|
||||
import matplotlib.pyplot as plt
|
||||
import matplotlib as mpl
|
||||
mpl.rcParams['savefig.dpi'] = 80
|
||||
mpl.rcParams['figure.dpi'] = 80
|
||||
|
||||
# Set the device
|
||||
device = torch.device("cuda:0")
|
||||
|
||||
|
||||
# ## 1. Load an obj file and create a Meshes object
|
||||
|
||||
# In[4]:
|
||||
|
||||
|
||||
# The path to the target 3D model we wish to fit
|
||||
# e.g. download https://free3d.com/3d-model/-dolphin-v1--12175.html and save in ./data/dolphin
|
||||
trg_obj = os.path.join('./data/doplhin', '10014_dolphin_v2_max2011_it2.obj')
|
||||
|
||||
|
||||
# In[6]:
|
||||
|
||||
|
||||
# We read the target 3D model using load_obj
|
||||
verts, faces, aux = load_obj(trg_obj)
|
||||
|
||||
# verts is a FloatTensor of shape (V, 3) where V is the number of vertices in the mesh
|
||||
# faces is an object which contains the following LongTensors: verts_idx, normals_idx and textures_idx
|
||||
# For this tutorial, normals and textures are ignored.
|
||||
faces_idx = faces.verts_idx.to(device)
|
||||
verts = verts.to(device)
|
||||
|
||||
# We scale normalize and center the target mesh to fit in a sphere of radius 1 centered at (0,0,0).
|
||||
# (scale, center) will be used to bring the predicted mesh to its original center and scale
|
||||
# Note that normalizing the target mesh, speeds up the optimization but is not necessary!
|
||||
center = verts.mean(0)
|
||||
verts = verts - center
|
||||
scale = max(verts.abs().max(0)[0])
|
||||
verts = verts / scale
|
||||
|
||||
# We construct a Meshes structure for the target mesh
|
||||
trg_mesh = Meshes(verts=[verts], faces=[faces_idx])
|
||||
|
||||
|
||||
# In[11]:
|
||||
|
||||
|
||||
# We initialize the source shape to be a sphere of radius 1
|
||||
src_mesh = ico_sphere(4, device)
|
||||
|
||||
|
||||
# ### Visualize the source and target meshes
|
||||
|
||||
# In[12]:
|
||||
|
||||
|
||||
def plot_pointcloud(mesh, title=""):
|
||||
verts = mesh.verts_packed()
|
||||
faces = mesh.faces_packed()
|
||||
x, y, z = verts.clone().detach().cpu().unbind(1)
|
||||
fig = plt.figure(figsize=(5, 5))
|
||||
ax = Axes3D(fig)
|
||||
ax.scatter3D(x, z, -y)
|
||||
ax.set_xlabel('x')
|
||||
ax.set_ylabel('z')
|
||||
ax.set_zlabel('y')
|
||||
ax.set_title(title)
|
||||
plt.show()
|
||||
|
||||
|
||||
# In[13]:
|
||||
|
||||
|
||||
get_ipython().run_line_magic('matplotlib', 'notebook')
|
||||
plot_pointcloud(trg_mesh, "Target mesh")
|
||||
plot_pointcloud(src_mesh, "Source mesh")
|
||||
|
||||
|
||||
# ## 3. Optimization loop
|
||||
|
||||
# In[14]:
|
||||
|
||||
|
||||
# We will learn to deform the source mesh by offsetting its vertices
|
||||
# The shape of the derform parameters is equal to the total number of vertices in src_mesh
|
||||
deform_verts = torch.full(src_mesh.verts_packed().shape, 0.0, device=device, requires_grad=True)
|
||||
|
||||
|
||||
# In[15]:
|
||||
|
||||
|
||||
# The optimizer
|
||||
optimizer = torch.optim.SGD([deform_verts], lr=1.0, momentum=0.9)
|
||||
|
||||
|
||||
# In[16]:
|
||||
|
||||
|
||||
# Number of optimization steps
|
||||
Niter = 2000
|
||||
# Weight for the chamfer loss
|
||||
w_chamfer = 1.0
|
||||
# Weight for mesh edge loss
|
||||
w_edge = 1.0
|
||||
# Weight for mesh normal consistency
|
||||
w_normal = 0.01
|
||||
# Weight for mesh laplacian smoothing
|
||||
w_laplacian = 0.1
|
||||
# Plot period for the losses
|
||||
plot_period = 250
|
||||
loop = tqdm_notebook(range(Niter))
|
||||
|
||||
chamfer_losses = []
|
||||
laplacian_losses = []
|
||||
edge_losses = []
|
||||
normal_losses = []
|
||||
|
||||
get_ipython().run_line_magic('matplotlib', 'inline')
|
||||
|
||||
for i in loop:
|
||||
# Initialize optimizer
|
||||
optimizer.zero_grad()
|
||||
|
||||
# Deform the mesh
|
||||
new_src_mesh = src_mesh.offset_verts(deform_verts)
|
||||
|
||||
# We sample 5k points from the surface of each mesh
|
||||
sample_trg = sample_points_from_meshes(trg_mesh, 5000)
|
||||
sample_src = sample_points_from_meshes(new_src_mesh, 5000)
|
||||
|
||||
# We compare the two sets of pointclouds by computing (a) the chamfer loss
|
||||
loss_chamfer, _ = chamfer_distance(sample_trg, sample_src)
|
||||
|
||||
# and (b) the edge length of the predicted mesh
|
||||
loss_edge = mesh_edge_loss(new_src_mesh)
|
||||
|
||||
# mesh normal consistency
|
||||
loss_normal = mesh_normal_consistency(new_src_mesh)
|
||||
|
||||
# mesh laplacian smoothing
|
||||
loss_laplacian = mesh_laplacian_smoothing(new_src_mesh, method="uniform")
|
||||
|
||||
# Weighted sum of the losses
|
||||
loss = loss_chamfer * w_chamfer + loss_edge * w_edge + loss_normal * w_normal + loss_laplacian * w_laplacian
|
||||
|
||||
# Print the losses
|
||||
loop.set_description('total_loss = %.6f' % loss)
|
||||
|
||||
# Save the losses for plotting
|
||||
chamfer_losses.append(loss_chamfer)
|
||||
edge_losses.append(loss_edge)
|
||||
normal_losses.append(loss_normal)
|
||||
laplacian_losses.append(loss_laplacian)
|
||||
|
||||
# Plot mesh
|
||||
if i % plot_period == 0:
|
||||
plot_pointcloud(new_src_mesh, title="iter: %d" % i)
|
||||
|
||||
# Optimization step
|
||||
loss.backward()
|
||||
optimizer.step()
|
||||
|
||||
|
||||
# ## 4. Visualize the loss
|
||||
|
||||
# In[17]:
|
||||
|
||||
|
||||
fig = plt.figure(figsize=(13, 5))
|
||||
ax = fig.gca()
|
||||
ax.plot(chamfer_losses, label="chamfer loss")
|
||||
ax.plot(edge_losses, label="edge loss")
|
||||
ax.plot(normal_losses, label="normal loss")
|
||||
ax.plot(laplacian_losses, label="laplacian loss")
|
||||
ax.legend(fontsize="16")
|
||||
ax.set_xlabel("Iteration", fontsize="16")
|
||||
ax.set_ylabel("Loss", fontsize="16")
|
||||
ax.set_title("Loss vs iterations", fontsize="16")
|
||||
|
||||
|
||||
# ## 5. Save the predicted mesh
|
||||
|
||||
# In[ ]:
|
||||
|
||||
|
||||
# Fetch the verts and faces of the final predicted mesh
|
||||
final_verts, final_faces = new_src_mesh.get_mesh_verts_faces(0)
|
||||
|
||||
# Scale normalize back to the original target size
|
||||
final_verts = final_verts * scale + center
|
||||
|
||||
# Store the predicted mesh using save_obj
|
||||
final_obj = os.path.join('./', 'final_model.obj')
|
||||
save_obj(final_obj, final_verts, final_faces)
|
||||
|
||||
|
||||
# ## 6. Conclusion
|
||||
#
|
||||
# In this tutorial we learnt how to load a mesh from an obj file, initialize a PyTorch3d datastructure called **Meshes**, set up an optimization loop and use four different PyTorch3d mesh loss functions.
|
494
files/render_textured_meshes.ipynb
Normal file
268
files/render_textured_meshes.py
Normal file
@ -0,0 +1,268 @@
|
||||
#!/usr/bin/env python
|
||||
# coding: utf-8
|
||||
|
||||
# In[ ]:
|
||||
|
||||
|
||||
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||
|
||||
|
||||
# # Render a textured mesh
|
||||
#
|
||||
# This tutorial shows how to:
|
||||
# - load a mesh and textures from an `.obj` file.
|
||||
# - set up a renderer
|
||||
# - render the mesh
|
||||
# - vary the rendering settings such as lighting and camera position
|
||||
# - use the batching features of the pytorch3d API to render the mesh from different viewpoints
|
||||
|
||||
# ## Import modules
|
||||
|
||||
# In[1]:
|
||||
|
||||
|
||||
import os
|
||||
import torch
|
||||
import matplotlib.pyplot as plt
|
||||
from skimage.io import imread
|
||||
|
||||
# Util function for loading meshes
|
||||
from pytorch3d.io import load_obj
|
||||
|
||||
# Data structures and functions for rendering
|
||||
from pytorch3d.structures import Meshes, Textures
|
||||
from pytorch3d.renderer import (
|
||||
look_at_view_transform,
|
||||
OpenGLPerspectiveCameras,
|
||||
PointLights,
|
||||
DirectionalLights,
|
||||
Materials,
|
||||
RasterizationSettings,
|
||||
MeshRenderer,
|
||||
MeshRasterizer,
|
||||
TexturedPhongShader
|
||||
)
|
||||
|
||||
# add path for demo utils
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.path.abspath(''))
|
||||
from utils import image_grid
|
||||
|
||||
|
||||
# ### Load a mesh and texture file
|
||||
#
|
||||
# Load an `.obj` file and it's associated `.mtl` file and create a **Textures** and **Meshes** object.
|
||||
#
|
||||
# **Meshes** is a unique datastructure provided in PyTorch3d for working with batches of meshes of different sizes.
|
||||
#
|
||||
# **Textures** is an auxillary datastructure for storing texture information about meshes.
|
||||
#
|
||||
# **Meshes** has several class methods which are used throughout the rendering pipeline.
|
||||
|
||||
# In[2]:
|
||||
|
||||
|
||||
# Setup
|
||||
device = torch.device("cuda:0")
|
||||
torch.cuda.set_device(device)
|
||||
|
||||
# Set paths
|
||||
DATA_DIR = "./data"
|
||||
obj_filename = os.path.join(DATA_DIR, "cow_mesh/cow.obj")
|
||||
|
||||
# Load obj file
|
||||
verts, faces, aux = load_obj(obj_filename)
|
||||
faces_idx = faces.verts_idx.to(device)
|
||||
verts = verts.to(device)
|
||||
|
||||
# Get textures from the outputs of the load_obj function
|
||||
# the `aux` variable contains the texture maps and vertex uv coordinates.
|
||||
# Refer to the `obj_io.load_obj` function for full API reference.
|
||||
# Here we only have one texture map for the whole mesh.
|
||||
verts_uvs = aux.verts_uvs[None, ...].to(device) # (N, V, 2)
|
||||
faces_uvs = faces.textures_idx[None, ...].to(device) # (N, F, 3)
|
||||
tex_maps = aux.texture_images
|
||||
texture_image = list(tex_maps.values())[0]
|
||||
texture_image = texture_image[None, ...].to(device) # (N, H, W, 3)
|
||||
|
||||
# Create a textures object
|
||||
tex = Textures(verts_uvs=verts_uvs, faces_uvs=faces_uvs, maps=texture_image)
|
||||
|
||||
# Create a meshes object with textures
|
||||
mesh = Meshes(verts=[verts], faces=[faces_idx], textures=tex)
|
||||
|
||||
|
||||
# #### Let's visualize the texture map
|
||||
|
||||
# In[3]:
|
||||
|
||||
|
||||
plt.figure(figsize=(7,7))
|
||||
plt.imshow(texture_image.squeeze().cpu().numpy())
|
||||
plt.grid("off")
|
||||
plt.axis('off')
|
||||
|
||||
|
||||
# ## Create a renderer
|
||||
#
|
||||
# A renderer in PyTorch3d is composed of a **rasterizer** and a **shader** which each have a number of subcomponents such as a **camera** (orthgraphic/perspective). Here we initialize some of these components and use default values for the rest.
|
||||
#
|
||||
# In this example we will first create a **renderer** which uses a **perspective camera**, a **point light** and applies **phong shading**. Then we learn how to vary different components using the modular API.
|
||||
|
||||
# In[4]:
|
||||
|
||||
|
||||
# Initialize an OpenGL perspective camera.
|
||||
R, T = look_at_view_transform(2.7, 10, 20)
|
||||
cameras = OpenGLPerspectiveCameras(device=device, R=R, T=T)
|
||||
|
||||
# Define the settings for rasterization and shading. Here we set the output image to be of size
|
||||
# 512x512. As we are rendering images for visualization purposes only we will set faces_per_pixel=1
|
||||
# and blur_radius=0.0. Refer to rasterize_meshes.py for explanations of these parameters.
|
||||
raster_settings = RasterizationSettings(
|
||||
image_size=512,
|
||||
blur_radius=0.0,
|
||||
faces_per_pixel=1,
|
||||
bin_size=0
|
||||
)
|
||||
|
||||
# Place a point light in front of the object
|
||||
lights = PointLights(device=device, location=[[1.0, 1.0, -2.0]])
|
||||
|
||||
# Create a phong renderer by composing a rasterizer and a shader. The textured phong shader will
|
||||
# interpolate the texture uv coordinates for each vertex, sample from a texture image and
|
||||
# apply the Phong lighting model
|
||||
renderer = MeshRenderer(
|
||||
rasterizer=MeshRasterizer(
|
||||
cameras=cameras,
|
||||
raster_settings=raster_settings
|
||||
),
|
||||
shader=TexturedPhongShader(
|
||||
device=device,
|
||||
cameras=cameras,
|
||||
lights=lights
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
# ## Render the mesh
|
||||
|
||||
# The light is in front of the object so it is bright and the image has specular highlights.
|
||||
|
||||
# In[5]:
|
||||
|
||||
|
||||
images = renderer(mesh)
|
||||
plt.figure(figsize=(10, 10))
|
||||
plt.imshow(images[0, ..., :3].cpu().numpy())
|
||||
plt.grid("off")
|
||||
plt.axis("off")
|
||||
|
||||
|
||||
# ## Move the light behind the object and re-render
|
||||
#
|
||||
# We can pass arbirary keyword arguments to the `rasterizer`/`shader` via the call to the `renderer` so the renderer does not need to be reinitialized if any of the settings change/
|
||||
#
|
||||
# In this case, we can simply update the location of the lights and pass them into the call to the renderer.
|
||||
#
|
||||
# The image is now dark as there is only ambient lighting, and there are no specular highlights.
|
||||
|
||||
# In[6]:
|
||||
|
||||
|
||||
lights.location = torch.tensor([0.0, 0.0, +1.0], device=device)[None]
|
||||
images = renderer(mesh, lights=lights)
|
||||
|
||||
|
||||
# In[7]:
|
||||
|
||||
|
||||
plt.figure(figsize=(10, 10))
|
||||
plt.imshow(images[0, ..., :3].cpu().numpy())
|
||||
plt.grid("off")
|
||||
plt.axis("off")
|
||||
|
||||
|
||||
# ## Rotate the object, modify the material properties or light properties
|
||||
#
|
||||
# We can also change many other settings in the rendering pipeline. Here we:
|
||||
#
|
||||
# - change the **viewing angle** of the camera
|
||||
# - change the **position** of the point light
|
||||
# - change the **material reflectance** properties of the mesh
|
||||
|
||||
# In[8]:
|
||||
|
||||
|
||||
# Rotate the object by increasing the azimuth angle
|
||||
R, T = look_at_view_transform(dist=2.7, elev=10, azim=50)
|
||||
cameras = OpenGLPerspectiveCameras(device=device, R=R, T=T)
|
||||
|
||||
# Move the light location to be in front of the object again
|
||||
lights.location = torch.tensor([[5.0, 5.0, -2.0]], device=device)
|
||||
|
||||
# Change specular color to green and change material shininess
|
||||
materials = Materials(
|
||||
device=device,
|
||||
specular_color=[[0.0, 1.0, 0.0]],
|
||||
shininess=10.0
|
||||
)
|
||||
|
||||
# Re render the mesh, passing in keyword arguments for the modified components.
|
||||
images = renderer(mesh, lights=lights, materials=materials, cameras=cameras)
|
||||
|
||||
|
||||
# In[9]:
|
||||
|
||||
|
||||
plt.figure(figsize=(10, 10))
|
||||
plt.imshow(images[0, ..., :3].cpu().numpy())
|
||||
plt.grid("off")
|
||||
plt.axis("off")
|
||||
|
||||
|
||||
# ## Batched Rendering
|
||||
#
|
||||
# One of the core design choices of the PyTorch3d API is to suport **batched inputs for all components**.
|
||||
# The renderer and associated components can take batched inputs and **render a batch of output images in one forward pass**. We will now use this feature to render the mesh from many different viewpoints.
|
||||
#
|
||||
|
||||
# In[10]:
|
||||
|
||||
|
||||
# Set batch size - this is the number of different viewpoints from which we want to render the mesh.
|
||||
batch_size = 20
|
||||
|
||||
# Create a batch of meshes by repeating the cow mesh and associated textures.
|
||||
# Meshes has a useful `extend` method which allows us do this very easily.
|
||||
# This also extends the textures.
|
||||
meshes = mesh.extend(batch_size)
|
||||
|
||||
# Get a batch of viewing angles.
|
||||
elev = torch.linspace(0, 360, batch_size)
|
||||
azim = torch.linspace(0, 360, batch_size)
|
||||
|
||||
# All the cameras helper methods support mixed type inputs and broadcasting. So we can
|
||||
# view the camera from the same distance and specify dist=2.7 as a float,
|
||||
# and then specify elevation and azimuth angles for each viewpoint as tensors.
|
||||
R, T = look_at_view_transform(dist=2.7, elev=elev, azim=azim)
|
||||
cameras = OpenGLPerspectiveCameras(device=device, R=R, T=T)
|
||||
|
||||
# Move the light back in front of the object
|
||||
lights.location = torch.tensor([[1.0, 1.0, -5.0]], device=device)
|
||||
|
||||
|
||||
# In[11]:
|
||||
|
||||
|
||||
# We can pass arbirary keyword arguments to the rasterizer/shader via the renderer
|
||||
# so the renderer does not need to be reinitialized if any of the settings change.
|
||||
images = renderer(meshes, cameras=cameras, lights=lights)
|
||||
|
||||
|
||||
# In[12]:
|
||||
|
||||
|
||||
image_grid(images.cpu().numpy(), rows=4, cols=5, rgb=True)
|
||||
|
15
help.html
Normal file
@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html><html lang=""><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>PyTorch3d · A library for deep learning with 3D data</title><meta name="viewport" content="width=device-width"/><meta name="generator" content="Docusaurus"/><meta name="description" content="A library for deep learning with 3D data"/><meta property="og:title" content="PyTorch3d · A library for deep learning with 3D data"/><meta property="og:type" content="website"/><meta property="og:url" content="https://pytorch3d.org/"/><meta property="og:description" content="A library for deep learning with 3D data"/><meta property="og:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><meta name="twitter:card" content="summary"/><meta name="twitter:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><link rel="shortcut icon" href="/img/pytorch3dfavicon.png"/><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css"/><script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-157376881-1', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script><script type="text/javascript" src="https://buttons.github.io/buttons.js"></script><script src="/js/scrollSpy.js"></script><link rel="stylesheet" href="/css/main.css"/><script src="/js/codetabs.js"></script></head><body><div class="fixedHeaderContainer"><div class="headerWrapper wrapper"><header><a href="/"><img class="logo" src="/img/pytorch3dfavicon.png" alt="PyTorch3d"/><h2 class="headerTitleWithLogo">PyTorch3d</h2></a><div class="navigationWrapper navigationSlider"><nav class="slidingNav"><ul class="nav-site nav-site-internal"><li class=""><a href="/docs/why_pytorch3d" target="_self">Docs</a></li><li class=""><a href="/tutorials" target="_self">Tutorials</a></li><li class=""><a href="https://pytorch3d.readthedocs.io/" target="_self">API</a></li><li class=""><a href="https://github.com/facebookresearch/pytorch3d" target="_self">GitHub</a></li></ul></nav></div></header></div></div><div class="navPusher"><div class="docMainWrapper wrapper"><div class="container mainContainer documentContainer postContainer"><div class="wrapper"><div class="post"><header class="postHeader"><h1>Need help?</h1></header><p>This project is maintained by a dedicated group of people.</p><div class="gridBlock"><div class="blockElement threeByGridBlock"><div class="blockContent"><h2><div><span><p>Browse Docs</p>
|
||||
</span></div></h2><div><span><p>Learn more using the <a href="/docs/doc1.html">documentation on this site.</a></p>
|
||||
</span></div></div></div><div class="blockElement threeByGridBlock"><div class="blockContent"><h2><div><span><p>Join the community</p>
|
||||
</span></div></h2><div><span><p>Ask questions about the documentation and project</p>
|
||||
</span></div></div></div><div class="blockElement threeByGridBlock"><div class="blockContent"><h2><div><span><p>Stay up to date</p>
|
||||
</span></div></h2><div><span><p>Find out what's new with this project</p>
|
||||
</span></div></div></div></div></div></div></div></div><footer class="nav-footer" id="footer"><section class="sitemap"><div class="footerSection"><div class="social"><a class="github-button" href="https://github.com/facebookresearch/pytorch3d" data-count-href="https://github.com/facebookresearch/pytorch3d/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star PyTorch3d on GitHub">pytorch3d</a></div></div></section><a href="https://opensource.facebook.com/" target="_blank" rel="noreferrer noopener" class="fbOpenSource"><img src="/img/oss_logo.png" alt="Facebook Open Source" width="170" height="45"/></a><section class="copyright">Copyright "©" 2020 Facebook Inc</section></footer></div></body></html>
|
15
help/index.html
Normal file
@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html><html lang=""><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>PyTorch3d · A library for deep learning with 3D data</title><meta name="viewport" content="width=device-width"/><meta name="generator" content="Docusaurus"/><meta name="description" content="A library for deep learning with 3D data"/><meta property="og:title" content="PyTorch3d · A library for deep learning with 3D data"/><meta property="og:type" content="website"/><meta property="og:url" content="https://pytorch3d.org/"/><meta property="og:description" content="A library for deep learning with 3D data"/><meta property="og:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><meta name="twitter:card" content="summary"/><meta name="twitter:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><link rel="shortcut icon" href="/img/pytorch3dfavicon.png"/><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css"/><script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-157376881-1', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script><script type="text/javascript" src="https://buttons.github.io/buttons.js"></script><script src="/js/scrollSpy.js"></script><link rel="stylesheet" href="/css/main.css"/><script src="/js/codetabs.js"></script></head><body><div class="fixedHeaderContainer"><div class="headerWrapper wrapper"><header><a href="/"><img class="logo" src="/img/pytorch3dfavicon.png" alt="PyTorch3d"/><h2 class="headerTitleWithLogo">PyTorch3d</h2></a><div class="navigationWrapper navigationSlider"><nav class="slidingNav"><ul class="nav-site nav-site-internal"><li class=""><a href="/docs/why_pytorch3d" target="_self">Docs</a></li><li class=""><a href="/tutorials" target="_self">Tutorials</a></li><li class=""><a href="https://pytorch3d.readthedocs.io/" target="_self">API</a></li><li class=""><a href="https://github.com/facebookresearch/pytorch3d" target="_self">GitHub</a></li></ul></nav></div></header></div></div><div class="navPusher"><div class="docMainWrapper wrapper"><div class="container mainContainer documentContainer postContainer"><div class="wrapper"><div class="post"><header class="postHeader"><h1>Need help?</h1></header><p>This project is maintained by a dedicated group of people.</p><div class="gridBlock"><div class="blockElement threeByGridBlock"><div class="blockContent"><h2><div><span><p>Browse Docs</p>
|
||||
</span></div></h2><div><span><p>Learn more using the <a href="/docs/doc1.html">documentation on this site.</a></p>
|
||||
</span></div></div></div><div class="blockElement threeByGridBlock"><div class="blockContent"><h2><div><span><p>Join the community</p>
|
||||
</span></div></h2><div><span><p>Ask questions about the documentation and project</p>
|
||||
</span></div></div></div><div class="blockElement threeByGridBlock"><div class="blockContent"><h2><div><span><p>Stay up to date</p>
|
||||
</span></div></h2><div><span><p>Find out what's new with this project</p>
|
||||
</span></div></div></div></div></div></div></div></div><footer class="nav-footer" id="footer"><section class="sitemap"><div class="footerSection"><div class="social"><a class="github-button" href="https://github.com/facebookresearch/pytorch3d" data-count-href="https://github.com/facebookresearch/pytorch3d/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star PyTorch3d on GitHub">pytorch3d</a></div></div></section><a href="https://opensource.facebook.com/" target="_blank" rel="noreferrer noopener" class="fbOpenSource"><img src="/img/oss_logo.png" alt="Facebook Open Source" width="170" height="45"/></a><section class="copyright">Copyright "©" 2020 Facebook Inc</section></footer></div></body></html>
|
1
img/batching.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg width="110" height="100" viewBox="0 0 110 100" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><path fill="#FF7D1E" d="M60 3h44v44H60z"/><ellipse fill="#000" cx="84.511" cy="75.989" rx="24.511" ry="23.989"/><path fill="#FFAF00" d="M28.5 53L57 98H0z"/><path fill="#812CE5" d="M26.51 0l25.213 17.959-9.63 29.058H10.927l-9.63-29.058z"/></g></svg>
|
After Width: | Height: | Size: 370 B |
BIN
img/favicon.ico
Normal file
After Width: | Height: | Size: 9.8 KiB |
3
img/language.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg class="language {{include.class}}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
|
||||
<path fill="#ffffff" d="M19.753 10.909c-.624-1.707-2.366-2.726-4.661-2.726-.09 0-.176.002-.262.006l-.016-2.063 3.525-.607c.115-.019.133-.119.109-.231-.023-.111-.167-.883-.188-.976-.027-.131-.102-.127-.207-.109-.104.018-3.25.461-3.25.461l-.013-2.078c-.001-.125-.069-.158-.194-.156l-1.025.016c-.105.002-.164.049-.162.148l.033 2.307s-3.061.527-3.144.543c-.084.014-.17.053-.151.143.019.09.19 1.094.208 1.172.018.08.072.129.188.107l2.924-.504.035 2.018c-1.077.281-1.801.824-2.256 1.303-.768.807-1.207 1.887-1.207 2.963 0 1.586.971 2.529 2.328 2.695 3.162.387 5.119-3.06 5.769-4.715 1.097 1.506.256 4.354-2.094 5.98-.043.029-.098.129-.033.207l.619.756c.08.096.206.059.256.023 2.51-1.73 3.661-4.515 2.869-6.683zm-7.386 3.188c-.966-.121-.944-.914-.944-1.453 0-.773.327-1.58.876-2.156a3.21 3.21 0 0 1 1.229-.799l.082 4.277a2.773 2.773 0 0 1-1.243.131zm2.427-.553l.046-4.109c.084-.004.166-.01.252-.01.773 0 1.494.145 1.885.361.391.217-1.023 2.713-2.183 3.758zm-8.95-7.668a.196.196 0 0 0-.196-.145h-1.95a.194.194 0 0 0-.194.144L.008 16.916c-.017.051-.011.076.062.076h1.733c.075 0 .099-.023.114-.072l1.008-3.318h3.496l1.008 3.318c.016.049.039.072.113.072h1.734c.072 0 .078-.025.062-.076-.014-.05-3.083-9.741-3.494-11.04zm-2.618 6.318l1.447-5.25 1.447 5.25H3.226z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 1.3 KiB |
BIN
img/ops.png
Normal file
After Width: | Height: | Size: 5.9 KiB |
1
img/ops.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg width="176" height="175" viewBox="0 0 176 175" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><path d="M48 91.5l20-22m-20 23l22 19m55-20l-20-22m20 23l-22 19m-22 0l11-41" fill="#FFF" stroke="#812CE5" stroke-linecap="round" stroke-linejoin="round" stroke-width="8"/><path d="M83.486 92l1.052.003c28.235.203 49.973 9.894 64.747 29.024l18.742-7.154a3.221 3.221 0 014.354 3.328l-5.254 52.91a3.221 3.221 0 01-5.384 2.055l-39.175-35.95a3.221 3.221 0 011.029-5.382l15.861-6.056c-12.9-15.2-31.37-22.778-55.828-22.778l-1.548.005c-6.61.049-10.808.483-16.554 2.055-8.742 2.393-17.839 7.063-27.596 14.77-14.424 11.392-22.415 28.435-23.943 51.5a5 5 0 11-9.978-.66c1.705-25.742 10.936-45.429 27.723-58.688 10.794-8.525 21.095-13.814 31.154-16.567 6.745-1.846 11.686-2.354 19.084-2.41L83.486 92zm2-92l1.08.004c29.2.227 51.445 11.137 66.203 32.591l18.815-6.588a3.221 3.221 0 014.26 3.447l-6.722 52.744a3.221 3.221 0 01-5.438 1.904L125.522 47.08a3.221 3.221 0 011.178-5.352l16.237-5.688C129.965 18.638 111.024 10 85.63 10l-1.501.005c-6.615.05-10.799.503-16.534 2.16-8.722 2.517-17.807 7.437-27.561 15.564-14.47 12.055-22.508 30.136-24.044 54.584a5 5 0 01-9.98-.626c1.698-27.033 10.882-47.695 27.623-61.642C44.429 11.051 54.74 5.466 64.82 2.556 71.59.603 76.551.065 83.968.006L85.486 0z" fill="#FFAF00" fill-rule="nonzero"/></g></svg>
|
After Width: | Height: | Size: 1.3 KiB |
BIN
img/oss_logo.png
Normal file
After Width: | Height: | Size: 4.3 KiB |
BIN
img/pytorch3dfavicon.png
Normal file
After Width: | Height: | Size: 9.2 KiB |
1
img/pytorch3dicon.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300"><path d="M180.57 50H61.7v200h118.87l57.73-100zm-17.73 183.91H99.77l63.07-36.41zm-85-5.89V72l85.05 49.11v57.82zm85-125.52L99.77 66.09h63.07zm16.09 27.88l34 19.62-34 19.62zM207 128l-28.1-16.23V79.35zm-28.1 92.63v-32.42L207 172z" fill="#fff"/></svg>
|
After Width: | Height: | Size: 308 B |
BIN
img/pytorch3dlogo.png
Normal file
After Width: | Height: | Size: 24 KiB |
1
img/pytorch3dlogo.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1300 330"><defs><linearGradient id="a" x1="130.95" y1="257.01" x2="198.97" y2="70.13" gradientUnits="userSpaceOnUse"><stop offset=".28" stop-color="#ffb000"/><stop offset=".75" stop-color="#812ce5"/></linearGradient><linearGradient id="b" x1="173.52" y1="233.48" x2="226.58" y2="87.7" gradientUnits="userSpaceOnUse"><stop offset=".2" stop-color="#ffb000"/><stop offset=".85" stop-color="#812ce5"/></linearGradient></defs><path d="M336.72 184.41l-18.53.22v48h-14V96.34h34.23c36 0 53.19 17.44 53.19 42.51.04 29.86-21.1 45.15-54.89 45.56zM338 109.2h-19.81v62.56l19.4-.43c25.72-.44 39.67-10.68 39.67-31.83 0-19.4-13.73-30.3-39.26-30.3zm114.45 122.3l-8.07 21.58c-9.15 24.42-18.74 31.39-32.26 31.39-7.63 0-13.3-2-19.4-4.58l4.14-12.42c4.8 2.61 9.81 4.36 15.26 4.36 7.63 0 13.3-4.14 20.49-23.11l6.76-17.66-39-98.32H415l31.4 82.41 30.74-82.41h14.17z"/><path d="M533.87 109.42v123.17h-14V109.42H472V96.34h109.83v13.08zm83.89 126c-27.69 0-48.18-20.49-48.18-52.54 0-31.83 21.36-53 49.27-53s48 20.49 48 52.54c-.04 31.86-21.41 53-49.09 53zm.43-93.3c-21.14 0-35.1 16.78-35.1 40.33 0 24.41 14.17 40.76 35.32 40.76s35.1-16.78 35.1-40.33c0-24.41-14.17-40.76-35.32-40.76zm80.29 90.47H685v-99.85l13.52-2.83v21.36c6.54-12.86 16.35-21.36 29.43-21.36a36.22 36.22 0 0117.44 4.58l-3.49 12.64a29.68 29.68 0 00-15.26-4.36c-10.46 0-20.27 7.85-28.12 25.73zm97.7 2.83c-30.08 0-48.83-21.58-48.83-52.54 0-31.17 20.71-53 49-53 12.21 0 22.67 3.05 31.18 8.5l-3.49 12.21a50.39 50.39 0 00-27.69-8.07c-21.58 0-35.1 16.13-35.1 39.9 0 24.41 14.17 40.33 35.32 40.33a51.66 51.66 0 0027.69-8.29l2.83 12.43a59.72 59.72 0 01-30.91 8.53zm112.47-2.83v-64.53c0-17.44-7-25.29-21.37-25.29-11.55 0-22.67 5.89-30.95 14.17v75.65h-13.52V85.65l13.52-2.83v63c10.46-10.46 23.54-15.91 34.66-15.91 19.4 0 31.18 12.42 31.18 34.22v68.46z"/><path d="M1023.12 194.44c0 25.72-21.8 41-48 41-12.65 0-27-3.92-36-8.94l3.27-12.2a70 70 0 0033.2 8.7c17.88 0 33.79-9.6 33.79-27.47 0-15-12.42-25.51-32.91-25.51a113.19 113.19 0 00-18.75 1.74v-11.33c29.86-7.63 46.87-17.22 46.87-33.14 0-13.51-10.68-21.36-26.82-21.36-11.33 0-24.41 5.45-33.35 13.51l-5-11.77C949 99.82 963.82 93.5 978 93.5c24.2 0 40.33 12.65 40.33 32.7 0 16.13-12 27.69-35.53 34.88 26.37-.65 40.32 15.05 40.32 33.36zm59.21 38.15h-36V96.34h37.06c44.69 0 72.16 27 72.16 67.14.03 42.95-26.79 69.11-73.22 69.11zm.22-123.39h-22.24v110.53H1083c34.88 0 58.64-17.88 58.64-55.16-.02-34.66-21.82-55.37-59.09-55.37z" fill="#ffb000"/><path d="M208.48 73.59H105.06v174h103.42l50.23-87zm28.14 87l-117.56 67.87V92.71zm-5.12-19.13l-93.32-53.87h62.21zm-31.11 92.13h-62.21l93.32-53.88z" fill="url(#a)"/><path fill="url(#b)" d="M193.05 80.59h14v160h-14z"/></svg>
|
After Width: | Height: | Size: 2.6 KiB |
1
img/pytorch3dlogowhite.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg id="CrypTen_Horizontal_Logos" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1300 330"><defs><style>.cls-1{fill:#fff}</style></defs><path class="cls-1" d="M336.72 184.41l-18.53.22v48h-14V96.34h34.23c36 0 53.19 17.44 53.19 42.51.04 29.86-21.1 45.15-54.89 45.56zM338 109.2h-19.81v62.56l19.4-.43c25.72-.44 39.67-10.68 39.67-31.83 0-19.4-13.73-30.3-39.26-30.3zm114.45 122.3l-8.07 21.58c-9.15 24.42-18.74 31.39-32.26 31.39-7.63 0-13.3-2-19.4-4.58l4.14-12.42c4.8 2.61 9.81 4.36 15.26 4.36 7.63 0 13.3-4.14 20.49-23.11l6.76-17.66-39-98.32H415l31.4 82.41 30.74-82.41h14.17z"/><path class="cls-1" d="M533.87 109.42v123.17h-14V109.42H472V96.34h109.83v13.08zm83.89 126c-27.69 0-48.18-20.49-48.18-52.54 0-31.83 21.36-53 49.27-53s48 20.49 48 52.54c-.04 31.86-21.41 53-49.09 53zm.43-93.3c-21.14 0-35.1 16.78-35.1 40.33 0 24.41 14.17 40.76 35.32 40.76s35.1-16.78 35.1-40.33c0-24.41-14.17-40.76-35.32-40.76zm80.29 90.47H685v-99.85l13.52-2.83v21.36c6.54-12.86 16.35-21.36 29.43-21.36a36.22 36.22 0 0117.44 4.58l-3.49 12.64a29.68 29.68 0 00-15.26-4.36c-10.46 0-20.27 7.85-28.12 25.73zm97.7 2.83c-30.08 0-48.83-21.58-48.83-52.54 0-31.17 20.71-53 49-53 12.21 0 22.67 3.05 31.18 8.5l-3.49 12.21a50.39 50.39 0 00-27.69-8.07c-21.58 0-35.1 16.13-35.1 39.9 0 24.41 14.17 40.33 35.32 40.33a51.66 51.66 0 0027.69-8.29l2.83 12.43a59.72 59.72 0 01-30.91 8.53zm112.47-2.83v-64.53c0-17.44-7-25.29-21.37-25.29-11.55 0-22.67 5.89-30.95 14.17v75.65h-13.52V85.65l13.52-2.83v63c10.46-10.46 23.54-15.91 34.66-15.91 19.4 0 31.18 12.42 31.18 34.22v68.46zm114.47-38.15c0 25.72-21.8 41-48 41-12.65 0-27-3.92-36-8.94l3.27-12.2a70 70 0 0033.2 8.7c17.88 0 33.79-9.6 33.79-27.47 0-15-12.42-25.51-32.91-25.51a113.19 113.19 0 00-18.75 1.74v-11.33c29.86-7.63 46.87-17.22 46.87-33.14 0-13.51-10.68-21.36-26.82-21.36-11.33 0-24.41 5.45-33.35 13.51l-5-11.77C949 99.82 963.82 93.5 978 93.5c24.2 0 40.33 12.65 40.33 32.7 0 16.13-12 27.69-35.53 34.88 26.37-.65 40.32 15.05 40.32 33.36zm59.21 38.15h-36V96.34h37.06c44.69 0 72.16 27 72.16 67.14.03 42.95-26.79 69.11-73.22 69.11zm.22-123.39h-22.24v110.53H1083c34.88 0 58.64-17.88 58.64-55.16-.02-34.66-21.82-55.37-59.09-55.37zM208.48 73.59H105.06v174h103.42l50.23-87zm23 67.87l-24.45-14.11V99.12zm5.12 19.13l-29.57 17.07v-34.14zm-43.57-73v31.68l-54.85-31.68zm-74 5.12l74 42.72v50.31l-74 42.72zm74 109.2v31.68h-54.85zm14 20.14v-28.22l24.45-14.12z"/></svg>
|
After Width: | Height: | Size: 2.3 KiB |
BIN
img/rendering.png
Normal file
After Width: | Height: | Size: 6.5 KiB |
1
img/rendering.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg width="185" height="127" viewBox="0 0 185 127" xmlns="http://www.w3.org/2000/svg"><g transform="translate(4)" fill="none" fill-rule="evenodd"><rect fill="#812CE5" x="2" width="175" height="127" rx="9"/><circle stroke="#FFF" stroke-width="5" fill="#812CE5" cx="148" cy="31" r="14"/><path d="M0 86l45-55m25 62L45 31m25 62l26-26m32.468 27L96.532 67M128.5 94L177 75" stroke="#FFF" stroke-width="8" fill="#FFF" stroke-linecap="round" stroke-linejoin="round"/></g></svg>
|
After Width: | Height: | Size: 469 B |
34
index.html
Normal file
@ -0,0 +1,34 @@
|
||||
<!DOCTYPE html><html lang=""><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>PyTorch3d · A library for deep learning with 3D data</title><meta name="viewport" content="width=device-width"/><meta name="generator" content="Docusaurus"/><meta name="description" content="A library for deep learning with 3D data"/><meta property="og:title" content="PyTorch3d · A library for deep learning with 3D data"/><meta property="og:type" content="website"/><meta property="og:url" content="https://pytorch3d.org/"/><meta property="og:description" content="A library for deep learning with 3D data"/><meta property="og:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><meta name="twitter:card" content="summary"/><meta name="twitter:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><link rel="shortcut icon" href="/img/pytorch3dfavicon.png"/><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css"/><script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-157376881-1', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script><script type="text/javascript" src="https://buttons.github.io/buttons.js"></script><script src="/js/scrollSpy.js"></script><link rel="stylesheet" href="/css/main.css"/><script src="/js/codetabs.js"></script></head><body><div class="fixedHeaderContainer"><div class="headerWrapper wrapper"><header><a href="/"><img class="logo" src="/img/pytorch3dfavicon.png" alt="PyTorch3d"/><h2 class="headerTitleWithLogo">PyTorch3d</h2></a><div class="navigationWrapper navigationSlider"><nav class="slidingNav"><ul class="nav-site nav-site-internal"><li class=""><a href="/docs/why_pytorch3d" target="_self">Docs</a></li><li class=""><a href="/tutorials" target="_self">Tutorials</a></li><li class=""><a href="https://pytorch3d.readthedocs.io/" target="_self">API</a></li><li class=""><a href="https://github.com/facebookresearch/pytorch3d" target="_self">GitHub</a></li></ul></nav></div></header></div></div><div class="navPusher"><div><div class="homeContainer"><div class="homeSplashFade"><div class="wrapper homeWrapper"><div class="splashLogo"><img src="/img/pytorch3dlogowhite.svg" alt="Project Logo"/></div><div class="inner"><h2 class="projectTitle"><small>A library for deep learning with 3D data</small></h2><div class="section promoSection"><div class="promoRow"><div class="pluginRowBlock"><div class="pluginWrapper buttonWrapper"><a class="button" href="/docs/why_pytorch3d.html">Docs</a></div><div class="pluginWrapper buttonWrapper"><a class="button" href="/tutorials/">Tutorials</a></div><div class="pluginWrapper buttonWrapper"><a class="button" href="#quickstart">Get Started</a></div></div></div></div></div></div></div></div><div class="landingPage mainContainer"><div class="productShowcaseSection" style="text-align:center"><div class="container paddingBottom paddingTop"><div class="wrapper"><div class="gridBlock"><div class="blockElement alignCenter fourByGridBlock imageAlignTop"><div class="blockImage"><img src="/img/batching.svg"/></div><div class="blockContent"><h2><div><span><p>Heterogeneous Batching</p>
|
||||
</span></div></h2><div><span><p>Supports batching of 3D inputs of different sizes such as meshes</p>
|
||||
</span></div></div></div><div class="blockElement alignCenter fourByGridBlock imageAlignTop"><div class="blockImage"><img src="/img/ops.png"/></div><div class="blockContent"><h2><div><span><p>Fast 3D Operators</p>
|
||||
</span></div></h2><div><span><p>Supports optimized implementations of several common functions for 3D data</p>
|
||||
</span></div></div></div><div class="blockElement alignCenter fourByGridBlock imageAlignTop"><div class="blockImage"><img src="/img/rendering.svg"/></div><div class="blockContent"><h2><div><span><p>Differentiable Rendering</p>
|
||||
</span></div></h2><div><span><p>Modular differentiable rendering API with parallel implementations in PyTorch, C++ and CUDA</p>
|
||||
</span></div></div></div></div></div></div></div><div class="productShowcaseSection" id="quickstart" style="text-align:center"><h2>Get Started</h2><div class="container"><div class="wrapper"><ol><li><strong>Install PyTorch3D:</strong><div><span><pre><code class="hljs css language-bash">conda install pytorch torchvision -c pytorch <span class="hljs-comment"># OSX only</span>
|
||||
conda install pytorch3d -c pytorch3d <span class="hljs-comment"># all systems</span>
|
||||
</code></pre>
|
||||
</span></div></li><li><strong>Try a few 3D operators </strong>e.g. compute the chamfer loss between two meshes:<div><span><pre><code class="hljs css language-python"><span class="hljs-keyword">from</span> pytorch3d.utils <span class="hljs-keyword">import</span> ico_sphere
|
||||
<span class="hljs-keyword">from</span> pytorch3d.io <span class="hljs-keyword">import</span> load_obj
|
||||
<span class="hljs-keyword">from</span> pytorch3d.structures <span class="hljs-keyword">import</span> Meshes
|
||||
<span class="hljs-keyword">from</span> pytorch3d.ops <span class="hljs-keyword">import</span> sample_points_from_meshes
|
||||
<span class="hljs-keyword">from</span> pytorch3d.loss <span class="hljs-keyword">import</span> chamfer_distance
|
||||
|
||||
<span class="hljs-comment"># Use an ico_sphere mesh and load a mesh from an .obj e.g. model.obj</span>
|
||||
sphere_mesh = ico_sphere(level=<span class="hljs-number">3</span>)
|
||||
verts, faces, _ = load_obj(<span class="hljs-string">"model.obj"</span>)
|
||||
test_mesh = Meshes(verts=[verts], faces=[faces.verts_idx])
|
||||
|
||||
<span class="hljs-comment"># Differentiably sample 5k points from the surface of each mesh and then compute the loss.</span>
|
||||
sample_sphere = sample_points_from_meshes(sphere_mesh, <span class="hljs-number">5000</span>)
|
||||
sample_test = sample_points_from_meshes(test_mesh, <span class="hljs-number">5000</span>)
|
||||
loss_chamfer, _ = chamfer_distance(sample_sphere, sample_test)
|
||||
</code></pre>
|
||||
</span></div></li></ol></div></div></div></div></div><footer class="nav-footer" id="footer"><section class="sitemap"><div class="footerSection"><div class="social"><a class="github-button" href="https://github.com/facebookresearch/pytorch3d" data-count-href="https://github.com/facebookresearch/pytorch3d/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star PyTorch3d on GitHub">pytorch3d</a></div></div></section><a href="https://opensource.facebook.com/" target="_blank" rel="noreferrer noopener" class="fbOpenSource"><img src="/img/oss_logo.png" alt="Facebook Open Source" width="170" height="45"/></a><section class="copyright">Copyright "©" 2020 Facebook Inc</section></footer></div></body></html>
|
31
js/codetabs.js
Normal file
@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Copyright (c) 2017-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
// Turn off ESLint for this file because it's sent down to users as-is.
|
||||
|
||||
/* eslint-disable */
|
||||
window.addEventListener('load', function() {
|
||||
// add event listener for all tab
|
||||
document.querySelectorAll('.nav-link').forEach(function(el) {
|
||||
el.addEventListener('click', function(e) {
|
||||
var groupId = e.target.getAttribute('data-group');
|
||||
document
|
||||
.querySelectorAll('.nav-link[data-group='.concat(groupId, ']'))
|
||||
.forEach(function(el) {
|
||||
el.classList.remove('active');
|
||||
});
|
||||
document
|
||||
.querySelectorAll('.tab-pane[data-group='.concat(groupId, ']'))
|
||||
.forEach(function(el) {
|
||||
el.classList.remove('active');
|
||||
});
|
||||
e.target.classList.add('active');
|
||||
document
|
||||
.querySelector('#'.concat(e.target.getAttribute('data-tab')))
|
||||
.classList.add('active');
|
||||
});
|
||||
});
|
||||
});
|
83
js/scrollSpy.js
Normal file
@ -0,0 +1,83 @@
|
||||
/**
|
||||
* Copyright (c) 2017-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
(function scrollSpy() {
|
||||
var OFFSET = 10;
|
||||
var timer;
|
||||
var headingsCache;
|
||||
|
||||
var findHeadings = function findHeadings() {
|
||||
return headingsCache || document.querySelectorAll('.toc-headings > li > a');
|
||||
};
|
||||
|
||||
var onScroll = function onScroll() {
|
||||
if (timer) {
|
||||
// throttle
|
||||
return;
|
||||
}
|
||||
|
||||
timer = setTimeout(function() {
|
||||
timer = null;
|
||||
var activeNavFound = false;
|
||||
var headings = findHeadings(); // toc nav anchors
|
||||
|
||||
/**
|
||||
* On every call, try to find header right after <-- next header
|
||||
* the one whose content is on the current screen <-- highlight this
|
||||
*/
|
||||
|
||||
for (var i = 0; i < headings.length; i++) {
|
||||
// headings[i] is current element
|
||||
// if an element is already active, then current element is not active
|
||||
// if no element is already active, then current element is active
|
||||
var currNavActive = !activeNavFound;
|
||||
/**
|
||||
* Enter the following check up only when an active nav header is not yet found
|
||||
* Then, check the bounding rectangle of the next header
|
||||
* The headers that are scrolled passed will have negative bounding rect top
|
||||
* So the first one with positive bounding rect top will be the nearest next header
|
||||
*/
|
||||
|
||||
if (currNavActive && i < headings.length - 1) {
|
||||
var heading = headings[i + 1];
|
||||
var next = decodeURIComponent(heading.href.split('#')[1]);
|
||||
var nextHeader = document.getElementById(next);
|
||||
|
||||
if (nextHeader) {
|
||||
var top = nextHeader.getBoundingClientRect().top;
|
||||
currNavActive = top > OFFSET;
|
||||
} else {
|
||||
console.error('Can not find header element', {
|
||||
id: next,
|
||||
heading: heading,
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Stop searching once a first such header is found,
|
||||
* this makes sure the highlighted header is the most current one
|
||||
*/
|
||||
|
||||
if (currNavActive) {
|
||||
activeNavFound = true;
|
||||
headings[i].classList.add('active');
|
||||
} else {
|
||||
headings[i].classList.remove('active');
|
||||
}
|
||||
}
|
||||
}, 100);
|
||||
};
|
||||
|
||||
document.addEventListener('scroll', onScroll);
|
||||
document.addEventListener('resize', onScroll);
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Cache the headings once the page has fully loaded.
|
||||
headingsCache = findHeadings();
|
||||
onScroll();
|
||||
});
|
||||
})();
|
1
sitemap.xml
Normal file
@ -0,0 +1 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"><url><loc>https://pytorch3d.org/help</loc><changefreq>weekly</changefreq><priority>0.5</priority><xhtml:link rel="alternate" hreflang="en" href="https://pytorch3d.org/en/help"/></url><url><loc>https://pytorch3d.org/index</loc><changefreq>weekly</changefreq><priority>0.5</priority><xhtml:link rel="alternate" hreflang="en" href="https://pytorch3d.org/en/index"/></url><url><loc>https://pytorch3d.org/users</loc><changefreq>weekly</changefreq><priority>0.5</priority><xhtml:link rel="alternate" hreflang="en" href="https://pytorch3d.org/en/users"/></url><url><loc>https://pytorch3d.org/docs/batching</loc><changefreq>hourly</changefreq><priority>1.0</priority><xhtml:link rel="alternate" hreflang="en" href="https://pytorch3d.org/docs/batching"/></url><url><loc>https://pytorch3d.org/docs/meshes_io</loc><changefreq>hourly</changefreq><priority>1.0</priority><xhtml:link rel="alternate" hreflang="en" href="https://pytorch3d.org/docs/meshes_io"/></url><url><loc>https://pytorch3d.org/docs/renderer_getting_started</loc><changefreq>hourly</changefreq><priority>1.0</priority><xhtml:link rel="alternate" hreflang="en" href="https://pytorch3d.org/docs/renderer_getting_started"/></url><url><loc>https://pytorch3d.org/docs/renderer</loc><changefreq>hourly</changefreq><priority>1.0</priority><xhtml:link rel="alternate" hreflang="en" href="https://pytorch3d.org/docs/renderer"/></url><url><loc>https://pytorch3d.org/docs/why_pytorch3d</loc><changefreq>hourly</changefreq><priority>1.0</priority><xhtml:link rel="alternate" hreflang="en" href="https://pytorch3d.org/docs/why_pytorch3d"/></url></urlset>
|
8314
tutorials/bundle_adjustment.html
Normal file
8314
tutorials/bundle_adjustment/index.html
Normal file
15018
tutorials/deform_source_mesh_to_target_mesh.html
Normal file
15018
tutorials/deform_source_mesh_to_target_mesh/index.html
Normal file
68
tutorials/index.html
Normal file
@ -0,0 +1,68 @@
|
||||
<!DOCTYPE html><html lang=""><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>PyTorch3d · A library for deep learning with 3D data</title><meta name="viewport" content="width=device-width"/><meta name="generator" content="Docusaurus"/><meta name="description" content="A library for deep learning with 3D data"/><meta property="og:title" content="PyTorch3d · A library for deep learning with 3D data"/><meta property="og:type" content="website"/><meta property="og:url" content="https://pytorch3d.org/"/><meta property="og:description" content="A library for deep learning with 3D data"/><meta property="og:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><meta name="twitter:card" content="summary"/><meta name="twitter:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><link rel="shortcut icon" href="/img/pytorch3dfavicon.png"/><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css"/><script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-157376881-1', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script><script type="text/javascript" src="https://buttons.github.io/buttons.js"></script><script src="/js/scrollSpy.js"></script><link rel="stylesheet" href="/css/main.css"/><script src="/js/codetabs.js"></script></head><body><div class="fixedHeaderContainer"><div class="headerWrapper wrapper"><header><a href="/"><img class="logo" src="/img/pytorch3dfavicon.png" alt="PyTorch3d"/><h2 class="headerTitleWithLogo">PyTorch3d</h2></a><div class="navigationWrapper navigationSlider"><nav class="slidingNav"><ul class="nav-site nav-site-internal"><li class=""><a href="/docs/why_pytorch3d" target="_self">Docs</a></li><li class=""><a href="/tutorials" target="_self">Tutorials</a></li><li class=""><a href="https://pytorch3d.readthedocs.io/" target="_self">API</a></li><li class=""><a href="https://github.com/facebookresearch/pytorch3d" target="_self">GitHub</a></li></ul></nav></div></header></div></div><div class="navPusher"><div class="docMainWrapper wrapper"><div class="container docsNavContainer" id="docsNav"><nav class="toc"><div class="toggleNav"><section class="navWrapper wrapper"><div class="navBreadcrumb wrapper"><div class="navToggle" id="navToggler"><div class="hamburger-menu"><div class="line1"></div><div class="line2"></div><div class="line3"></div></div></div><h2><i>›</i><span></span></h2><div class="tocToggler" id="tocToggler"><i class="icon-toc"></i></div></div><div class="navGroups"><div class="navGroup"><h3 class="navGroupCategoryTitle">Tutorials</h3><ul class=""><li class="navListItem navListItemActive"><a class="navItem" href="/tutorials/">Overview</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">3D operators</h3><ul class=""><li class="navListItem"><a class="navItem" href="/tutorials/deform_source_mesh_to_target_mesh">Fit Mesh</a></li><li class="navListItem"><a class="navItem" href="/tutorials/bundle_adjustment">Bundle Adjustment</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Rendering</h3><ul class=""><li class="navListItem"><a class="navItem" href="/tutorials/render_textured_meshes">Render Textured Meshes</a></li><li class="navListItem"><a class="navItem" href="/tutorials/camera_position_optimization_with_differentiable_rendering">Camera Position Optimization</a></li></ul></div></div></section></div><script>
|
||||
var coll = document.getElementsByClassName('collapsible');
|
||||
var checkActiveCategory = true;
|
||||
for (var i = 0; i < coll.length; i++) {
|
||||
var links = coll[i].nextElementSibling.getElementsByTagName('*');
|
||||
if (checkActiveCategory){
|
||||
for (var j = 0; j < links.length; j++) {
|
||||
if (links[j].classList.contains('navListItemActive')){
|
||||
coll[i].nextElementSibling.classList.toggle('hide');
|
||||
coll[i].childNodes[1].classList.toggle('rotate');
|
||||
checkActiveCategory = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
coll[i].addEventListener('click', function() {
|
||||
var arrow = this.childNodes[1];
|
||||
arrow.classList.toggle('rotate');
|
||||
var content = this.nextElementSibling;
|
||||
content.classList.toggle('hide');
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
createToggler('#navToggler', '#docsNav', 'docsSliderActive');
|
||||
createToggler('#tocToggler', 'body', 'tocActive');
|
||||
|
||||
var headings = document.querySelector('.toc-headings');
|
||||
headings && headings.addEventListener('click', function(event) {
|
||||
var el = event.target;
|
||||
while(el !== headings){
|
||||
if (el.tagName === 'A') {
|
||||
document.body.classList.remove('tocActive');
|
||||
break;
|
||||
} else{
|
||||
el = el.parentNode;
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
|
||||
function createToggler(togglerSelector, targetSelector, className) {
|
||||
var toggler = document.querySelector(togglerSelector);
|
||||
var target = document.querySelector(targetSelector);
|
||||
|
||||
if (!toggler) {
|
||||
return;
|
||||
}
|
||||
|
||||
toggler.onclick = function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
target.classList.toggle(className);
|
||||
};
|
||||
}
|
||||
});
|
||||
</script></nav></div><div class="container mainContainer documentContainer postContainer"><div class="wrapper"><div class="post"><header class="postHeader"><h1 class="postHeaderTitle">Welcome to the PyTorch3D Tutorials</h1></header><p>Here you can learn about the structure and applications of Pytorch3D from examples which are in the form of ipython notebooks.</p><h3> Run interactively </h3><p>At the top of each example you can find a button named <strong>"Open in Colab"</strong> which will open the notebook in <a href="https://colab.research.google.com/notebooks/intro.ipynb"> Google Colaboratory </a> where you can run the code directly in the browser with access to GPU support e.g.</p><img align="center" src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/><p> You can modify the code and experiment with varying different settings. Remember to install pytorch, torchvision, fvcore and pytorch3d in the first cell of the colab notebook by running: </p><div><span><pre><code class="hljs css language-bash">!pip install torch torchvision
|
||||
!pip install <span class="hljs-string">'git+https://github.com/facebookresearch/pytorch3d.git
|
||||
</span></code></pre>
|
||||
</span></div><h3> Run locally </h3><p> There is also a button to download the notebook and source code to run it locally. </p></div></div></div></div><footer class="nav-footer" id="footer"><section class="sitemap"><div class="footerSection"><div class="social"><a class="github-button" href="https://github.com/facebookresearch/pytorch3d" data-count-href="https://github.com/facebookresearch/pytorch3d/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star PyTorch3d on GitHub">pytorch3d</a></div></div></section><a href="https://opensource.facebook.com/" target="_blank" rel="noreferrer noopener" class="fbOpenSource"><img src="/img/oss_logo.png" alt="Facebook Open Source" width="170" height="45"/></a><section class="copyright">Copyright "©" 2020 Facebook Inc</section></footer></div></body></html>
|
517
tutorials/render_textured_meshes.html
Normal file
517
tutorials/render_textured_meshes/index.html
Normal file
9
users.html
Normal file
@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html><html lang=""><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>PyTorch3d · A library for deep learning with 3D data</title><meta name="viewport" content="width=device-width"/><meta name="generator" content="Docusaurus"/><meta name="description" content="A library for deep learning with 3D data"/><meta property="og:title" content="PyTorch3d · A library for deep learning with 3D data"/><meta property="og:type" content="website"/><meta property="og:url" content="https://pytorch3d.org/"/><meta property="og:description" content="A library for deep learning with 3D data"/><meta property="og:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><meta name="twitter:card" content="summary"/><meta name="twitter:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><link rel="shortcut icon" href="/img/pytorch3dfavicon.png"/><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css"/><script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-157376881-1', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script><script type="text/javascript" src="https://buttons.github.io/buttons.js"></script><script src="/js/scrollSpy.js"></script><link rel="stylesheet" href="/css/main.css"/><script src="/js/codetabs.js"></script></head><body><div class="fixedHeaderContainer"><div class="headerWrapper wrapper"><header><a href="/"><img class="logo" src="/img/pytorch3dfavicon.png" alt="PyTorch3d"/><h2 class="headerTitleWithLogo">PyTorch3d</h2></a><div class="navigationWrapper navigationSlider"><nav class="slidingNav"><ul class="nav-site nav-site-internal"><li class=""><a href="/docs/why_pytorch3d" target="_self">Docs</a></li><li class=""><a href="/tutorials" target="_self">Tutorials</a></li><li class=""><a href="https://pytorch3d.readthedocs.io/" target="_self">API</a></li><li class=""><a href="https://github.com/facebookresearch/pytorch3d" target="_self">GitHub</a></li></ul></nav></div></header></div></div><div class="navPusher"><div class="mainContainer"><div class="container paddingBottom paddingTop"><div class="wrapper"><div class="showcaseSection"><div class="prose"><h1>Who is Using This?</h1><p>This project is used by many folks</p></div><div class="logos"><a href="https://www.facebook.com"><img src="/img/undraw_open_source.svg" alt="User1" title="User1"/></a></div><p>Are you using this project?</p><a href="undefined/edit/master/website/siteConfig.js" class="button">Add your company</a></div></div></div></div><footer class="nav-footer" id="footer"><section class="sitemap"><div class="footerSection"><div class="social"><a class="github-button" href="https://github.com/facebookresearch/pytorch3d" data-count-href="https://github.com/facebookresearch/pytorch3d/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star PyTorch3d on GitHub">pytorch3d</a></div></div></section><a href="https://opensource.facebook.com/" target="_blank" rel="noreferrer noopener" class="fbOpenSource"><img src="/img/oss_logo.png" alt="Facebook Open Source" width="170" height="45"/></a><section class="copyright">Copyright "©" 2020 Facebook Inc</section></footer></div></body></html>
|
9
users/index.html
Normal file
@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html><html lang=""><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>PyTorch3d · A library for deep learning with 3D data</title><meta name="viewport" content="width=device-width"/><meta name="generator" content="Docusaurus"/><meta name="description" content="A library for deep learning with 3D data"/><meta property="og:title" content="PyTorch3d · A library for deep learning with 3D data"/><meta property="og:type" content="website"/><meta property="og:url" content="https://pytorch3d.org/"/><meta property="og:description" content="A library for deep learning with 3D data"/><meta property="og:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><meta name="twitter:card" content="summary"/><meta name="twitter:image" content="https://pytorch3d.org/img/pytorch3dlogoicon.svg"/><link rel="shortcut icon" href="/img/pytorch3dfavicon.png"/><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css"/><script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-157376881-1', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script><script type="text/javascript" src="https://buttons.github.io/buttons.js"></script><script src="/js/scrollSpy.js"></script><link rel="stylesheet" href="/css/main.css"/><script src="/js/codetabs.js"></script></head><body><div class="fixedHeaderContainer"><div class="headerWrapper wrapper"><header><a href="/"><img class="logo" src="/img/pytorch3dfavicon.png" alt="PyTorch3d"/><h2 class="headerTitleWithLogo">PyTorch3d</h2></a><div class="navigationWrapper navigationSlider"><nav class="slidingNav"><ul class="nav-site nav-site-internal"><li class=""><a href="/docs/why_pytorch3d" target="_self">Docs</a></li><li class=""><a href="/tutorials" target="_self">Tutorials</a></li><li class=""><a href="https://pytorch3d.readthedocs.io/" target="_self">API</a></li><li class=""><a href="https://github.com/facebookresearch/pytorch3d" target="_self">GitHub</a></li></ul></nav></div></header></div></div><div class="navPusher"><div class="mainContainer"><div class="container paddingBottom paddingTop"><div class="wrapper"><div class="showcaseSection"><div class="prose"><h1>Who is Using This?</h1><p>This project is used by many folks</p></div><div class="logos"><a href="https://www.facebook.com"><img src="/img/undraw_open_source.svg" alt="User1" title="User1"/></a></div><p>Are you using this project?</p><a href="undefined/edit/master/website/siteConfig.js" class="button">Add your company</a></div></div></div></div><footer class="nav-footer" id="footer"><section class="sitemap"><div class="footerSection"><div class="social"><a class="github-button" href="https://github.com/facebookresearch/pytorch3d" data-count-href="https://github.com/facebookresearch/pytorch3d/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star PyTorch3d on GitHub">pytorch3d</a></div></div></section><a href="https://opensource.facebook.com/" target="_blank" rel="noreferrer noopener" class="fbOpenSource"><img src="/img/oss_logo.png" alt="Facebook Open Source" width="170" height="45"/></a><section class="copyright">Copyright "©" 2020 Facebook Inc</section></footer></div></body></html>
|