適用於圖形的可微分層。

import numpy as np
import tensorflow as tf
import trimesh

import tensorflow_graphics.geometry.transformation as tfg_transformation
from tensorflow_graphics.notebooks import threejs_visualization

# Download the mesh.
!wget https://storage.googleapis.com/tensorflow-graphics/notebooks/index/cow.obj
# Load the mesh.
mesh = trimesh.load("cow.obj")
mesh = {"vertices": mesh.vertices, "faces": mesh.faces}
# Visualize the original mesh.
threejs_visualization.triangular_mesh_renderer(mesh, width=400, height=400)
# Set the axis and angle parameters.
axis = np.array((0., 1., 0.))  # y axis.
angle = np.array((np.pi / 4.,))  # 45 degree angle.
# Rotate the mesh.
mesh["vertices"] = tfg_transformation.axis_angle.rotate(mesh["vertices"], axis,
                                                        angle).numpy()
# Visualize the rotated mesh.
threejs_visualization.triangular_mesh_renderer(mesh, width=400, height=400)
Notebook 中執行
TensorFlow Graphics 旨在提供一組可微分的圖形層 (例如攝影機、反射模型、網格捲積) 和 3D 檢視器功能 (例如 3D TensorBoard),讓社群廣泛使用實用的圖形函式,這些功能可用於您選擇的機器學習模型。

過去幾年,已出現許多新穎的可微分圖形層,可以插入神經網路架構中。從空間轉換器到可微分圖形渲染器,這些新層利用多年來在電腦視覺和圖形研究中獲得的知識,來建構新穎且更有效率的網路架構。將幾何先驗和約束明確地建模到機器學習模型中,為可以穩健、有效率地訓練,更重要的是,以自我監督方式訓練的架構開啟了大門。

若要開始使用,請參閱更詳細的總覽安裝指南API