使用 VisionTransformer(VIT) FineTune 训练驾驶员行为状态识别模型

本文主要是介绍使用 VisionTransformer(VIT) FineTune 训练驾驶员行为状态识别模型,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

一、VisionTransformer(VIT) 介绍

大模型已经成为人工智能领域的热门话题。在这股热潮中,大模型的核心结构 Transformer 也再次脱颖而出证明了其强大的能力和广泛的应用前景。Transformer2017年由Google提出以来,便在NLP领域掀起了一场革命。相较于传统的循环神经网络(RNN)和长短时记忆网络(LSTM), Transformer 凭借自注意力机制和端到端训练方式,以及处理长距离依赖问题上显著的优势,使其在多项NLP任务中都取得了卓越表现,常见模型例如:BERTGPT 等。

随着 TransformerNLP领域的成功,慢慢的也开始进军到了CV领域。在 CV 领域中,卷积神经网络(CNN)一直占据主导地位。然而,CNN 的卷积操作限制了其对全局信息的捕捉,导致在处理复杂场景时效果不佳。相比之下,Transformer 能够更好地捕捉长距离依赖关系,有助于识别图像中的全局特征,另外,自注意力机制也能使得模型关注到不同区域的重要信息,提高特征提取的准确性。

但是要想 Transformer 处理图像,首选需要考虑如何将图像转为序列数据,因为 CNN 的输入通常是一个四维张量,其维度通常表示为 [批次大小, 高度, 宽度, 通道数],一般图像也是RGB三维的,所以可以非常方便的处理图像数据。而 Transformer 的输入是一个三维张量,其维度表示为 [批次大小,序列长度, 嵌入维度],维度的不同导致不能直接将图像传入 Transformer 结构 。

对此 VisionTransformer (VIT)巧妙的例用了 CNN 解决了维度不一致的问题,成为了将 Transformer 架构应用于 CV 领域的一种创新方法, 下面是 VIT 的架构图:

在这里插入图片描述

首先,VIT将输入图像分割成一系列固定大小的图像块(利用CNN),每个块就像NLP中的单词一样,成为序列中的一个元素,这点类似于文本模型中的 Embedding 层。这种分割方法使得图像的局部特征得以保留,并为后续的处理提供了基础。接着,为了确保模型能够理解图像块的空间位置,VIT为每个图像块添加了位置编码,这些编码是可学习的参数,它们准确地指示了每个块在原始图像中的位置。

然后,每个图像块被展平成一维向量,并通过一个线性层进行嵌入,转换成高维向量。这个过程类似于在自然语言处理中将单词映射到词嵌入向量。完成嵌入后,这些向量被送入标准的Transformer编码器中。编码器由多个自注意力层和前馈网络组成,它们能够捕捉图像块之间的复杂交互和依赖关系。

最后,VITTransformer编码器的输出上添加了一个分类头,通常是一个全连接层,用于生成最终的分类结果。

下面是 VIT-Base 的据图结构:

VisionTransformer((conv_proj): Conv2d(3, 768, kernel_size=(16, 16), stride=(16, 16))(encoder): Encoder((dropout): Dropout(p=0.0, inplace=False)(layers): Sequential((encoder_layer_0): EncoderBlock((ln_1): LayerNorm((768,), eps=1e-06, elementwise_affine=True)(self_attention): MultiheadAttention((out_proj): NonDynamicallyQuantizableLinear(in_features=768, out_features=768, bias=True))(dropout): Dropout(p=0.0, inplace=False)(ln_2): LayerNorm((768,), eps=1e-06, elementwise_affine=True)(mlp): MLPBlock((0): Linear(in_features=768, out_features=3072, bias=True)(1): GELU(approximate='none')(2): Dropout(p=0.0, inplace=False)(3): Linear(in_features=3072, out_features=768, bias=True)(4): Dropout(p=0.0, inplace=False)))(encoder_layer_1): EncoderBlock((ln_1): LayerNorm((768,), eps=1e-06, elementwise_affine=True)(self_attention): MultiheadAttention((out_proj): NonDynamicallyQuantizableLinear(in_features=768, out_features=768, bias=True))(dropout): Dropout(p=0.0, inplace=False)(ln_2): LayerNorm((768,), eps=1e-06, elementwise_affine=True)(mlp): MLPBlock((0): Linear(in_features=768, out_features=3072, bias=True)(1): GELU(approximate='none')(2): Dropout(p=0.0, inplace=False)(3): Linear(in_features=3072, out_features=768, bias=True)(4): Dropout(p=0.0, inplace=False)))(encoder_layer_2): EncoderBlock((ln_1): LayerNorm((768,), eps=1e-06, elementwise_affine=True)(self_attention): MultiheadAttention((out_proj): NonDynamicallyQuantizableLinear(in_features=768, out_features=768, bias=True))(dropout): Dropout(p=0.0, inplace=False)(ln_2): LayerNorm((768,), eps=1e-06, elementwise_affine=True)(mlp): MLPBlock((0): Linear(in_features=768, out_features=3072, bias=True)(1): GELU(approximate='none')(2): Dropout(p=0.0, inplace=False)(3): Linear(in_features=3072, out_features=768, bias=True)(4): Dropout(p=0.0, inplace=False)))(encoder_layer_3): EncoderBlock((ln_1): LayerNorm((768,), eps=1e-06, elementwise_affine=True)(self_attention): MultiheadAttention((out_proj): NonDynamicallyQuantizableLinear(in_features=768, out_features=768, bias=True))(dropout): Dropout(p=0.0, inplace=False)(ln_2): LayerNorm((768,), eps=1e-06, elementwise_affine=True)(mlp): MLPBlock((0): Linear(in_features=768, out_features=3072, bias=True)(1): GELU(approximate='none')(2): Dropout(p=0.0, inplace=False)(3): Linear(in_features=3072, out_features=768, bias=True)(4): Dropout(p=0.0, inplace=False)))(encoder_layer_4): EncoderBlock((ln_1): LayerNorm((768,), eps=1e-06, elementwise_affine=True)(self_attention): MultiheadAttention((out_proj): NonDynamicallyQuantizableLinear(in_features=768, out_features=768, bias=True))(dropout): Dropout(p=0.0, inplace=False)(ln_2): LayerNorm((768,), eps=1e-06, elementwise_affine=True)(mlp): MLPBlock((0): Linear(in_features=768, out_features=3072, bias=True)(1): GELU(approximate='none')(2): Dropout(p=0.0, inplace=False)(3): Linear(in_features=3072, out_features=768, bias=True)(4): Dropout(p=0.0, inplace=False)))(encoder_layer_5): EncoderBlock((ln_1): LayerNorm((768,), eps=1e-06, elementwise_affine=True)(self_attention): MultiheadAttention((out_proj): NonDynamicallyQuantizableLinear(in_features=768, out_features=768, bias=True))(dropout): Dropout(p=0.0, inplace=False)(ln_2): LayerNorm((768,), eps=1e-06, elementwise_affine=True)(mlp): MLPBlock((0): Linear(in_features=768, out_features=3072, bias=True)(1): GELU(approximate='none')(2): Dropout(p=0.0, inplace=False)(3): Linear(in_features=3072, out_features=768, bias=True)(4): Dropout(p=0.0, inplace=False)))(encoder_layer_6): EncoderBlock((ln_1): LayerNorm((768,), eps=1e-06, elementwise_affine=True)(self_attention): MultiheadAttention((out_proj): NonDynamicallyQuantizableLinear(in_features=768, out_features=768, bias=True))(dropout): Dropout(p=0.0, inplace=False)(ln_2): LayerNorm((768,), eps=1e-06, elementwise_affine=True)(mlp): MLPBlock((0): Linear(in_features=768, out_features=3072, bias=True)(1): GELU(approximate='none')(2): Dropout(p=0.0, inplace=False)(3): Linear(in_features=3072, out_features=768, bias=True)(4): Dropout(p=0.0, inplace=False)))(encoder_layer_7): EncoderBlock((ln_1): LayerNorm((768,), eps=1e-06, elementwise_affine=True)(self_attention): MultiheadAttention((out_proj): NonDynamicallyQuantizableLinear(in_features=768, out_features=768, bias=True))(dropout): Dropout(p=0.0, inplace=False)(ln_2): LayerNorm((768,), eps=1e-06, elementwise_affine=True)(mlp): MLPBlock((0): Linear(in_features=768, out_features=3072, bias=True)(1): GELU(approximate='none')(2): Dropout(p=0.0, inplace=False)(3): Linear(in_features=3072, out_features=768, bias=True)(4): Dropout(p=0.0, inplace=False)))(encoder_layer_8): EncoderBlock((ln_1): LayerNorm((768,), eps=1e-06, elementwise_affine=True)(self_attention): MultiheadAttention((out_proj): NonDynamicallyQuantizableLinear(in_features=768, out_features=768, bias=True))(dropout): Dropout(p=0.0, inplace=False)(ln_2): LayerNorm((768,), eps=1e-06, elementwise_affine=True)(mlp): MLPBlock((0): Linear(in_features=768, out_features=3072, bias=True)(1): GELU(approximate='none')(2): Dropout(p=0.0, inplace=False)(3): Linear(in_features=3072, out_features=768, bias=True)(4): Dropout(p=0.0, inplace=False)))(encoder_layer_9): EncoderBlock((ln_1): LayerNorm((768,), eps=1e-06, elementwise_affine=True)(self_attention): MultiheadAttention((out_proj): NonDynamicallyQuantizableLinear(in_features=768, out_features=768, bias=True))(dropout): Dropout(p=0.0, inplace=False)(ln_2): LayerNorm((768,), eps=1e-06, elementwise_affine=True)(mlp): MLPBlock((0): Linear(in_features=768, out_features=3072, bias=True)(1): GELU(approximate='none')(2): Dropout(p=0.0, inplace=False)(3): Linear(in_features=3072, out_features=768, bias=True)(4): Dropout(p=0.0, inplace=False)))(encoder_layer_10): EncoderBlock((ln_1): LayerNorm((768,), eps=1e-06, elementwise_affine=True)(self_attention): MultiheadAttention((out_proj): NonDynamicallyQuantizableLinear(in_features=768, out_features=768, bias=True))(dropout): Dropout(p=0.0, inplace=False)(ln_2): LayerNorm((768,), eps=1e-06, elementwise_affine=True)(mlp): MLPBlock((0): Linear(in_features=768, out_features=3072, bias=True)(1): GELU(approximate='none')(2): Dropout(p=0.0, inplace=False)(3): Linear(in_features=3072, out_features=768, bias=True)(4): Dropout(p=0.0, inplace=False)))(encoder_layer_11): EncoderBlock((ln_1): LayerNorm((768,), eps=1e-06, elementwise_affine=True)(self_attention): MultiheadAttention((out_proj): NonDynamicallyQuantizableLinear(in_features=768, out_features=768, bias=True))(dropout): Dropout(p=0.0, inplace=False)(ln_2): LayerNorm((768,), eps=1e-06, elementwise_affine=True)(mlp): MLPBlock((0): Linear(in_features=768, out_features=3072, bias=True)(1): GELU(approximate='none')(2): Dropout(p=0.0, inplace=False)(3): Linear(in_features=3072, out_features=768, bias=True)(4): Dropout(p=0.0, inplace=False))))(ln): LayerNorm((768,), eps=1e-06, elementwise_affine=True))(heads): Sequential((head): Linear(in_features=768, out_features=1000, bias=True))
)

从结构中可以看出,输入三维图像, 经过(16, 16) 的卷积核,并且步长也是 (16, 16) ,如果输入大小为 (224, 224) ,则输出就为 768 个大小为 (14,14) 的特征图,然后每个特征图在展平成一维向量就是 (batch,768,196) ,接着后面就可以喂入到 Transformer 结构了。

上面对 VIT 有了简单的了解后,下卖弄使用 Pytorch vit_b_16 模型 FineTune 训练下 Kaggle 比赛中的驾驶员状态数据集。

实验使用的依赖版本如下:

torch==1.13.1+cu116
torchvision==0.14.1+cu116
tensorboard==2.17.1
tensorboard-data-server==0.7.2

二、准备数据集

驾驶员状态数据集这里使用 Kaggle 比赛的数据,由于官网已经没办法下载了,这里可以在 百度的 aistudio 公开数据集中下载:

https://aistudio.baidu.com/datasetdetail/35503

下载后可以看到训练集下有10个分类:

在这里插入图片描述
分别表示:

分类解释
c0安全驾驶
c1右手使用手机
c2右手打电话
c3左手使用手机
c4左手打电话
c5操作中控台
c6喝水
c7向后伸手
c8手摸头发或化妆
c9与人交谈

每个类别下的示例图像如下:

在这里插入图片描述

数据集的分布如下,每个类别整体分布2000 左右:

在这里插入图片描述

三、VIT FineTune 训练

Pytorch 中已经集成好了 VIT 结构,这里使用 vit_b_16 为例,可以选择冻结所有原来模型的参数,追加两层全链接层:

net.py

from torchvision import models
import torch.nn as nnclass Model(nn.Module):def __init__(self, num_classes):super(Model, self).__init__()# 加载预训练的 vit_b_16 模型self.base_model = models.vit_b_16(pretrained=True)print(self.base_model)# 冻结主干网络的权重for param in self.base_model.parameters():param.requires_grad = Falseself.relu = nn.ReLU()self.fc1 = nn.Linear(self.base_model.heads.head.out_features, 1024)self.dropout1 = nn.Dropout(p=0.2)self.fc2 = nn.Linear(1024, 512)self.dropout2 = nn.Dropout(p=0.1)self.fc3 = nn.Linear(512, num_classes)def forward(self, x):x = self.base_model(x)x = self.fc1(x)x = self.relu(x)x = self.dropout1(x)x = self.fc2(x)x = self.relu(x)x = self.dropout2(x)x = self.fc3(x)return x

或者不冻结原有的参数,也不改变原来模型的结构,在此基础上继续训练新的类别,可以使用如下结构,直接将 head 层的输出改为分类的大小:

net.py

from torchvision import models
import torch.nn as nnclass Model(nn.Module):def __init__(self, num_classes):super(Model, self).__init__()# 加载预训练模型self.base_model = models.vit_b_16(pretrained=True)print(self.base_model)num_ftrs = self.base_model.heads.head.in_features# 修改最后一层的输出数self.base_model.heads.head = nn.Linear(num_ftrs, num_classes)print(self.base_model)def forward(self, x):return self.base_model(x)

这里我使用第一种方式,显存占用比较小,整体训练过程如下,其中使用 80% 的数据训练,20% 的数据验证:

import os.path
import torch
from torchvision import datasets, models, transforms
from torch.utils.data import DataLoader, random_split
import torch.nn as nn
import torch.optim as optim
from tqdm import tqdm
from torch.utils.tensorboard import SummaryWriter
from net import Model
import sys, json# 设置随机种子, 让结果可复现
torch.manual_seed(0)# 加载数据集
def load_data(data_dir, train_ratio, data_transforms, batch_size):# 读取数据集dataset = datasets.ImageFolder(data_dir, data_transforms)# 拆分为训练集和验证集train_size = int(train_ratio * len(dataset))val_size = len(dataset) - train_sizetrain_dataset, val_dataset = random_split(dataset, [train_size, val_size])train_loader = DataLoader(train_dataset, batch_size=batch_size, shuffle=True)val_loader = DataLoader(val_dataset, batch_size=batch_size, shuffle=False)return train_loader, val_loader, dataset.classes# 迭代训练
def train_model(model, criterion, optimizer, train_loader, val_loader, device, output_dir, writer, num_epochs=10):best_accuracy, global_step = 0.0, 0for epoch in range(num_epochs):model.train()running_loss = 0.0for inputs, labels in tqdm(train_loader, file=sys.stdout, desc="Train Epoch: " + str(epoch)):inputs, labels = inputs.to(device), labels.to(device)optimizer.zero_grad()outputs = model(inputs)loss = criterion(outputs, labels)loss.backward()optimizer.step()running_loss += loss.item()writer.add_scalar('Loss/train', loss, global_step)global_step += 1train_loss = running_loss / len(train_loader)# 验证模型model.eval()accuracy, val_loss = validate_model(model, val_loader, device, epoch, criterion)tqdm.write(f'Epoch {epoch + 1}, Device: {device}, Loss: {train_loss}, Val Loss: {val_loss} , Current Accuracy: {accuracy}')writer.add_scalar('Loss/val', val_loss, epoch)writer.add_scalar('Accuracy/val', accuracy, epoch)if accuracy > best_accuracy:# 保存最优模型结构torch.save(model.state_dict(), os.path.join(output_dir, 'best_model.pth'))best_accuracy = accuracy# 保存最终模型结构torch.save(model.state_dict(), os.path.join(output_dir, 'last_model.pth'))# 验证模型
def validate_model(model, val_loader, device, epoch, criterion):correct = 0total = 0running_loss = 0.0with torch.no_grad():for inputs, labels in tqdm(val_loader, file=sys.stdout, desc="Val Epoch: " + str(epoch)):inputs, labels = inputs.to(device), labels.to(device)outputs = model(inputs)loss = criterion(outputs, labels)running_loss += loss.item()_, predicted = torch.max(outputs, 1)total += labels.size(0)correct += (predicted == labels).sum().item()return 100 * correct / total, running_loss / len(val_loader)def main():# 数据集地址data_dir = 'imgs/train'# 模型保存目录output_dir = "model"# 日志输出目录logs_dir = "logs"# 训练集的比例train_ratio = 0.8# 批次大小batch_size = 45# 学习率lr = 1e-3# 迭代周期epochs = 50data_transforms = transforms.Compose([transforms.Resize(256),transforms.CenterCrop(224),transforms.ToTensor(),transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])])# 加载数据集,80% 训练,20% 验证train_loader, val_loader, classes = load_data(data_dir=data_dir,train_ratio=train_ratio,data_transforms=data_transforms,batch_size=batch_size)if not os.path.exists(output_dir):os.mkdir(output_dir)# 记录分类顺序with open(os.path.join(output_dir, "classify.txt"), "w", encoding="utf-8") as w:w.write(json.dumps(classes, ensure_ascii=False))# 日志记录writer = SummaryWriter(logs_dir)# 设备device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")# 加载模型结构model = Model(len(classes))print(model)# 损失函数criterion = nn.CrossEntropyLoss()# 优化器optimizer = optim.AdamW(model.parameters(), lr=lr)# 训练model.to(device)train_model(model=model,criterion=criterion,optimizer=optimizer,train_loader=train_loader,val_loader=val_loader,device=device,output_dir=output_dir,writer=writer,num_epochs=epochs)writer.close()if __name__ == '__main__':main()

训练期间大概占用显存两个G左右:

在这里插入图片描述

训练过程,可以看到验证集的准确率在逐步提升以及loss在逐步收敛:

在这里插入图片描述

训练结束后,可以查看下 tensorboard 中你的 loss 和 准确率的曲线:

tensorboard --logdir=logs --bind_all

在 浏览器访问 http:ip:6006/

在这里插入图片描述

在验证集上的准确率达到 98.5 左右,loss 的波动还是蛮大的,大家也可以加入更多优化策略进来。

四、模型测试

import os
import torch
from torchvision import transforms
from net import Model
import matplotlib.pyplot as plt
from PIL import Image
import jsonplt.rcParams['font.sans-serif'] = ['SimHei']classify_cn = {"c0": "安全驾驶","c1": "右手使用手机","c2": "右手打电话","c3": "左手使用手机","c4": "左手打电话","c5": "操作中控台","c6": "喝水","c7": "向后伸手","c8": "手摸头发或化妆","c9": "与人交谈"
}def main():image_dir = "imgs/test"# 读取分类with open("model/classify.txt", "r", encoding="utf-8") as r:classify = json.loads(r.read())# 使用设备device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")# 加载模型model = Model(len(classify))model.load_state_dict(torch.load('model/best_model.pth'))model = model.to(device)data_transforms = transforms.Compose([transforms.Resize(224),transforms.CenterCrop(224),transforms.ToTensor(),transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])])imgs = os.listdir(image_dir)# 分成四个一组imgs = list(zip(*[iter(imgs)] * 4))for names in imgs:plt.figure(figsize=(8, 8))for i, name in enumerate(names):plt.subplot(2, 2, i + 1)image = Image.open(os.path.join(image_dir, name)).convert('RGB')img = data_transforms(image).unsqueeze(0)img = img.to(device)with torch.no_grad():output = model(img)_, predicted = torch.max(output.data, 1)label = classify_cn[classify[predicted[0].item()]]plt.imshow(image)plt.title(label)plt.show()if __name__ == '__main__':main()

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

这篇关于使用 VisionTransformer(VIT) FineTune 训练驾驶员行为状态识别模型的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1145054

相关文章

shell编程之函数与数组的使用详解

《shell编程之函数与数组的使用详解》:本文主要介绍shell编程之函数与数组的使用,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录shell函数函数的用法俩个数求和系统资源监控并报警函数函数变量的作用范围函数的参数递归函数shell数组获取数组的长度读取某下的

使用Python开发一个带EPUB转换功能的Markdown编辑器

《使用Python开发一个带EPUB转换功能的Markdown编辑器》Markdown因其简单易用和强大的格式支持,成为了写作者、开发者及内容创作者的首选格式,本文将通过Python开发一个Markd... 目录应用概览代码结构与核心组件1. 初始化与布局 (__init__)2. 工具栏 (setup_t

Python虚拟环境终极(含PyCharm的使用教程)

《Python虚拟环境终极(含PyCharm的使用教程)》:本文主要介绍Python虚拟环境终极(含PyCharm的使用教程),具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,... 目录一、为什么需要虚拟环境?二、虚拟环境创建方式对比三、命令行创建虚拟环境(venv)3.1 基础命令3

Python Transformer 库安装配置及使用方法

《PythonTransformer库安装配置及使用方法》HuggingFaceTransformers是自然语言处理(NLP)领域最流行的开源库之一,支持基于Transformer架构的预训练模... 目录python 中的 Transformer 库及使用方法一、库的概述二、安装与配置三、基础使用:Pi

关于pandas的read_csv方法使用解读

《关于pandas的read_csv方法使用解读》:本文主要介绍关于pandas的read_csv方法使用,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录pandas的read_csv方法解读read_csv中的参数基本参数通用解析参数空值处理相关参数时间处理相关

使用Node.js制作图片上传服务的详细教程

《使用Node.js制作图片上传服务的详细教程》在现代Web应用开发中,图片上传是一项常见且重要的功能,借助Node.js强大的生态系统,我们可以轻松搭建高效的图片上传服务,本文将深入探讨如何使用No... 目录准备工作搭建 Express 服务器配置 multer 进行图片上传处理图片上传请求完整代码示例

SpringBoot条件注解核心作用与使用场景详解

《SpringBoot条件注解核心作用与使用场景详解》SpringBoot的条件注解为开发者提供了强大的动态配置能力,理解其原理和适用场景是构建灵活、可扩展应用的关键,本文将系统梳理所有常用的条件注... 目录引言一、条件注解的核心机制二、SpringBoot内置条件注解详解1、@ConditionalOn

Python中使用正则表达式精准匹配IP地址的案例

《Python中使用正则表达式精准匹配IP地址的案例》Python的正则表达式(re模块)是完成这个任务的利器,但你知道怎么写才能准确匹配各种合法的IP地址吗,今天我们就来详细探讨这个问题,感兴趣的朋... 目录为什么需要IP正则表达式?IP地址的基本结构基础正则表达式写法精确匹配0-255的数字验证IP地

使用Python实现全能手机虚拟键盘的示例代码

《使用Python实现全能手机虚拟键盘的示例代码》在数字化办公时代,你是否遇到过这样的场景:会议室投影电脑突然键盘失灵、躺在沙发上想远程控制书房电脑、或者需要给长辈远程协助操作?今天我要分享的Pyth... 目录一、项目概述:不止于键盘的远程控制方案1.1 创新价值1.2 技术栈全景二、需求实现步骤一、需求

Spring LDAP目录服务的使用示例

《SpringLDAP目录服务的使用示例》本文主要介绍了SpringLDAP目录服务的使用示例... 目录引言一、Spring LDAP基础二、LdapTemplate详解三、LDAP对象映射四、基本LDAP操作4.1 查询操作4.2 添加操作4.3 修改操作4.4 删除操作五、认证与授权六、高级特性与最佳