3D头模加载

目录

psbody加载

psbody示例

trimesh加载

加载动画:

openmesh


psbody加载

codetalker

python 复制代码
from psbody.mesh import Mesh

    if cfg.dataset == "BIWI":
        template_file = os.path.join(cfg.data_root, "BIWI.ply")
    elif cfg.dataset == "vocaset":
        template_file = os.path.join(cfg.data_root, "FLAME_sample.ply")
         
    print("rendering: ", test_name)
                 
    template = Mesh(filename=template_file)

psbody示例

python 复制代码
from psbody.mesh import Mesh
from psbody.mesh.meshviewer import MeshViewer

template_file = r'BIWI/BIWI.ply'
template_file = r'E:\project\audio\audio2face\CodeTalker-main\vocaset\FLAME_sample.ply'
# template_file = r'E:\project\audio\audio2face\CodeTalker-main\BIWI\BIWI.ply'

target_mesh = Mesh(filename=template_file)
target_mesh.set_vertex_colors('white')
viewer = MeshViewer()
# viewer.set_background_color((1.0, 1.0, 1.0),blocking=False)

viewer.set_static_meshes([target_mesh], blocking=True)
# viewer.set_dynamic_meshes(target_mesh)
viewer.set_background_color((1.0, 1.0, 1.0))
viewer.show()

这个显示是黑屏,不能显示物体

trimesh加载

FaceDiffuser

python 复制代码
import trimesh

if __name__ == '__main__':
    template_file=f"data/BIWI/templates/face_template.obj"
    ref_mesh = trimesh.load_mesh(template_file, process=False)

    scene = trimesh.scene.scene.Scene([ref_mesh])

    # 显示场景
    scene.show()

报错:

python 复制代码
ImportError: `trimesh.viewer.windowed` requires `pip install "pyglet<2"`

解决方法:

pip install "pyglet<2"

加载动画:

python 复制代码
import trimesh

import numpy as np

def load_mesh(file_path):
    """加载PLY文件并返回网格对象。"""
    return trimesh.load(file_path, process=False)

def apply_smile(mesh, intensity=0.5):
    """模拟微笑通过向上移动模型嘴角附近的顶点。"""
    # 假设嘴角的顶点索引已知
    mouth_corner_indices = [1500, 2300]  # 示例索引,需要根据实际模型调整

    movement = np.array([0, intensity, 0])  # 向上移动
    for idx in mouth_corner_indices:
        print(f"Vertex_o {idx}: {mesh.vertices[idx]}")  # 打印原始顶点位置
    # 更新嘴角顶点位置
    for idx in range(mouth_corner_indices[0],mouth_corner_indices[1]):
        mesh.vertices[idx] += movement
    for idx in mouth_corner_indices:
        print(f"Vertex {idx}: {mesh.vertices[idx]}")  # 打印更新后的顶点位置
def main():
    # 路径替换为你的PLY文件路径
    mesh = load_mesh(r'E:\BIWI.ply')

    # 应用微笑表情变换
    apply_smile(mesh, intensity=0.1)  # 强度根据模型尺度调整

    # 使用trimesh提供的简单pyglet窗口显示结果
    mesh.show()

if __name__ == "__main__":
    main()

openmesh

pip install openmesh

win11直接安装报错

从巴塞尔面模型 (BFM) 转换为 FLAME 头部模型

https://github.com/TimoBolkart/BFM_to_FLAME

相关推荐
武汉星际互动4 小时前
从“一件事”到“一类事”,政务服务改革的“下一站”在哪里?
大数据·人工智能·政务
朝朝辞暮i4 小时前
VLA 系统学习第 20 课——Diffusion Policy 为什么要先给动作加噪,再学习把噪声去掉?
人工智能·python·深度学习·transformer·vla
七夜zippoe4 小时前
Agent 权限边界:别让 AI 误删你的生产库(安全设计)
数据库·人工智能·安全·ai·权限边界·安全设计
田里的水稻4 小时前
RL_强化学习概述---具身机器人
人工智能·深度学习·神经网络·机器学习
朝朝辞暮i4 小时前
第一部分:ACT 阶段总结——从 Behavior Cloning 到完整的 Transformer Action Policy
人工智能·pytorch·深度学习·transformer·vla
Allen_LVyingbo4 小时前
生命过程的分子语言:AI 解析范式与场景应用全景研究(上)
大数据·人工智能·知识图谱·健康医疗·数据库开发·数据库架构
KKKlucifer4 小时前
国内数据分类分级平台的路线分化与落地边界
大数据·人工智能·分类
Joecien4 小时前
大模型做分类的第三条路:百炼决策模型实测,46ms 一次前向出概率,阈值标定是接入前提
人工智能·分类·数据挖掘
用户7196975933584 小时前
YOLO-World 精读:慢的不是检测器,是文本编码器
人工智能
alonglong4 小时前
RAG 增量索引实测:把 434.7 秒的全量重建压到 1.35 秒,以及"字节级一致"为什么只属于复用路径
人工智能