从faces_glintasia的.rec数据集转换为jpg图片

本文介绍如何将faces_glintasia的.rec格式数据集转换为jpg图片,适用于计算机视觉和深度学习研究。内容包括使用Python进行数据处理的步骤和方法。
摘要由CSDN通过智能技术生成
import mxnet as mx
import mxnet.ndarray as nd
from skimage import io
import numpy as np
from mxnet import recordio
from tqdm import tqdm

path_prefix = 'D:\\BaiduNetdiskDownload\\faces_glintasia\\train' # 存放.rec文件的文件夹
output_dir = path_prefix + 'data'  # 输出路径

rec_path = str(path_prefix + '.rec')
idx_path =</
  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
One of the main challenges in feature learning using Deep Convolutional Neural Networks (DCNNs) for large- scale face recognition is the design of appropriate loss func- tions that enhance discriminative power. Centre loss pe- nalises the distance between the deep features and their cor- responding class centres in the Euclidean space to achieve intra-class compactness. SphereFace assumes that the lin- ear transformation matrix in the last fully connected layer can be used as a representation of the class centres in an angular space and penalises the angles between the deep features and their corresponding weights in a multiplicative way. Recently, a popular line of research is to incorporate margins in well-established loss functions in order to max- imise face class separability. In this paper, we propose an Additive Angular Margin Loss (ArcFace) to obtain highly discriminative features for face recognition. The proposed ArcFace has a clear geometric interpretation due to the ex- act correspondence to the geodesic distance on the hyper- sphere. We present arguably the most extensive experimen- tal evaluation of all the recent state-of-the-art face recog- nition methods on over 10 face recognition benchmarks in- cluding a new large-scale image database with trillion level of pairs and a large-scale video dataset. We show that Ar- cFace consistently outperforms the state-of-the-art and can be easily implemented with negligible computational over- head. We release all refined training data, training codes, pre-trained models and training logs 1 , which will help re- produce the results in this paper
根据你提供的代码,我对其进行了一些改进。主要的改进包括: 1. 使用 `reserve` 方法为 `boss_face_dir_data_vec` 预分配足够的空间,避免不必要的内存重新分配。 2. 将 `boss_faces_dirs_map` 的键类型改为 `Vector3d`,以便与 `boss_faces_dirs` 中的元素类型匹配。 3. 在 `std::find_if` 中使用 lambda 表达式来进行查找,并修正了 `isEqual` 函数的调用。 4. 修正了 `temaa` 的使用,确保在 `std::find_if` 中正确地使用它。 下面是改进后的代码: ```cpp #include <iostream> #include <vector> #include <unordered_map> #include <algorithm> struct BossFacesDirData { int dir_num; double face_dir[3]; }; bool isEqual(const Vector3d& dir1, const Vector3d& dir2) { return (std::abs(dir1.x - dir2.x) < 0.001 && std::abs(dir1.y - dir2.y) < 0.001 && std::abs(dir1.z - dir2.z) < 0.001); } int main() { std::vector<BossFacesDirData> boss_face_dir_data_vec; boss_face_dir_data_vec.reserve(boss_faces.size()); std::unordered_map<Vector3d, int> boss_faces_dirs_map; for (int b = 0; b < boss_faces_dirs.size(); b++) { boss_faces_dirs_map[boss_faces_dirs[b]] = b + 1; } for (int a = 0; a < boss_faces.size(); a++) { double temp_dir1[3]; getFaceDir(boss_faces[a], temp_dir1); Vector3d temaa(temp_dir1[0], temp_dir1[1], temp_dir1[2]); auto it = std::find_if(boss_faces_dirs_map.begin(), boss_faces_dirs_map.end(), [&](const auto& pair) { return isEqual(pair.first, temaa); }); BossFacesDirData boss_face_dir_data; boss_face_dir_data.dir_num = (it != boss_faces_dirs_map.end()) ? it->second : 0; std::copy_n(temp_dir1, 3, boss_face_dir_data.face_dir); boss_face_dir_data_vec.emplace_back(std::move(boss_face_dir_data)); if (boss_face_dir_data.dir_num > 20) { break; } } // 输出分组结果 for (const auto& data : boss_face_dir_data_vec) { std::cout << "Dir Num: " << data.dir_num << ", Face Dir: " << data.face_dir[0] << ", " << data.face_dir[1] << ", " << data.face_dir[2] << std::endl; } return 0; } ``` 请注意,你需要确保 `Vector3d` 类型已正确定义,并且 `getFaceDir` 函数返回一个正确的方向向量。对于 `isEqual` 函数,你可能需要根据你的具体需求进行适当的修改。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值