mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-08-02 03:42:50 +08:00
Summary: Updated the load obj function to support creating of a per face texture map using the information in an .mtl file. Uses the approach from in SoftRasterizer. Currently I have ported in the SoftRasterizer code but this is only to help with comparison and will be deleted before landing. The ShapeNet Test data will also be deleted. Here is the [Design doc](https://docs.google.com/document/d/1AUcLP4QwVSqlfLAUfbjM9ic5vYn9P54Ha8QbcVXW2eI/edit?usp=sharing). ## Added - texture atlas creation functions in PyTorch based on the SoftRas cuda implementation - tests to compare SoftRas vs PyTorch3D implementation to verify it matches (using real shapenet data with meshes consisting of multiple textures) - benchmarks tests ## Remaining todo: - add more tests for obj io to test the new functions and the two texturing options - replace the shapenet data with the output from SoftRas saved as a file. # MAIN FILES TO REVIEW - `obj_io.py` - `test_obj_io.py` [still some tests to be added but have comparisons with SoftRas for now] The reference SoftRas implementations are in `softras_load_obj.py` and `load_textures.cu`. Reviewed By: gkioxari Differential Revision: D20754859 fbshipit-source-id: 42ace9dfb73f26e29d800c763f56d5b66c60c5e2
98 lines
2.4 KiB
Python
98 lines
2.4 KiB
Python
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
|
|
|
from itertools import product
|
|
|
|
from fvcore.common.benchmark import benchmark
|
|
from test_obj_io import TestMeshObjIO
|
|
from test_ply_io import TestMeshPlyIO
|
|
|
|
|
|
def bm_save_load() -> None:
|
|
simple_kwargs_list = [
|
|
{"V": 100, "F": 200},
|
|
{"V": 1000, "F": 2000},
|
|
{"V": 10000, "F": 20000},
|
|
]
|
|
benchmark(
|
|
TestMeshObjIO.bm_load_simple_obj_with_init,
|
|
"LOAD_SIMPLE_OBJ",
|
|
simple_kwargs_list,
|
|
warmup_iters=1,
|
|
)
|
|
benchmark(
|
|
TestMeshObjIO.bm_save_simple_obj_with_init,
|
|
"SAVE_SIMPLE_OBJ",
|
|
simple_kwargs_list,
|
|
warmup_iters=1,
|
|
)
|
|
benchmark(
|
|
TestMeshPlyIO.bm_load_simple_ply_with_init,
|
|
"LOAD_SIMPLE_PLY",
|
|
simple_kwargs_list,
|
|
warmup_iters=1,
|
|
)
|
|
benchmark(
|
|
TestMeshPlyIO.bm_save_simple_ply_with_init,
|
|
"SAVE_SIMPLE_PLY",
|
|
simple_kwargs_list,
|
|
warmup_iters=1,
|
|
)
|
|
|
|
complex_kwargs_list = [{"N": 8}, {"N": 32}, {"N": 128}]
|
|
benchmark(
|
|
TestMeshObjIO.bm_load_complex_obj,
|
|
"LOAD_COMPLEX_OBJ",
|
|
complex_kwargs_list,
|
|
warmup_iters=1,
|
|
)
|
|
benchmark(
|
|
TestMeshObjIO.bm_save_complex_obj,
|
|
"SAVE_COMPLEX_OBJ",
|
|
complex_kwargs_list,
|
|
warmup_iters=1,
|
|
)
|
|
benchmark(
|
|
TestMeshPlyIO.bm_load_complex_ply,
|
|
"LOAD_COMPLEX_PLY",
|
|
complex_kwargs_list,
|
|
warmup_iters=1,
|
|
)
|
|
benchmark(
|
|
TestMeshPlyIO.bm_save_complex_ply,
|
|
"SAVE_COMPLEX_PLY",
|
|
complex_kwargs_list,
|
|
warmup_iters=1,
|
|
)
|
|
|
|
# Texture loading benchmarks
|
|
kwargs_list = [{"R": 2}, {"R": 4}, {"R": 10}, {"R": 15}, {"R": 20}]
|
|
benchmark(
|
|
TestMeshObjIO.bm_load_texture_atlas,
|
|
"PYTORCH3D_TEXTURE_ATLAS",
|
|
kwargs_list,
|
|
warmup_iters=1,
|
|
)
|
|
|
|
kwargs_list = []
|
|
S = [64, 256, 1024]
|
|
F = [100, 1000, 10000]
|
|
R = [5, 10, 20]
|
|
test_cases = product(S, F, R)
|
|
|
|
for case in test_cases:
|
|
s, f, r = case
|
|
kwargs_list.append({"S": s, "F": f, "R": r})
|
|
|
|
benchmark(
|
|
TestMeshObjIO.bm_bilinear_sampling_vectorized,
|
|
"BILINEAR_VECTORIZED",
|
|
kwargs_list,
|
|
warmup_iters=1,
|
|
)
|
|
benchmark(
|
|
TestMeshObjIO.bm_bilinear_sampling_grid_sample,
|
|
"BILINEAR_GRID_SAMPLE",
|
|
kwargs_list,
|
|
warmup_iters=1,
|
|
)
|