Updates for version 0.7.1

This commit is contained in:
Jeremy Francis Reizenstein
2022-10-23 09:41:42 -07:00
parent 27dc9dc21d
commit 45d1b39f1c
14 changed files with 481 additions and 545 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -186,9 +186,9 @@ class MyConfigurable(Configurable):
# In[ ]:
# expand_args_fields must be called on an object before it is instantiated.
# A warning is raised if this is missed, but it is possible to not notice the warning.
# It modifies the class like @dataclass
# The expand_args_fields function modifies the class like @dataclasses.dataclass.
# If it has not been called on a Configurable object before it has been instantiated, it will
# be called automatically.
expand_args_fields(MyConfigurable)
my_configurable_instance = MyConfigurable(a=18)
assert my_configurable_instance.d == 16
@@ -197,7 +197,7 @@ assert my_configurable_instance.d == 16
# In[ ]:
# get_default_args calls expand_args_fields automatically
# get_default_args also calls expand_args_fields automatically
our_structured = get_default_args(MyConfigurable)
assert isinstance(our_structured, DictConfig)
print(OmegaConf.to_yaml(our_structured))
@@ -357,7 +357,6 @@ class MyLinear(torch.nn.Module, Configurable):
# In[ ]:
expand_args_fields(MyLinear)
my_linear = MyLinear()
input = torch.zeros(2)
output = my_linear(input)
@@ -415,7 +414,6 @@ class Out(Configurable):
# In[ ]:
expand_args_fields(Out)
out2 = Out(inner_class_type="UserImplementedInner")
print(out2.inner)
@@ -450,7 +448,6 @@ class LargeComponent(Configurable):
# In[ ]:
expand_args_fields(LargeComponent)
large_component = LargeComponent()
assert large_component.apply(3) == 4
print(OmegaConf.to_yaml(LargeComponent))
@@ -491,7 +488,6 @@ class LargeComponent(Configurable):
# In[ ]:
expand_args_fields(LargeComponent)
large_component = LargeComponent()
assert large_component.apply(3) == 4
print(OmegaConf.to_yaml(LargeComponent))
@@ -506,7 +502,6 @@ print(OmegaConf.to_yaml(LargeComponent))
# ## Appendix: gotchas ⚠️
#
# * Omitting to define `__post_init__` or not calling `run_auto_creation` in it.
# * Using a configurable class without calling get_default_args or expand_args_fields on it.
# * Omitting a type annotation on a field. For example, writing
# ```
# subcomponent_class_type = "SubComponent"

View File

@@ -145,10 +145,9 @@
"from pytorch3d.implicitron.dataset.dataset_base import FrameData\n",
"from pytorch3d.implicitron.dataset.rendered_mesh_dataset_map_provider import RenderedMeshDatasetMapProvider\n",
"from pytorch3d.implicitron.models.generic_model import GenericModel\n",
"from pytorch3d.implicitron.models.implicit_function.base import ImplicitFunctionBase\n",
"from pytorch3d.implicitron.models.implicit_function.base import ImplicitFunctionBase, ImplicitronRayBundle\n",
"from pytorch3d.implicitron.models.renderer.base import EvaluationMode\n",
"from pytorch3d.implicitron.tools.config import expand_args_fields, get_default_args, registry, remove_unused_components\n",
"from pytorch3d.renderer import RayBundle\n",
"from pytorch3d.implicitron.tools.config import get_default_args, registry, remove_unused_components\n",
"from pytorch3d.renderer.implicit.renderer import VolumeSampler\n",
"from pytorch3d.structures import Volumes\n",
"from pytorch3d.vis.plotly_vis import plot_batch_individually, plot_scene"
@@ -245,17 +244,6 @@
"!wget -P data/cow_mesh https://dl.fbaipublicfiles.com/pytorch3d/data/cow_mesh/cow_texture.png"
]
},
{
"cell_type": "markdown",
"metadata": {
"customInput": null,
"originalKey": "2a976be8-01bf-4a1c-a6e7-61d5d08c3dbd",
"showInput": false
},
"source": [
"If we want to instantiate one of Implicitron's configurable objects, such as `RenderedMeshDatasetMapProvider`, without using the OmegaConf initialisation (get_default_args), we need to call `expand_args_fields` on the class first."
]
},
{
"cell_type": "code",
"execution_count": null,
@@ -272,7 +260,6 @@
},
"outputs": [],
"source": [
"expand_args_fields(RenderedMeshDatasetMapProvider)\n",
"cow_provider = RenderedMeshDatasetMapProvider(\n",
" data_file=\"data/cow_mesh/cow.obj\",\n",
" use_point_light=False,\n",
@@ -405,7 +392,7 @@
"\n",
" def forward(\n",
" self,\n",
" ray_bundle: RayBundle,\n",
" ray_bundle: ImplicitronRayBundle,\n",
" fun_viewpool=None,\n",
" global_code=None,\n",
" ):\n",
@@ -468,7 +455,6 @@
" gm = GenericModel(**cfg)\n",
"else:\n",
" # constructing GenericModel directly\n",
" expand_args_fields(GenericModel)\n",
" gm = GenericModel(\n",
" implicit_function_class_type=\"MyVolumes\",\n",
" render_image_height=output_resolution,\n",

View File

@@ -73,10 +73,9 @@ from PIL import Image
from pytorch3d.implicitron.dataset.dataset_base import FrameData
from pytorch3d.implicitron.dataset.rendered_mesh_dataset_map_provider import RenderedMeshDatasetMapProvider
from pytorch3d.implicitron.models.generic_model import GenericModel
from pytorch3d.implicitron.models.implicit_function.base import ImplicitFunctionBase
from pytorch3d.implicitron.models.implicit_function.base import ImplicitFunctionBase, ImplicitronRayBundle
from pytorch3d.implicitron.models.renderer.base import EvaluationMode
from pytorch3d.implicitron.tools.config import expand_args_fields, get_default_args, registry, remove_unused_components
from pytorch3d.renderer import RayBundle
from pytorch3d.implicitron.tools.config import get_default_args, registry, remove_unused_components
from pytorch3d.renderer.implicit.renderer import VolumeSampler
from pytorch3d.structures import Volumes
from pytorch3d.vis.plotly_vis import plot_batch_individually, plot_scene
@@ -112,12 +111,9 @@ get_ipython().system('wget -P data/cow_mesh https://dl.fbaipublicfiles.com/pytor
get_ipython().system('wget -P data/cow_mesh https://dl.fbaipublicfiles.com/pytorch3d/data/cow_mesh/cow_texture.png')
# If we want to instantiate one of Implicitron's configurable objects, such as `RenderedMeshDatasetMapProvider`, without using the OmegaConf initialisation (get_default_args), we need to call `expand_args_fields` on the class first.
# In[ ]:
expand_args_fields(RenderedMeshDatasetMapProvider)
cow_provider = RenderedMeshDatasetMapProvider(
data_file="data/cow_mesh/cow.obj",
use_point_light=False,
@@ -184,7 +180,7 @@ class MyVolumes(ImplicitFunctionBase, torch.nn.Module):
def forward(
self,
ray_bundle: RayBundle,
ray_bundle: ImplicitronRayBundle,
fun_viewpool=None,
global_code=None,
):
@@ -225,7 +221,6 @@ if CONSTRUCT_MODEL_FROM_CONFIG:
gm = GenericModel(**cfg)
else:
# constructing GenericModel directly
expand_args_fields(GenericModel)
gm = GenericModel(
implicit_function_class_type="MyVolumes",
render_image_height=output_resolution,

View File

@@ -129,7 +129,7 @@
"## Load the SMPL model\n",
"\n",
"#### Download the SMPL model\n",
"- Go to http://smpl.is.tue.mpg.de/downloads and sign up.\n",
"- Go to https://smpl.is.tue.mpg.de/download.php and sign up.\n",
"- Download SMPL for Python Users and unzip.\n",
"- Copy the file male template file **'models/basicModel_m_lbs_10_207_0_v1.0.0.pkl'** to the data/DensePose/ folder.\n",
" - rename the file to **'smpl_model.pkl'** or rename the string where it's commented below\n",

View File

@@ -96,7 +96,7 @@ sys.path.append(os.path.abspath(''))
# ## Load the SMPL model
#
# #### Download the SMPL model
# - Go to http://smpl.is.tue.mpg.de/downloads and sign up.
# - Go to https://smpl.is.tue.mpg.de/download.php and sign up.
# - Download SMPL for Python Users and unzip.
# - Copy the file male template file **'models/basicModel_m_lbs_10_207_0_v1.0.0.pkl'** to the data/DensePose/ folder.
# - rename the file to **'smpl_model.pkl'** or rename the string where it's commented below