diff --git a/demo/estimate_smpl.py b/demo/estimate_smpl.py index 9e528fa3..8e51fc9b 100644 --- a/demo/estimate_smpl.py +++ b/demo/estimate_smpl.py @@ -15,9 +15,8 @@ inference_video_based_model, init_model, ) -from mmhuman3d.core.visualization import visualize_smpl_hmr +from mmhuman3d.core.visualization.visualize_smpl import visualize_smpl_hmr from mmhuman3d.data.data_structures.human_data import HumanData -from mmhuman3d.utils import array_to_images from mmhuman3d.utils.demo_utils import ( extract_feature_sequence, get_speed_up_interval, @@ -28,6 +27,7 @@ speed_up_interpolate, speed_up_process, ) +from mmhuman3d.utils.ffmpeg_utils import array_to_images from mmhuman3d.utils.transforms import rotmat_to_aa try: diff --git a/docs/conf.py b/docs/conf.py index fcb79218..aabb7d4d 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -45,9 +45,8 @@ def get_version(): ] autodoc_mock_imports = [ - 'mmhuman3d.version', - 'mmhuman3d.core.visualization.renderer.torch3d_renderer', 'mmcv.ops', - 'pytorch3d' + 'mmhuman3d.version', 'mmhuman3d.core.renderer.torch3d_renderer', + 'mmcv.ops', 'pytorch3d' ] # Ignore >>> when copying code diff --git a/docs/render.md b/docs/render.md index 745d2f9a..1fa0a347 100644 --- a/docs/render.md +++ b/docs/render.md @@ -37,7 +37,7 @@ renderer = MeshRenderer( shader=SoftPhongShader(device=device, cameras=cameras, lights=lights)) ### initialized by mmhuman3d -from mmhuman3d.core.visualization.renderer import MeshRenderer +from mmhuman3d.core.renderer.torch3d_renderer.builder import MeshRenderer # rasterizer could be passed by nn.Module or dict rasterizer = dict( image_size=128, @@ -60,7 +60,7 @@ shader = dict(type='SoftPhongShader') These two methods are equal. ```python import torch.nn as nn -from mmhuman3d.core.visualization.renderer import MeshRenderer, build_renderer +from mmhuman3d.core.renderer.torch3d_renderer.builder import MeshRenderer, build_renderer renderer = MeshRenderer(shader=shader, device=device, rasterizer=rasterizer, resolution=resolution) renderer = build_renderer(dict(type='mesh', device=device, shader=shader, rasterizer=rasterizer, resolution=resolution)) @@ -77,7 +77,7 @@ We provide `tensor2rgba` function for visualization, the returned tensor will be The operation is simple: ```python import torch - from mmhuman3d.core.visualization.renderer import build_renderer + from mmhuman3d.core.renderer.torch3d_renderer.builder import build_renderer renderer = build_renderer(dict(type='mesh', device=device, resolution=resolution)) rendered_tensor = renderer(meshes=meshes, cameras=cameras, lights=lights) @@ -107,7 +107,7 @@ You could pass your data by `render_runner` to render a series batch of render. ```python import torch -from mmhuman3d.core.visualization.renderer import render_runner +from mmhuman3d.core.renderer.torch3d_renderer import render_runner render_data = dict(cameras=cameras, lights=lights, meshes=meshes, backgrounds=backgrounds) # no_grad=True for non-differentiable render @@ -130,7 +130,7 @@ Warp a gray texture image to smpl_mesh. import torch from mmhuman3d.models.body_models.builder import build_body_model from pytorch3d.structures import meshes -from mmhuman3d.core.visualization.renderer import build_renderer +from mmhuman3d.core.renderer.torch3d_renderer.builder import build_renderer body_model = build_body_model(dict(type='smpl', model_path=model_path)).to(device) pose_dict = body_model.tensor2dict(torch.zeros(1, 72)) verts = body_model(**pose_dict)['vertices'] diff --git a/docs/visualize_smpl.md b/docs/visualize_smpl.md index a45c1755..cec73fab 100644 --- a/docs/visualize_smpl.md +++ b/docs/visualize_smpl.md @@ -3,7 +3,7 @@ You have smpl pose tensor or array shape of which is (frame, 72) ```python - from mmhuman3d.core.visualization import visualize_smpl_pose + from mmhuman3d.core.visualization.visualize_smpl import visualize_smpl_pose body_model_config = dict( type='smpl', model_path=model_path) visualize_smpl_pose( @@ -29,7 +29,7 @@ If you want to visualize a T-pose smpl or your poses do not have global_orient, you can do: ```python import torch - from mmhuman3d.core.visualization import visualize_T_pose + from mmhuman3d.core.visualization.visualize_smpl import visualize_T_pose body_model_config = dict( type='smpl', model_path=model_path) visualize_T_pose( @@ -45,7 +45,7 @@ E.g., we use vibe sample_video.mp4 as an example. ```python import pickle - from mmhuman3d.core.visualization import visualize_smpl_vibe + from mmhuman3d.core.visualization.visualize_smpl import visualize_smpl_vibe with open('vibe_output.pkl', 'rb') as f: d = pickle.load(f, encoding='latin1') poses = d[1]['pose'] @@ -86,7 +86,7 @@ E.g., we use vibe sample_video.mp4 as an example. ```python import pickle - from mmhuman3d.core.visualization import visualize_smpl_hmr + from mmhuman3d.core.visualization.visualize_smpl import visualize_smpl_hmr gender = 'female' focal_length = 5000 det_width = 224 @@ -142,7 +142,7 @@ - **visualize smpl with opencv camera:** You should pass the opencv defined intrinsic matrix K and extrinsic matrix R, T. ```python - from mmhuman3d.core.visualization import visualize_smpl_calibration + from mmhuman3d.core.visualization.visualize_smpl import visualize_smpl_calibration body_model_config = dict( type='smpl', model_path=model_path, gender=gender) visualize_smpl_calibration( diff --git a/mmhuman3d/apis/train.py b/mmhuman3d/apis/train.py index 207f6a43..9396aba7 100644 --- a/mmhuman3d/apis/train.py +++ b/mmhuman3d/apis/train.py @@ -15,7 +15,7 @@ from mmhuman3d.core.evaluation import DistEvalHook, EvalHook from mmhuman3d.core.optimizer import build_optimizers from mmhuman3d.data.datasets import build_dataloader, build_dataset -from mmhuman3d.utils import get_root_logger +from mmhuman3d.utils.logger import get_root_logger def set_random_seed(seed, deterministic=False): diff --git a/mmhuman3d/core/visualization/renderer/torch3d_renderer/__init__.py b/mmhuman3d/core/renderer/__init__.py similarity index 100% rename from mmhuman3d/core/visualization/renderer/torch3d_renderer/__init__.py rename to mmhuman3d/core/renderer/__init__.py diff --git a/mmhuman3d/core/visualization/renderer/matplotlib3d_renderer.py b/mmhuman3d/core/renderer/matplotlib3d_renderer.py similarity index 99% rename from mmhuman3d/core/visualization/renderer/matplotlib3d_renderer.py rename to mmhuman3d/core/renderer/matplotlib3d_renderer.py index 2188bbce..049aa724 100644 --- a/mmhuman3d/core/visualization/renderer/matplotlib3d_renderer.py +++ b/mmhuman3d/core/renderer/matplotlib3d_renderer.py @@ -13,7 +13,7 @@ from mmhuman3d.core.conventions.cameras.convert_convention import \ enc_camera_convention # prevent yapf isort conflict -from mmhuman3d.utils import get_different_colors +from mmhuman3d.utils.demo_utils import get_different_colors from mmhuman3d.utils.ffmpeg_utils import images_to_video from mmhuman3d.utils.path_utils import check_path_suffix diff --git a/mmhuman3d/core/visualization/renderer/torch3d_renderer/base_renderer.py b/mmhuman3d/core/renderer/torch3d_renderer/base_renderer.py similarity index 98% rename from mmhuman3d/core/visualization/renderer/torch3d_renderer/base_renderer.py rename to mmhuman3d/core/renderer/torch3d_renderer/base_renderer.py index f9436d19..fbe389ed 100644 --- a/mmhuman3d/core/visualization/renderer/torch3d_renderer/base_renderer.py +++ b/mmhuman3d/core/renderer/torch3d_renderer/base_renderer.py @@ -20,12 +20,11 @@ from mmhuman3d.core.cameras import MMCamerasBase from mmhuman3d.utils.ffmpeg_utils import images_to_gif, images_to_video from mmhuman3d.utils.path_utils import check_path_suffix -from .builder import RENDERER, build_lights, build_shader +from .lights import build_lights +from .shader import build_shader from .utils import normalize, rgb2bgr, tensor2array -@RENDERER.register_module( - name=['base', 'Base', 'base_renderer', 'BaseRenderer']) class BaseRenderer(nn.Module): def __init__(self, diff --git a/mmhuman3d/core/renderer/torch3d_renderer/builder.py b/mmhuman3d/core/renderer/torch3d_renderer/builder.py new file mode 100644 index 00000000..0ce90a9d --- /dev/null +++ b/mmhuman3d/core/renderer/torch3d_renderer/builder.py @@ -0,0 +1,48 @@ +from mmcv.utils import Registry + +from .base_renderer import BaseRenderer +from .depth_renderer import DepthRenderer +from .mesh_renderer import MeshRenderer +from .normal_renderer import NormalRenderer +from .pointcloud_renderer import PointCloudRenderer +from .segmentation_renderer import SegmentationRenderer +from .silhouette_renderer import SilhouetteRenderer +from .uv_renderer import UVRenderer + +RENDERER = Registry('renderer') +RENDERER.register_module( + name=['base', 'Base', 'base_renderer', 'BaseRenderer'], + module=BaseRenderer) +RENDERER.register_module( + name=['Depth', 'depth', 'depth_renderer', 'DepthRenderer'], + module=DepthRenderer) +RENDERER.register_module( + name=['Mesh', 'mesh', 'mesh_renderer', 'MeshRenderer'], + module=MeshRenderer) +RENDERER.register_module( + name=['Normal', 'normal', 'normal_renderer', 'NormalRenderer'], + module=NormalRenderer) +RENDERER.register_module( + name=[ + 'PointCloud', 'pointcloud', 'point_cloud', 'pointcloud_renderer', + 'PointCloudRenderer' + ], + module=PointCloudRenderer) +RENDERER.register_module( + name=[ + 'segmentation', 'segmentation_renderer', 'Segmentation', + 'SegmentationRenderer' + ], + module=SegmentationRenderer) +RENDERER.register_module( + name=[ + 'silhouette', 'silhouette_renderer', 'Silhouette', 'SilhouetteRenderer' + ], + module=SilhouetteRenderer) +RENDERER.register_module( + name=['uv_renderer', 'uv', 'UV', 'UVRenderer'], module=UVRenderer) + + +def build_renderer(cfg): + """Build renderers.""" + return RENDERER.build(cfg) diff --git a/mmhuman3d/core/visualization/renderer/torch3d_renderer/depth_renderer.py b/mmhuman3d/core/renderer/torch3d_renderer/depth_renderer.py similarity index 96% rename from mmhuman3d/core/visualization/renderer/torch3d_renderer/depth_renderer.py rename to mmhuman3d/core/renderer/torch3d_renderer/depth_renderer.py index aff8c400..a14bc48b 100644 --- a/mmhuman3d/core/visualization/renderer/torch3d_renderer/depth_renderer.py +++ b/mmhuman3d/core/renderer/torch3d_renderer/depth_renderer.py @@ -5,12 +5,10 @@ from mmhuman3d.core.cameras import MMCamerasBase from .base_renderer import BaseRenderer -from .builder import RENDERER, build_shader +from .shader import build_shader from .utils import normalize -@RENDERER.register_module( - name=['Depth', 'depth', 'depth_renderer', 'DepthRenderer']) class DepthRenderer(BaseRenderer): """Render depth map with the help of camera system.""" shader_type = 'DepthShader' diff --git a/mmhuman3d/core/renderer/torch3d_renderer/lights/__init__.py b/mmhuman3d/core/renderer/torch3d_renderer/lights/__init__.py new file mode 100644 index 00000000..06d85748 --- /dev/null +++ b/mmhuman3d/core/renderer/torch3d_renderer/lights/__init__.py @@ -0,0 +1,10 @@ +# yapf: disable +from .builder import ( # noqa: F401 + AmbientLights, + DirectionalLights, + PointLights, + build_lights, +) +from .lights import MMLights # noqa: F401 + +# yapf: enable diff --git a/mmhuman3d/core/renderer/torch3d_renderer/lights/builder.py b/mmhuman3d/core/renderer/torch3d_renderer/lights/builder.py new file mode 100644 index 00000000..aa88a6ef --- /dev/null +++ b/mmhuman3d/core/renderer/torch3d_renderer/lights/builder.py @@ -0,0 +1,17 @@ +from mmcv.utils import Registry + +from .lights import AmbientLights, DirectionalLights, PointLights # noqa:E401 + +LIGHTS = Registry('lights') +LIGHTS.register_module( + name=['directional', 'directional_lights', 'DirectionalLights'], + module=DirectionalLights) +LIGHTS.register_module( + name=['point', 'point_lights', 'PointLights'], module=PointLights) +LIGHTS.register_module( + name=['ambient', 'ambient_lights', 'AmbientLights'], module=AmbientLights) + + +def build_lights(cfg): + """Build lights.""" + return LIGHTS.build(cfg) diff --git a/mmhuman3d/core/visualization/renderer/torch3d_renderer/lights.py b/mmhuman3d/core/renderer/torch3d_renderer/lights/lights.py similarity index 100% rename from mmhuman3d/core/visualization/renderer/torch3d_renderer/lights.py rename to mmhuman3d/core/renderer/torch3d_renderer/lights/lights.py diff --git a/mmhuman3d/core/visualization/renderer/torch3d_renderer/mesh_renderer.py b/mmhuman3d/core/renderer/torch3d_renderer/mesh_renderer.py similarity index 92% rename from mmhuman3d/core/visualization/renderer/torch3d_renderer/mesh_renderer.py rename to mmhuman3d/core/renderer/torch3d_renderer/mesh_renderer.py index cab33418..69853fbc 100644 --- a/mmhuman3d/core/visualization/renderer/torch3d_renderer/mesh_renderer.py +++ b/mmhuman3d/core/renderer/torch3d_renderer/mesh_renderer.py @@ -4,14 +4,10 @@ from pytorch3d.structures import Meshes from mmhuman3d.core.cameras import MMCamerasBase -from mmhuman3d.core.visualization.renderer.torch3d_renderer.lights import \ - MMLights # noqa: E501 from .base_renderer import BaseRenderer -from .builder import RENDERER +from .lights import MMLights -@RENDERER.register_module( - name=['Mesh', 'mesh', 'mesh_renderer', 'MeshRenderer']) class MeshRenderer(BaseRenderer): """Render RGBA image with the help of camera system.""" shader_type = 'SoftPhongShader' diff --git a/mmhuman3d/core/visualization/renderer/torch3d_renderer/meshes.py b/mmhuman3d/core/renderer/torch3d_renderer/meshes.py similarity index 99% rename from mmhuman3d/core/visualization/renderer/torch3d_renderer/meshes.py rename to mmhuman3d/core/renderer/torch3d_renderer/meshes.py index c2eb10cf..12f5b44c 100644 --- a/mmhuman3d/core/visualization/renderer/torch3d_renderer/meshes.py +++ b/mmhuman3d/core/renderer/torch3d_renderer/meshes.py @@ -11,7 +11,7 @@ from mmhuman3d.utils.mesh_utils import \ join_meshes_as_batch as _join_meshes_as_batch from .builder import build_renderer -from .textures import TexturesNearest +from .textures.textures import TexturesNearest from .utils import align_input_to_padded diff --git a/mmhuman3d/core/visualization/renderer/torch3d_renderer/normal_renderer.py b/mmhuman3d/core/renderer/torch3d_renderer/normal_renderer.py similarity index 96% rename from mmhuman3d/core/visualization/renderer/torch3d_renderer/normal_renderer.py rename to mmhuman3d/core/renderer/torch3d_renderer/normal_renderer.py index 0205a049..94a4694a 100644 --- a/mmhuman3d/core/visualization/renderer/torch3d_renderer/normal_renderer.py +++ b/mmhuman3d/core/renderer/torch3d_renderer/normal_renderer.py @@ -5,12 +5,9 @@ from mmhuman3d.core.cameras import MMCamerasBase from .base_renderer import BaseRenderer -from .builder import RENDERER from .utils import normalize -@RENDERER.register_module( - name=['Normal', 'normal', 'normal_renderer', 'NormalRenderer']) class NormalRenderer(BaseRenderer): """Render normal map with the help of camera system.""" shader_type = 'NormalShader' diff --git a/mmhuman3d/core/visualization/renderer/torch3d_renderer/pointcloud_renderer.py b/mmhuman3d/core/renderer/torch3d_renderer/pointcloud_renderer.py similarity index 97% rename from mmhuman3d/core/visualization/renderer/torch3d_renderer/pointcloud_renderer.py rename to mmhuman3d/core/renderer/torch3d_renderer/pointcloud_renderer.py index 707a8a25..9c7fc60c 100644 --- a/mmhuman3d/core/visualization/renderer/torch3d_renderer/pointcloud_renderer.py +++ b/mmhuman3d/core/renderer/torch3d_renderer/pointcloud_renderer.py @@ -13,13 +13,8 @@ from mmhuman3d.core.cameras import MMCamerasBase from mmhuman3d.utils.mesh_utils import mesh_to_pointcloud_vc from .base_renderer import BaseRenderer -from .builder import RENDERER -@RENDERER.register_module(name=[ - 'PointCloud', 'pointcloud', 'point_cloud', 'pointcloud_renderer', - 'PointCloudRenderer' -]) class PointCloudRenderer(BaseRenderer): def __init__(self, diff --git a/mmhuman3d/core/visualization/renderer/torch3d_renderer/render_runner.py b/mmhuman3d/core/renderer/torch3d_renderer/render_runner.py similarity index 97% rename from mmhuman3d/core/visualization/renderer/torch3d_renderer/render_runner.py rename to mmhuman3d/core/renderer/torch3d_renderer/render_runner.py index 43e38c70..2b3aba0e 100644 --- a/mmhuman3d/core/visualization/renderer/torch3d_renderer/render_runner.py +++ b/mmhuman3d/core/renderer/torch3d_renderer/render_runner.py @@ -13,8 +13,8 @@ from mmhuman3d.core.cameras import MMCamerasBase from mmhuman3d.core.cameras.builder import build_cameras from .base_renderer import BaseRenderer -from .builder import build_lights, build_renderer -from .lights import AmbientLights, MMLights +from .builder import build_renderer +from .lights import AmbientLights, MMLights, build_lights osj = os.path.join diff --git a/mmhuman3d/core/visualization/renderer/torch3d_renderer/segmentation_renderer.py b/mmhuman3d/core/renderer/torch3d_renderer/segmentation_renderer.py similarity index 95% rename from mmhuman3d/core/visualization/renderer/torch3d_renderer/segmentation_renderer.py rename to mmhuman3d/core/renderer/torch3d_renderer/segmentation_renderer.py index ea37dfe7..87ed4a16 100644 --- a/mmhuman3d/core/visualization/renderer/torch3d_renderer/segmentation_renderer.py +++ b/mmhuman3d/core/renderer/torch3d_renderer/segmentation_renderer.py @@ -4,16 +4,11 @@ from pytorch3d.structures import Meshes from mmhuman3d.core.cameras import MMCamerasBase -from mmhuman3d.utils import get_different_colors +from mmhuman3d.utils.demo_utils import get_different_colors from .base_renderer import BaseRenderer -from .builder import RENDERER from .utils import normalize -@RENDERER.register_module(name=[ - 'segmentation', 'segmentation_renderer', 'Segmentation', - 'SegmentationRenderer' -]) class SegmentationRenderer(BaseRenderer): """Render segmentation map into a segmentation index tensor.""" shader_type = 'SegmentationShader' diff --git a/mmhuman3d/core/renderer/torch3d_renderer/shader/__init__.py b/mmhuman3d/core/renderer/torch3d_renderer/shader/__init__.py new file mode 100644 index 00000000..4e55fad8 --- /dev/null +++ b/mmhuman3d/core/renderer/torch3d_renderer/shader/__init__.py @@ -0,0 +1,16 @@ +# yapf: disable +from .builder import ( # noqa: F401 + DepthShader, + HardFlatShader, + HardGouraudShader, + HardPhongShader, + NoLightShader, + NormalShader, + SegmentationShader, + SilhouetteShader, + SoftGouraudShader, + SoftPhongShader, + build_shader, +) + +# yapf: enable diff --git a/mmhuman3d/core/visualization/renderer/torch3d_renderer/builder.py b/mmhuman3d/core/renderer/torch3d_renderer/shader/builder.py similarity index 55% rename from mmhuman3d/core/visualization/renderer/torch3d_renderer/builder.py rename to mmhuman3d/core/renderer/torch3d_renderer/shader/builder.py index 01abfc43..884797eb 100644 --- a/mmhuman3d/core/visualization/renderer/torch3d_renderer/builder.py +++ b/mmhuman3d/core/renderer/torch3d_renderer/shader/builder.py @@ -5,12 +5,8 @@ HardPhongShader, SoftGouraudShader, SoftPhongShader, - TexturesAtlas, - TexturesUV, - TexturesVertex, ) -from .lights import AmbientLights, DirectionalLights, PointLights from .shader import ( DepthShader, NoLightShader, @@ -18,18 +14,6 @@ SegmentationShader, SilhouetteShader, ) -from .textures import TexturesNearest - -RENDERER = Registry('renderer') - -LIGHTS = Registry('lights') -LIGHTS.register_module( - name=['directional', 'directional_lights', 'DirectionalLights'], - module=DirectionalLights) -LIGHTS.register_module( - name=['point', 'point_lights', 'PointLights'], module=PointLights) -LIGHTS.register_module( - name=['ambient', 'ambient_lights', 'AmbientLights'], module=AmbientLights) SHADER = Registry('shader') SHADER.register_module( @@ -67,35 +51,7 @@ ], module=SegmentationShader) -TEXTURES = Registry('textures') -TEXTURES.register_module( - name=['TexturesAtlas', 'textures_atlas', 'atlas', 'Atlas'], - module=TexturesAtlas) -TEXTURES.register_module( - name=['TexturesNearest', 'textures_nearest', 'nearest', 'Nearest'], - module=TexturesNearest) -TEXTURES.register_module( - name=['TexturesUV', 'textures_uv', 'uv'], module=TexturesUV) -TEXTURES.register_module( - name=['TexturesVertex', 'textures_vertex', 'vertex', 'vc'], - module=TexturesVertex) - - -def build_textures(cfg): - """Build textures.""" - return TEXTURES.build(cfg) - def build_shader(cfg): """Build shader.""" return SHADER.build(cfg) - - -def build_lights(cfg): - """Build lights.""" - return LIGHTS.build(cfg) - - -def build_renderer(cfg): - """Build renderers.""" - return RENDERER.build(cfg) diff --git a/mmhuman3d/core/visualization/renderer/torch3d_renderer/shader.py b/mmhuman3d/core/renderer/torch3d_renderer/shader/shader.py similarity index 100% rename from mmhuman3d/core/visualization/renderer/torch3d_renderer/shader.py rename to mmhuman3d/core/renderer/torch3d_renderer/shader/shader.py diff --git a/mmhuman3d/core/visualization/renderer/torch3d_renderer/silhouette_renderer.py b/mmhuman3d/core/renderer/torch3d_renderer/silhouette_renderer.py similarity index 95% rename from mmhuman3d/core/visualization/renderer/torch3d_renderer/silhouette_renderer.py rename to mmhuman3d/core/renderer/torch3d_renderer/silhouette_renderer.py index 20719457..9dcc2ded 100644 --- a/mmhuman3d/core/visualization/renderer/torch3d_renderer/silhouette_renderer.py +++ b/mmhuman3d/core/renderer/torch3d_renderer/silhouette_renderer.py @@ -5,13 +5,9 @@ from mmhuman3d.core.cameras import MMCamerasBase from .base_renderer import BaseRenderer -from .builder import RENDERER from .utils import normalize -@RENDERER.register_module(name=[ - 'silhouette', 'silhouette_renderer', 'Silhouette', 'SilhouetteRenderer' -]) class SilhouetteRenderer(BaseRenderer): """Silhouette renderer.""" shader_type = 'SilhouetteShader' diff --git a/mmhuman3d/core/visualization/renderer/torch3d_renderer/smpl_renderer.py b/mmhuman3d/core/renderer/torch3d_renderer/smpl_renderer.py similarity index 98% rename from mmhuman3d/core/visualization/renderer/torch3d_renderer/smpl_renderer.py rename to mmhuman3d/core/renderer/torch3d_renderer/smpl_renderer.py index bc68d8cb..a43e1d3b 100644 --- a/mmhuman3d/core/visualization/renderer/torch3d_renderer/smpl_renderer.py +++ b/mmhuman3d/core/renderer/torch3d_renderer/smpl_renderer.py @@ -10,14 +10,12 @@ from torch.nn.functional import interpolate from mmhuman3d.core.cameras import MMCamerasBase -from mmhuman3d.core.visualization.renderer.torch3d_renderer.utils import \ - align_input_to_padded # noqa: E501 from mmhuman3d.utils.ffmpeg_utils import images_to_array from mmhuman3d.utils.path_utils import check_path_suffix from .base_renderer import BaseRenderer from .builder import build_renderer from .lights import DirectionalLights, PointLights -from .utils import normalize, rgb2bgr, tensor2array +from .utils import align_input_to_padded, normalize, rgb2bgr, tensor2array class SMPLRenderer(BaseRenderer): diff --git a/mmhuman3d/core/renderer/torch3d_renderer/textures/__init__.py b/mmhuman3d/core/renderer/torch3d_renderer/textures/__init__.py new file mode 100644 index 00000000..4f7c950f --- /dev/null +++ b/mmhuman3d/core/renderer/torch3d_renderer/textures/__init__.py @@ -0,0 +1,10 @@ +# yapf: disable +from .builder import ( # noqa:F401 + TexturesAtlas, + TexturesNearest, + TexturesUV, + TexturesVertex, + build_textures, +) + +# yapf: enable diff --git a/mmhuman3d/core/renderer/torch3d_renderer/textures/builder.py b/mmhuman3d/core/renderer/torch3d_renderer/textures/builder.py new file mode 100644 index 00000000..c54b3d37 --- /dev/null +++ b/mmhuman3d/core/renderer/torch3d_renderer/textures/builder.py @@ -0,0 +1,22 @@ +from mmcv.utils import Registry +from pytorch3d.renderer import TexturesAtlas, TexturesUV, TexturesVertex + +from .textures import TexturesNearest + +TEXTURES = Registry('textures') +TEXTURES.register_module( + name=['TexturesAtlas', 'textures_atlas', 'atlas', 'Atlas'], + module=TexturesAtlas) +TEXTURES.register_module( + name=['TexturesNearest', 'textures_nearest', 'nearest', 'Nearest'], + module=TexturesNearest) +TEXTURES.register_module( + name=['TexturesUV', 'textures_uv', 'uv'], module=TexturesUV) +TEXTURES.register_module( + name=['TexturesVertex', 'textures_vertex', 'vertex', 'vc'], + module=TexturesVertex) + + +def build_textures(cfg): + """Build textures.""" + return TEXTURES.build(cfg) diff --git a/mmhuman3d/core/visualization/renderer/torch3d_renderer/textures.py b/mmhuman3d/core/renderer/torch3d_renderer/textures/textures.py similarity index 100% rename from mmhuman3d/core/visualization/renderer/torch3d_renderer/textures.py rename to mmhuman3d/core/renderer/torch3d_renderer/textures/textures.py diff --git a/mmhuman3d/core/visualization/renderer/torch3d_renderer/utils.py b/mmhuman3d/core/renderer/torch3d_renderer/utils.py similarity index 100% rename from mmhuman3d/core/visualization/renderer/torch3d_renderer/utils.py rename to mmhuman3d/core/renderer/torch3d_renderer/utils.py diff --git a/mmhuman3d/core/visualization/renderer/torch3d_renderer/uv_renderer.py b/mmhuman3d/core/renderer/torch3d_renderer/uv_renderer.py similarity index 99% rename from mmhuman3d/core/visualization/renderer/torch3d_renderer/uv_renderer.py rename to mmhuman3d/core/renderer/torch3d_renderer/uv_renderer.py index ba5b3990..8a9dc8c3 100644 --- a/mmhuman3d/core/visualization/renderer/torch3d_renderer/uv_renderer.py +++ b/mmhuman3d/core/renderer/torch3d_renderer/uv_renderer.py @@ -20,11 +20,9 @@ MMCamerasBase, ) from mmhuman3d.utils.path_utils import check_path_suffix -from .builder import RENDERER from .utils import array2tensor, rgb2bgr -@RENDERER.register_module(name=['uv_renderer', 'uv', 'UV', 'UVRenderer']) class UVRenderer(nn.Module): """Renderer for SMPL(x) UV map.""" diff --git a/mmhuman3d/core/visualization/renderer/vedo_render.py b/mmhuman3d/core/renderer/vedo_render.py similarity index 100% rename from mmhuman3d/core/visualization/renderer/vedo_render.py rename to mmhuman3d/core/renderer/vedo_render.py diff --git a/mmhuman3d/core/visualization/__init__.py b/mmhuman3d/core/visualization/__init__.py index bb4cede6..732bb4f4 100644 --- a/mmhuman3d/core/visualization/__init__.py +++ b/mmhuman3d/core/visualization/__init__.py @@ -1,24 +1,2 @@ -from .renderer.torch3d_renderer import render_runner -from .renderer.torch3d_renderer.builder import ( - build_lights, - build_renderer, - build_shader, - build_textures, -) -from .visualize_keypoints2d import visualize_kp2d -from .visualize_keypoints3d import visualize_kp3d -from .visualize_smpl import ( - render_smpl, - visualize_smpl_calibration, - visualize_smpl_hmr, - visualize_smpl_pose, - visualize_smpl_vibe, - visualize_T_pose, -) - -__all__ = [ - 'visualize_kp2d', 'visualize_kp3d', 'visualize_smpl_pose', - 'visualize_T_pose', 'render_smpl', 'visualize_smpl_vibe', - 'visualize_smpl_calibration', 'visualize_smpl_hmr', 'render_runner', - 'build_lights', 'build_renderer', 'build_shader', 'build_textures' -] +from .visualize_keypoints2d import visualize_kp2d # noqa:F401 +from .visualize_keypoints3d import visualize_kp3d # noqa:F401 diff --git a/mmhuman3d/core/visualization/renderer/__init__.py b/mmhuman3d/core/visualization/renderer/__init__.py deleted file mode 100644 index 6c38efe0..00000000 --- a/mmhuman3d/core/visualization/renderer/__init__.py +++ /dev/null @@ -1,34 +0,0 @@ -from .matplotlib3d_renderer import Axes3dJointsRenderer -from .torch3d_renderer import render_runner -from .torch3d_renderer.base_renderer import BaseRenderer -from .torch3d_renderer.builder import ( - build_lights, - build_renderer, - build_shader, - build_textures, -) -from .torch3d_renderer.depth_renderer import DepthRenderer -from .torch3d_renderer.mesh_renderer import MeshRenderer -from .torch3d_renderer.normal_renderer import NormalRenderer -from .torch3d_renderer.pointcloud_renderer import PointCloudRenderer -from .torch3d_renderer.segmentation_renderer import SegmentationRenderer -from .torch3d_renderer.shader import ( - DepthShader, - NoLightShader, - NormalShader, - SegmentationShader, -) -from .torch3d_renderer.silhouette_renderer import SilhouetteRenderer -from .torch3d_renderer.smpl_renderer import SMPLRenderer -from .torch3d_renderer.textures import TexturesNearest -from .torch3d_renderer.uv_renderer import UVRenderer -from .vedo_render import VedoRenderer - -__all__ = [ - 'NoLightShader', 'BaseRenderer', 'TexturesNearest', 'SMPLRenderer', - 'SilhouetteRenderer', 'Axes3dJointsRenderer', 'VedoRenderer', - 'MeshRenderer', 'DepthRenderer', 'NormalRenderer', 'SegmentationRenderer', - 'PointCloudRenderer', 'UVRenderer', 'build_renderer', 'build_shader', - 'build_textures', 'build_lights', 'DepthShader', 'SegmentationShader', - 'NormalShader', 'NoLightShader', 'render_runner' -] diff --git a/mmhuman3d/core/visualization/visualize_cameras.py b/mmhuman3d/core/visualization/visualize_cameras.py index 7b0ab4fa..cc0f56e6 100644 --- a/mmhuman3d/core/visualization/visualize_cameras.py +++ b/mmhuman3d/core/visualization/visualize_cameras.py @@ -2,8 +2,8 @@ import os from mmhuman3d.core.cameras.camera_parameters import CameraParameter +from mmhuman3d.core.renderer.vedo_render import VedoRenderer from mmhuman3d.utils.path_utils import check_path_suffix -from .renderer.vedo_render import VedoRenderer def visualize_chessboard_kinects_rgb(chessboard_path: str, diff --git a/mmhuman3d/core/visualization/visualize_keypoints2d.py b/mmhuman3d/core/visualization/visualize_keypoints2d.py index ee56cb8d..2b843341 100644 --- a/mmhuman3d/core/visualization/visualize_keypoints2d.py +++ b/mmhuman3d/core/visualization/visualize_keypoints2d.py @@ -15,16 +15,15 @@ HUMAN_DATA_LIMBS_INDEX, HUMAN_DATA_PALETTE, ) -from mmhuman3d.utils import ( +from mmhuman3d.utils.demo_utils import get_different_colors +from mmhuman3d.utils.ffmpeg_utils import images_to_video, video_to_images +from mmhuman3d.utils.keypoint_utils import search_limbs +from mmhuman3d.utils.path_utils import ( Existence, check_input_path, check_path_existence, check_path_suffix, - get_different_colors, - images_to_video, prepare_output_path, - search_limbs, - video_to_images, ) diff --git a/mmhuman3d/core/visualization/visualize_keypoints3d.py b/mmhuman3d/core/visualization/visualize_keypoints3d.py index 2e073e85..f5601fad 100644 --- a/mmhuman3d/core/visualization/visualize_keypoints3d.py +++ b/mmhuman3d/core/visualization/visualize_keypoints3d.py @@ -4,12 +4,10 @@ import numpy as np import mmhuman3d.core.conventions.keypoints_mapping as keypoints_mapping -from mmhuman3d.core.visualization.renderer import Axes3dJointsRenderer -from mmhuman3d.utils import ( - get_different_colors, - prepare_output_path, - search_limbs, -) +from mmhuman3d.core.renderer.matplotlib3d_renderer import Axes3dJointsRenderer +from mmhuman3d.utils.demo_utils import get_different_colors +from mmhuman3d.utils.keypoint_utils import search_limbs +from mmhuman3d.utils.path_utils import prepare_output_path def _norm_pose(pose_numpy: np.ndarray, min_value: Union[float, int], diff --git a/mmhuman3d/core/visualization/visualize_smpl.py b/mmhuman3d/core/visualization/visualize_smpl.py index d600b9ec..9fe29e5f 100644 --- a/mmhuman3d/core/visualization/visualize_smpl.py +++ b/mmhuman3d/core/visualization/visualize_smpl.py @@ -23,29 +23,30 @@ from mmhuman3d.core.conventions.cameras.convert_convention import \ convert_camera_matrix # prevent yapf isort conflict from mmhuman3d.core.conventions.segmentation import body_segmentation -from mmhuman3d.core.visualization.renderer import render_runner -from mmhuman3d.core.visualization.renderer.torch3d_renderer.meshes import \ +from mmhuman3d.core.renderer.torch3d_renderer import render_runner +from mmhuman3d.core.renderer.torch3d_renderer.meshes import \ ParametricMeshes # noqa: E501 -from mmhuman3d.core.visualization.renderer.torch3d_renderer.utils import \ +from mmhuman3d.core.renderer.torch3d_renderer.smpl_renderer import SMPLRenderer +from mmhuman3d.core.renderer.torch3d_renderer.utils import \ align_input_to_padded # noqa: E501 from mmhuman3d.models.body_models.builder import build_body_model -from mmhuman3d.utils import ( - check_input_path, - check_path_suffix, +from mmhuman3d.utils.demo_utils import ( convert_bbox_to_intrinsic, convert_crop_cam_to_orig_img, convert_kp2d_to_bbox, get_default_hmr_intrinsic, get_different_colors, +) +from mmhuman3d.utils.ffmpeg_utils import ( + check_input_path, images_to_array, prepare_output_path, - save_meshes_as_objs, - save_meshes_as_plys, vid_info_reader, video_to_array, video_to_images, ) -from .renderer import SMPLRenderer +from mmhuman3d.utils.mesh_utils import save_meshes_as_objs, save_meshes_as_plys +from mmhuman3d.utils.path_utils import check_path_suffix try: from typing import Literal diff --git a/mmhuman3d/data/data_converters/humman.py b/mmhuman3d/data/data_converters/humman.py index 4e62acdd..29ad698f 100644 --- a/mmhuman3d/data/data_converters/humman.py +++ b/mmhuman3d/data/data_converters/humman.py @@ -11,8 +11,8 @@ get_keypoint_idx, get_keypoint_num, ) -from mmhuman3d.data.data_structures import SMCReader from mmhuman3d.data.data_structures.human_data import HumanData +from mmhuman3d.data.data_structures.smc_reader import SMCReader from mmhuman3d.models.body_models.builder import build_body_model from .base_converter import BaseModeConverter from .builder import DATA_CONVERTERS diff --git a/mmhuman3d/data/data_structures/__init__.py b/mmhuman3d/data/data_structures/__init__.py index 758b406f..e69de29b 100644 --- a/mmhuman3d/data/data_structures/__init__.py +++ b/mmhuman3d/data/data_structures/__init__.py @@ -1,5 +0,0 @@ -from mmhuman3d.data.data_structures import human_data, smc_reader -from mmhuman3d.data.data_structures.human_data import HumanData -from mmhuman3d.data.data_structures.smc_reader import SMCReader - -__all__ = ['HumanData', 'human_data', 'SMCReader', 'smc_reader'] diff --git a/mmhuman3d/data/datasets/pipelines/loading.py b/mmhuman3d/data/datasets/pipelines/loading.py index 30129649..c59bb875 100644 --- a/mmhuman3d/data/datasets/pipelines/loading.py +++ b/mmhuman3d/data/datasets/pipelines/loading.py @@ -4,7 +4,7 @@ import mmcv import numpy as np -import mmhuman3d.data.data_structures as data_structures +from mmhuman3d.data.data_structures.smc_reader import SMCReader from ..builder import PIPELINES @@ -50,7 +50,7 @@ def __call__(self, results): assert 'image_id' in results, 'Load image from .smc, ' \ 'but image_id is not provided.' device, device_id, frame_id = results['image_id'] - smc_reader = data_structures.SMCReader(filename) + smc_reader = SMCReader(filename) img = smc_reader.get_color( device, device_id, frame_id, disable_tqdm=True) img = img.squeeze() # (1, H, W, 3) -> (H, W, 3) diff --git a/mmhuman3d/utils/__init__.py b/mmhuman3d/utils/__init__.py index 2e535c88..e69de29b 100644 --- a/mmhuman3d/utils/__init__.py +++ b/mmhuman3d/utils/__init__.py @@ -1,175 +0,0 @@ -from mmhuman3d.utils.collect_env import collect_env -from mmhuman3d.utils.demo_utils import ( - box2cs, - conver_verts_to_cam_coord, - convert_bbox_to_intrinsic, - convert_crop_cam_to_orig_img, - convert_kp2d_to_bbox, - get_default_hmr_intrinsic, - get_different_colors, - prepare_frames, - process_mmdet_results, - process_mmtracking_results, - smooth_process, - xywh2xyxy, - xyxy2xywh, -) -from mmhuman3d.utils.dist_utils import DistOptimizerHook, allreduce_grads -from mmhuman3d.utils.ffmpeg_utils import ( - array_to_images, - array_to_video, - compress_video, - crop_video, - gif_to_images, - gif_to_video, - images_to_array, - images_to_gif, - images_to_sorted_images, - images_to_video, - pad_for_libx264, - slice_video, - spatial_concat_video, - temporal_concat_video, - vid_info_reader, - video_to_array, - video_to_gif, - video_to_images, - video_writer, -) -from mmhuman3d.utils.geometry import ( - batch_rodrigues, - estimate_translation, - estimate_translation_np, - perspective_projection, - quaternion_to_angle_axis, - rotation_matrix_to_angle_axis, - rotation_matrix_to_quaternion, -) -from mmhuman3d.utils.keypoint_utils import search_limbs -from mmhuman3d.utils.logger import get_root_logger -from mmhuman3d.utils.mesh_utils import ( - join_batch_meshes_as_scene, - load_objs_as_meshes, - load_plys_as_meshes, - mesh_to_pointcloud_vc, - save_meshes_as_objs, - save_meshes_as_plys, - texture_uv2vc, -) -from mmhuman3d.utils.misc import multi_apply, torch_to_numpy -from mmhuman3d.utils.path_utils import ( - Existence, - check_input_path, - check_path_existence, - check_path_suffix, - prepare_output_path, -) -from mmhuman3d.utils.transforms import ( - Compose, - aa_to_ee, - aa_to_quat, - aa_to_rot6d, - aa_to_rotmat, - aa_to_sja, - ee_to_aa, - ee_to_quat, - ee_to_rot6d, - ee_to_rotmat, - quat_to_aa, - quat_to_ee, - quat_to_rot6d, - quat_to_rotmat, - rot6d_to_aa, - rot6d_to_ee, - rot6d_to_quat, - rot6d_to_rotmat, - rotmat_to_aa, - rotmat_to_ee, - rotmat_to_quat, - rotmat_to_rot6d, - sja_to_aa, -) - -__all__ = [ - 'Compose', - 'DistOptimizerHook', - 'Existence', - 'aa_to_ee', - 'aa_to_quat', - 'aa_to_rot6d', - 'aa_to_rotmat', - 'aa_to_sja', - 'allreduce_grads', - 'array_to_images', - 'array_to_video', - 'batch_rodrigues', - 'box2cs', - 'check_input_path', - 'check_path_existence', - 'check_path_suffix', - 'collect_env', - 'compress_video', - 'conver_verts_to_cam_coord', - 'convert_bbox_to_intrinsic', - 'convert_crop_cam_to_orig_img', - 'convert_kp2d_to_bbox', - 'crop_video', - 'ee_to_aa', - 'ee_to_quat', - 'ee_to_rot6d', - 'ee_to_rotmat', - 'estimate_translation', - 'estimate_translation_np', - 'get_default_hmr_intrinsic', - 'get_different_colors', - 'get_root_logger', - 'gif_to_images', - 'gif_to_video', - 'images_to_array', - 'images_to_gif', - 'images_to_sorted_images', - 'images_to_video', - 'join_batch_meshes_as_scene', - 'mesh_to_pointcloud_vc', - 'multi_apply', - 'pad_for_libx264', - 'perspective_projection', - 'prepare_frames', - 'prepare_output_path', - 'process_mmdet_results', - 'process_mmtracking_results', - 'quat_to_aa', - 'quat_to_ee', - 'quat_to_rot6d', - 'quat_to_rotmat', - 'quaternion_to_angle_axis', - 'rot6d_to_aa', - 'rot6d_to_ee', - 'rot6d_to_quat', - 'rot6d_to_rotmat', - 'rotation_matrix_to_angle_axis', - 'rotation_matrix_to_quaternion', - 'rotmat_to_aa', - 'rotmat_to_ee', - 'rotmat_to_quat', - 'rotmat_to_rot6d', - 'save_meshes_as_plys', - 'search_limbs', - 'sja_to_aa', - 'slice_video', - 'smooth_process', - 'spatial_concat_video', - 'temporal_concat_video', - 'torch_to_numpy', - 'vid_info_reader', - 'video_to_array', - 'video_to_gif', - 'video_to_images', - 'video_writer', - 'xywh2xyxy', - 'xyxy2xywh', - 'save_meshes_as_objs', - 'texture_uv2vc', - 'load_objs_as_meshes', - 'load_plys_as_meshes', -] diff --git a/mmhuman3d/utils/transforms.py b/mmhuman3d/utils/transforms.py index 5a89bf13..d1d95f66 100644 --- a/mmhuman3d/utils/transforms.py +++ b/mmhuman3d/utils/transforms.py @@ -2,22 +2,37 @@ import numpy import torch -from pytorch3d.transforms import ( - axis_angle_to_matrix, - axis_angle_to_quaternion, - euler_angles_to_matrix, - matrix_to_euler_angles, - matrix_to_quaternion, - matrix_to_rotation_6d, - quaternion_to_axis_angle, - quaternion_to_matrix, - rotation_6d_to_matrix, -) from mmhuman3d.core.conventions.joints_mapping.standard_joint_angles import ( TRANSFORMATION_AA_TO_SJA, TRANSFORMATION_SJA_TO_AA, ) +from .logger import get_root_logger + +try: + from pytorch3d.transforms import ( + axis_angle_to_matrix, + axis_angle_to_quaternion, + euler_angles_to_matrix, + matrix_to_euler_angles, + matrix_to_quaternion, + matrix_to_rotation_6d, + quaternion_to_axis_angle, + quaternion_to_matrix, + rotation_6d_to_matrix, + ) +except (ImportError, ModuleNotFoundError): + import traceback + logger = get_root_logger() + stack_str = '' + for line in traceback.format_stack(): + if 'frozen' not in line: + stack_str += line + '\n' + import_exception = traceback.format_exc() + '\n' + warning_msg = stack_str + import_exception + \ + 'If pytorch3d is not required,' +\ + ' this warning could be ignored.' + logger.warning(warning_msg) class Compose: diff --git a/tests/test_utils/test_mesh_utils.py b/tests/test_utils/test_mesh_utils.py index 701cc54b..086fd588 100644 --- a/tests/test_utils/test_mesh_utils.py +++ b/tests/test_utils/test_mesh_utils.py @@ -5,8 +5,8 @@ from pytorch3d.renderer.mesh import TexturesVertex from pytorch3d.utils import torus -from mmhuman3d.core.visualization.renderer import build_renderer -from mmhuman3d.core.visualization.renderer.torch3d_renderer.meshes import ( +from mmhuman3d.core.renderer.torch3d_renderer.builder import build_renderer +from mmhuman3d.core.renderer.torch3d_renderer.meshes import ( ParametricMeshes, join_batch_meshes_as_scene, ) diff --git a/tests/test_vis/test_render.py b/tests/test_vis/test_render.py index ce23f49d..7e294531 100644 --- a/tests/test_vis/test_render.py +++ b/tests/test_vis/test_render.py @@ -4,8 +4,8 @@ from mmhuman3d.core.cameras import compute_orbit_cameras from mmhuman3d.core.cameras.builder import build_cameras -from mmhuman3d.core.visualization import render_runner -from mmhuman3d.core.visualization.renderer import build_renderer +from mmhuman3d.core.renderer.torch3d_renderer import render_runner +from mmhuman3d.core.renderer.torch3d_renderer.builder import build_renderer def test_render_runner(): diff --git a/tests/test_vis/test_uv.py b/tests/test_vis/test_uv.py index ef9c1fca..6ebfce2a 100644 --- a/tests/test_vis/test_uv.py +++ b/tests/test_vis/test_uv.py @@ -1,7 +1,7 @@ import torch from pytorch3d.structures import Meshes -from mmhuman3d.core.visualization.renderer import UVRenderer +from mmhuman3d.core.renderer.torch3d_renderer.builder import UVRenderer from mmhuman3d.models.body_models.builder import build_body_model if torch.cuda.is_available(): diff --git a/tests/test_vis/test_vis_smpl.py b/tests/test_vis/test_vis_smpl.py index a242ee85..292e7b46 100644 --- a/tests/test_vis/test_vis_smpl.py +++ b/tests/test_vis/test_vis_smpl.py @@ -4,7 +4,7 @@ import pytest import torch -from mmhuman3d.core.visualization import ( +from mmhuman3d.core.visualization.visualize_smpl import ( visualize_smpl_calibration, visualize_smpl_hmr, visualize_smpl_pose, diff --git a/tools/smplify.py b/tools/smplify.py index a8b00aa1..8302fb78 100644 --- a/tools/smplify.py +++ b/tools/smplify.py @@ -9,7 +9,7 @@ from mmhuman3d.core.conventions.keypoints_mapping import convert_kps from mmhuman3d.core.evaluation import keypoint_mpjpe from mmhuman3d.core.visualization.visualize_smpl import visualize_smpl_pose -from mmhuman3d.data.data_structures import HumanData +from mmhuman3d.data.data_structures.human_data import HumanData from mmhuman3d.models.registrants.builder import build_registrant diff --git a/tools/test_model_builders.py b/tools/test_model_builders.py deleted file mode 100644 index 11ba086e..00000000 --- a/tools/test_model_builders.py +++ /dev/null @@ -1,24 +0,0 @@ -from mmhuman3d.models.architectures.builder import build_architecture - -arch_cfg = dict( - type='PareImportTestor', - backbone=dict( - type='ResNet', - depth=34, - out_indices=[3], - norm_eval=False, - init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet34')), - head=dict( - type='HybrIKHead', - smpl_mean_params='data/body_models/h36m_mean_beta.npy'), - body_model=dict( - type='HybrIKSMPL', - model_path= # noqa: E251 - 'data/body_models/smpl', - extra_joints_regressor='data/body_models/J_regressor_h36m.npy'), - loss_beta=dict(type='MSELoss', loss_weight=1), - loss_theta=dict(type='MSELoss', loss_weight=0.01), - loss_twist=dict(type='MSELoss', loss_weight=0.2), - loss_uvd=dict(type='L1Loss', loss_weight=1), -) -arch = build_architecture(arch_cfg) diff --git a/tools/train.py b/tools/train.py index 90d62961..dc2e6036 100644 --- a/tools/train.py +++ b/tools/train.py @@ -13,7 +13,8 @@ from mmhuman3d.apis import set_random_seed, train_model from mmhuman3d.data.datasets import build_dataset from mmhuman3d.models.architectures.builder import build_architecture -from mmhuman3d.utils import collect_env, get_root_logger +from mmhuman3d.utils.collect_env import collect_env +from mmhuman3d.utils.logger import get_root_logger def parse_args():