smplify-x笔记

SMPL模型

关节点定义如下图
在这里插入图片描述

每个不同的2d数据集都会涉及到joint_mapper,即re-order the SMPL joints to some other convention, 例如coco数据集。

from .vertex_ids import vertex_ids as VERTEX_IDS
if vertex_ids is None:
	# SMPL and SMPL-H share the same topology, so any extra joints can be drawn from the same place.
	vertex_ids = VERTEX_IDS['smplh']
self.vertex_joint_selector = VertexJointSelector(vertex_ids=vertex_ids, **kwargs)
joints = self.vertex_joint_selector(vertices, joints)
# Map the joints to the current dataset
if self.joint_mapper is not None:
	joints = self.joint_mapper(joints)
vertex_ids = {
	'smplh': {
		'nose': 332, 'reye': 6260, 'leye': 2800, 'rear': 4071, 'lear': 583, 'rthumb': 6191, 'rindex': 5782,
		'rmiddle': 5905, 'rring': 6016, 'rpinky': 6133, 'lthumb': 2746, 'lindex': 2319, 'lmiddle': 2445, 'lring': 2556,
		'lpinky': 2673, 'LBigToe': 3216, 'LSmallToe': 3326, 'LHeel': 3387, 'RBigToe': 6617, 'RSmallToe': 6624,
		'RHeel': 6787
	},
	'smplx': {
		'nose': 9120, 'reye': 9929, 'leye': 9448, 'rear': 616, 'lear': 6, 'rthumb': 8079, 'rindex': 7669, 
		'rmiddle': 7794, 'rring': 7905, 'rpinky': 8022, 'lthumb': 5361, 'lindex': 4933, 'lmiddle': 5058, 'lring': 5169,
		'lpinky': 5286, 'LBigToe': 5770, 'LSmallToe': 5780, 'LHeel': 8846, 'RBigToe': 8463, 'RSmallToe': 8474,
		'RHeel': 8635
	},
	'mano': {
		'thumb': 744, 'index': 320, 'middle': 443, 'ring': 554, 'pinky': 671
	}

看了下VertexJointsSelector,其中的逻辑就是在官方定义的joints基础上,从组成mesh的vertexes中再挑选出若干有实质语义的点,补充进joints中,接在后面。默认会把面部的nose, reye, leye, rear, lear五点补充进去,再选择把哪些点补充进去,就取决于初始化参数。当use_feet_keypoints为True时,会把脚部6点补充进去。当use_hands为True时,会把手部10点补充进去。

官方定义的joints,

SMPL: NUM_BODY_JOINTS = 23, NUM_JOINTS = 23
SMPLH: NUM_BODY_JOINTS = 21, NUM_HAND_JOINTS = 15, NUM_JOINTS = NUM_BODY_JOINTS + 2 * NUM_HAND_JOINTS = 51
SMPLX: NUM_BODY_JOINTS = 21, NUM_HAND_JOINTS = 15, NUM_FACE_JOINTS = 3, NUM_JOINTS = NUM_BODY_JOINTS + 2 * NUM_HAND_JOINTS + NUM_FACE_JOINTS = 54

FLAME模型

FLAME:Faces Learned with an Articulated Model and Expressions,是头部模型,有68个landmarks,前17个landmark为人脸轮廓点,后51个landmark为人脸内部关键点。

openpose模型

smplify-x用到了openpose的body/face/hand三个部分的点位,生成json结果的结构化定义如下。body为25点,具体点位定义如下图所示。hand分左右手,每只手21个关键点,face用的是FLAME模型的68点位。
在这里插入图片描述

"people": [{
	"pose_keypoint_2d": [25*3],
	"hand_left_keypoints_2d": [20*3],
	"hand_right_keypoints_2d": [20*3],
	"face_keypoints_2d": [68*3],
	"gender_pd":,
	"gender_gt":,
}]

想要将smpl/smplh/smplx模型的joints映射为openpose的点位格式时,index的映射关系如下

if model_type == 'smpl':
	return np.array([24, 12, 17, 19, 21, 16, 18, 20, 0, 2, 5, 8, 1, 4,
                     7, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34], dtype=np.int32)
elif model_type == 'smplh':
	mapping = [body_mapping, lhand_mapping, rhand_mapping]
elif model_type == 'smplx':
	mapping = [body_mapping, lhand_mapping, rhand_mapping, face_mapping]

相机模型

class PerspectiveCamera(nn.Module):
	def __init__(self, rotation=None, translation=None,
					focal_length_x=None, focal_length_y=None, batch_size=1,
					center=None, dtype=torch.float32, **kwargs):
		rotation = nn.Parameter(rotation, requires_grad=True)
		translation = nn.Parameters(translation, requires_grad=True)
	def forward(self, points):

创建一个透视变换相机,初始化参数为rotation旋转矩阵,translation平移向量,focal_length_x x方向焦距,focal_length_y y方向焦距,batch_size相机个数,center相平面的中心坐标。如果没主动设置,默认焦距为5000。
在这个相机模型里,需要梯度的有rotation,translation。前向部分,完成3d点投影的工作。主要是根据rotation和translation将坐标从世界坐标系转至相机坐标系,再根据相机投影矩阵,将坐标从相机坐标系转换至像素坐标系。

训练损失

E ( β , θ , ψ ) = E J ( β , θ ; K , J e s t ) + E θ b ( θ b ) + E θ f ( θ f ) + E θ h ( θ h ) + E α ( θ b ) + E β ( β ) + E ε ( ψ ) + E ς ( β , θ , ψ ) \begin{aligned} E(\beta, \theta, \psi) &= E_J(\beta, \theta; K, J_{est}) \\ &+ E_{\theta_b}(\theta_b) + E_{\theta_f}(\theta_f) + E_{\theta_h}(\theta_h) + E_{\alpha}(\theta_b) \\ &+ E_{\beta}(\beta) + E_\varepsilon(\psi) \\ &+ E_{\varsigma}(\beta, \theta, \psi) \end{aligned} E(β,θ,ψ)=EJ(β,θ;K,Jest)+Eθb(θb)+Eθf(θf)+Eθh(θh)+Eα(θb)+Eβ(β)+Eε(ψ)+Eς(β,θ,ψ)
第1个data_term是关节点2d投影误差,K是相机投影矩阵。第2~5是Pose Priors, 第6~7是Shape和Expression Priors,最后一个是interpenetration penalty。

  • 2
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
`vue-property-decorator` 是一个用于在 Vue 中使用装饰器语法的库,它提供了一些装饰器来简化 Vue 组件的开发过程。这些装饰器可以用于定义组件的属性、方法、计算属性、生命周期钩子等。 以下是一些常用的装饰器和它们的用法: - `@Component(options?: ComponentOptions)`:将一个类声明为一个 Vue 组件。可以传入一个可选的 `ComponentOptions` 对象来配置组件选项,例如 `template`、`props`、`computed` 等。 - `@Prop(options?: (Vue.PropOptions | Vue.Constructor[] | Vue.Constructor)[] | Vue.PropOptions)`:定义一个组件的 prop 属性。可以传入一个可选的 `PropOptions` 对象来配置 prop 的类型、默认值等。 - `@Watch(path: string, options?: WatchOptions)`:监听一个属性或表达式的变化,并在变化时执行相应的方法。可以传入一个可选的 `WatchOptions` 对象来配置监听选项,例如 `deep`、`immediate` 等。 - `@Emit(event?: string)`:将一个方法标记为触发事件的方法,并指定要触发的事件名。可以传入一个可选的事件名,默认为方法名。 - `@Ref(refKey?: string)`:获取子组件或 DOM 元素的引用,并将其赋值给指定的属性。可以传入一个可选的引用键,默认为属性名。 - `@Inject(key?: string | symbol)`:注入一个父组件提供的属性或方法。可以传入一个可选的注入键,默认为属性名。 - `@Provide(key?: string | symbol)`:在组件中提供属性或方法,以供子组件注入使用。可以传入一个可选的提供键,默认为属性名。 - `@Model(event?: string, options?: (PropOptions | Constructor[] | Constructor)[] | PropOptions)`:将一个 prop 属性设置为组件的 v-model。可以指定要触发的事件名和 prop 的配置选项。 这些装饰器可以与 `vue-class-component` 一起使用,帮助我们更清晰、简洁地定义 Vue 组件,并提供更好的类型支持和可读性。 希望这些笔记对你有所帮助!如有任何疑问,请随时提问。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值