Commit dbf06b50 authored by facebook-github-bot's avatar facebook-github-bot
Browse files

Initial commit

fbshipit-source-id: ad58e416e3ceeca85fae0583308968d04e78fe0d
parents
<img src="https://github.com/facebookresearch/pytorch3d/blob/master/.github/pytorch3dlogo.png" width="900"/>
[![CircleCI](https://circleci.com/gh/facebookresearch/pytorch3d.svg?style=svg)](https://circleci.com/gh/facebookresearch/pytorch3d)
[![Anaconda-Server Badge](https://anaconda.org/pytorch3d/pytorch3d/badges/version.svg)](https://anaconda.org/pytorch3d/pytorch3d)
# Introduction
PyTorch3d provides efficient, reusable components for 3D Computer Vision research with [PyTorch](https://pytorch.org).
Key features include:
- Data structure for storing and manipulating triangle meshes
- Efficient operations on triangle meshes (projective transformations, graph convolution, sampling, loss functions)
- A differentiable mesh renderer
PyTorch3d is designed to integrate smoothly with deep learning methods for predicting and manipulating 3D data.
For this reason, all operators in PyTorch3d:
- Are implemented using PyTorch tensors
- Can handle minibatches of hetereogenous data
- Can be differentiated
- Can utilize GPUs for acceleration
Within FAIR, PyTorch3d has been used to power research projects such as [Mesh R-CNN](https://arxiv.org/abs/1906.02739).
## Installation
For detailed instructions refer to [INSTALL.md](INSTALL.md).
## License
PyTorch3d is released under the [BSD-3-Clause License](LICENSE).
## Tutorials
Get started with PyTorch3d by trying one of the tutorial notebooks.
|<img src="https://github.com/facebookresearch/pytorch3d/blob/master/.github/dolphin_deform.gif" width="310"/>|<img src="https://github.com/facebookresearch/pytorch3d/blob/master/.github/bundle_adjust.gif" width="310"/>|
|:-----------------------------------------------------------------------------------------------------------:|:--------------------------------------------------:|
| [Deform a sphere mesh to dolphin](https://github.com/fairinternal/pytorch3d/blob/master/docs/tutorials/deform_source_mesh_to_target_mesh.ipynb)| [Bundle adjustment](https://github.com/fairinternal/pytorch3d/blob/master/docs/tutorials/bundle_adjustment.ipynb) |
| <img src="https://github.com/facebookresearch/pytorch3d/blob/master/.github/render_textured_mesh.gif" width="310"/> | <img src="https://github.com/facebookresearch/pytorch3d/blob/master/.github/camera_position_teapot.gif" width="310" height="310"/>
|:------------------------------------------------------------:|:--------------------------------------------------:|
| [Render textured meshes](https://github.com/fairinternal/pytorch3d/blob/master/docs/tutorials/render_textured_meshes.ipynb)| [Camera position optimization](https://github.com/fairinternal/pytorch3d/blob/master/docs/tutorials/camera_position_optimization_with_differentiable_rendering.ipynb)|
## Documentation
Learn more about the API by reading the PyTorch3d [documentation](https://pytorch3d.readthedocs.org/).
We also have deep dive notes on several API components:
- [Heterogeneous Batching](https://github.com/facebookresearch/pytorch3d/tree/master/docs/notes/batching.md)
- [Mesh IO](https://github.com/facebookresearch/pytorch3d/tree/master/docs/notes/meshes_io.md)
- [Differentiable Rendering](https://github.com/facebookresearch/pytorch3d/tree/master/docs/notes/renderer_getting_started.md)
## Development
We welcome new contributions to Pytorch3d and we will be actively maintaining this library! Please refer to [CONTRIBUTING.md](./.github/CONTRIBUTING.md) for full instructions on how to run the code, tests and linter, and submit your pull requests.
## Contributors
PyTorch3d is written and maintained by the Facebook AI Research Computer Vision Team.
## Citation
If you find PyTorch3d useful in your research, please cite:
```bibtex
@misc{ravi2020pytorch3d,
author = {Nikhila Ravi and Jeremy Reizenstein and David Novotny and Taylor Gordon
and Wan-Yen Lo and Justin Johnson and Georgia Gkioxari},
title = {PyTorch3D},
howpublished = {\url{https://github.com/facebookresearch/pytorch3d}},
year = {2020}
}
```
#!/bin/bash -e
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
# Run this script at project root by "./dev/linter.sh" before you commit
{
V=$(black --version|cut '-d ' -f3)
code='import distutils.version; assert "19.3" < distutils.version.LooseVersion("'$V'")'
python -c "${code}" 2> /dev/null
} || {
echo "Linter requires black 19.3b0 or higher!"
exit 1
}
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
DIR="${DIR}/.."
echo "Running isort..."
isort -y -sp "${DIR}"
echo "Running black..."
black -l 80 "${DIR}"
echo "Running flake..."
flake8 "${DIR}"
echo "Running clang-format ..."
find "${DIR}" -regex ".*\.\(cpp\|c\|cc\|cu\|cuh\|cxx\|h\|hh\|hpp\|hxx\|tcc\|mm\|m\)" -print0 | xargs -0 clang-format -i
(cd "${DIR}"; command -v arc > /dev/null && arc lint) || true
source
_build
_static
_template
*-checkpoint.ipynb
.ipynb_checkpoints
.ipynb_checkpoints/**
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# Minimal makefile for Sphinx documentation
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SOURCEDIR = .
BUILDDIR = _build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
## Setup
### Install dependencies
```
pip install -U recommonmark mock sphinx sphinx_rtd_theme sphinx_markdown_tables
```
### Add symlink to the root README.md
We want to include the root readme as an overview. Before generating the docs create a symlink to the root readme.
```
cd docs
ln -s ../README.md overview.md
```
In `conf.py` for deployment this is done using `subprocess.call`.
### Add a new file
Add a new `.md` or `.rst` file and add the name to the doc tree in `index.rst` e.g
```
.. toctree::
:maxdepth: 1
:caption: Intro Documentation
overview
```
To autogenerate docs from docstrings in the source code, add the import path for the function e.g.
```
Chamfer Loss
--------------------
.. autoclass:: loss.chamfer.chamfer_distance
:members:
:undoc-members:
.. automethod:: __init__
````
### Build
From `pytorch3d/docs` run:
```
> make html
```
The website is generated in `_build/html`.
### Common Issues
Sphinx can be fussy, and sometimes about things you weren’t expecting. For example, you might encounter something like:
WARNING: toctree contains reference to nonexisting document u'overview'
...
checking consistency...
<pytorch3d>/docs/overview.rst::
WARNING: document isn't included in any toctree
You might have indented overview in the .. toctree:: in index.rst with four spaces, when Sphinx is expecting three.
### View
Start a python simple server:
```
> python -m http.server
```
Navigate to: `http://0.0.0.0:8000/`
# -*- coding: utf-8 -*-
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# flake8: noqa
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
import pytorch3d # isort: skip
import mock
from recommonmark.parser import CommonMarkParser
from recommonmark.states import DummyStateMachine
from sphinx.builders.html import StandaloneHTMLBuilder
from sphinx.ext.autodoc import between
# Monkey patch to fix recommonmark 0.4 doc reference issues.
orig_run_role = DummyStateMachine.run_role
def run_role(self, name, options=None, content=None):
if name == "doc":
name = "any"
return orig_run_role(self, name, options, content)
DummyStateMachine.run_role = run_role
StandaloneHTMLBuilder.supported_image_types = [
"image/svg+xml",
"image/gif",
"image/png",
"image/jpeg",
]
# -- Path setup --------------------------------------------------------------
sys.path.insert(0, os.path.abspath("../"))
sys.path.insert(0, os.path.abspath("../pytorch3d"))
sys.path.insert(0, os.path.abspath("../../"))
DEPLOY = os.environ.get("READTHEDOCS") == "True"
needs_sphinx = "1.7"
# The short X.Y version
version = pytorch3d.__version__
# The full version, including alpha/beta/rc tags
release = version
try:
import torch # noqa
except ImportError:
for m in [
"torch",
"torchvision",
"torch.nn",
"torch.autograd",
"torch.autograd.function",
"torch.nn.modules",
"torch.nn.modules.utils",
"torch.utils",
"torch.utils.data",
"torchvision",
"torchvision.ops",
]:
sys.modules[m] = mock.Mock(name=m)
for m in ["cv2", "scipy", "numpy", "pytorch3d._C", "np.eye", "np.zeros"]:
sys.modules[m] = mock.Mock(name=m)
# -- Project information -----------------------------------------------------
project = "PyTorch3D"
copyright = "2019, facebookresearch"
author = "facebookresearch"
# The full version, including alpha/beta/rc tags
release = "v0.1"
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx_markdown_tables",
"sphinx.ext.autodoc",
"sphinx.ext.mathjax",
"sphinx.ext.napoleon",
"sphinx.ext.intersphinx",
"sphinx.ext.todo",
"sphinx.ext.coverage",
"sphinx.ext.viewcode",
"sphinx.ext.githubpages",
]
# -- Configurations for plugins ------------
napoleon_google_docstring = True
napoleon_include_init_with_doc = True
napoleon_include_special_with_doc = True
napoleon_numpy_docstring = False
# napoleon_use_param = False
napoleon_use_rtype = False
autodoc_inherit_docstrings = False
autodoc_member_order = "bysource"
source_parsers = {".md": CommonMarkParser}
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
source_suffix = [".rst", ".md"]
# The master toctree document.
master_doc = "index"
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "build", "README.md"]
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = "sphinx"
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "sphinx_rtd_theme"
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
html_theme_options = {"collapse_navigation": True}
def url_resolver(url):
if ".html" not in url:
url = url.replace("../", "")
return (
"https://github.com/facebookresearch/pytorch3d/blob/master/" + url
)
else:
if DEPLOY:
return "http://pytorch3d.readthedocs.io/" + url
else:
return "/" + url
def setup(app):
# Add symlink to root README
if DEPLOY:
import subprocess
subprocess.call(["ln", "-s", "../README.md", "overview.md"])
from recommonmark.transform import AutoStructify
app.add_config_value(
"recommonmark_config",
{
"url_resolver": url_resolver,
"auto_toc_tree_section": "Contents",
"enable_math": True,
"enable_inline_math": True,
"enable_eval_rst": True,
"enable_auto_toc_tree": True,
},
True,
)
# Register a sphinx.ext.autodoc.between listener to ignore everything
# between lines that contain the word IGNORE
app.connect(
"autodoc-process-docstring", between("^.*IGNORE.*$", exclude=True)
)
app.add_transform(AutoStructify)
return app
Welcome to PyTorch3D's documentation!
=====================================
PyTorch3D is a library of reusable components for Deep Learning with 3D data.
Table of Contents
=================
.. toctree::
:maxdepth: 2
overview
.. toctree::
:maxdepth: 2
modules/index
API Documentation
==================
.. toctree::
structures
io
loss
ops
renderer/index
transforms
utils
\ No newline at end of file
pytorch3d.io
===========================
.. automodule:: pytorch3d.io
:members:
:undoc-members:
:show-inheritance:
\ No newline at end of file
pytorch3d.loss
====================
Loss functions for meshes and point clouds.
.. automodule:: pytorch3d.loss
:members:
:undoc-members:
:show-inheritance:
pytorch3d.ops
===========================
.. automodule:: pytorch3d.ops
:members:
:undoc-members:
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment