300w_lp数据欧拉角分布——展望训练模型(重要)

import os
import numpy as np
import scipy.io
import matplotlib.pyplot as plt
from collections import Counter

# Path to the directory containing MATLAB pose annotation files
directory_path = 'C:\Demos\deep-head-pose\\300W_LP\AFW'

# Function to process a single MATLAB file and return Euler angles
def process_mat_file(file_path):
    try:
        # Load the MATLAB file
        mat = scipy.io.loadmat(file_path)

        # Extract pose parameters
        pose_params = mat['Pose_Para'][0]

        # Extract the rotation matrix and translation vector
        if pose_params.size >= 3:
            pitch_param, yaw_param, roll_param = pose_params[:3]
        else:
            raise ValueError(f"Unexpected shape for Pose_Para in {file_path}. Expected at least 3 elements, got {pose_params.size}")

        # Convert the parameters to degrees
        roll = roll_param * 180 / np.pi
        pitch = pitch_param * 180 / np.pi
        yaw = yaw_param * 180 / np.pi

        return roll, pitch, yaw
    except Exception as e:
        print(f"Error processing {file_path}: {e}")
        return None, None, None

# Initialize counters for each Euler angle
rolls = []
pitches = []
yaws = []

# Iterate through all files in the directory
for root, dirs, files in os.walk(directory_path):
    for file in files:
        if file.endswith('.mat'):
            file_path = os.path.join(root, file)
            roll, pitch, yaw = process_mat_file(file_path)
            if roll is not None:
                rolls.append(round(roll))
                pitches.append(round(pitch))
                yaws.append(round(yaw))

# Count occurrences of each angle
roll_counter = Counter(rolls)
pitch_counter = Counter(pitches)
yaw_counter = Counter(yaws)

# Plot the histograms
fig, axes = plt.subplots(3, 1, figsize=(10, 15))

# Roll
axes[0].bar(roll_counter.keys(), roll_counter.values())
axes[0].set_title('Roll Angle Distribution')
axes[0].set_xlabel('Roll Angle (degrees)')
axes[0].set_ylabel('Count')

# Pitch
axes[1].bar(pitch_counter.keys(), pitch_counter.values())
axes[1].set_title('Pitch Angle Distribution')
axes[1].set_xlabel('Pitch Angle (degrees)')
axes[1].set_ylabel('Count')

# Yaw
axes[2].bar(yaw_counter.keys(), yaw_counter.values())
axes[2].set_title('Yaw Angle Distribution')
axes[2].set_xlabel('Yaw Angle (degrees)')
axes[2].set_ylabel('Count')

plt.tight_layout()
plt.show()

在这里插入图片描述

训练模型

根据训练多次训练模型得出了Retinaface模型如何训练自制遮罩图片集效果好,那就是均匀分布头部位姿,不同人上下左右各几张,总共100张左右就能训练出不错的模型效果

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值