姿态识别论文复现(一)安装包+下载数据

Lite-HRNet:轻量级高分辨率网络

简介:高分辨率网络Lite-HRNet,用于人体姿态估计

环境配置:该代码是在 Ubuntu 16.04 上使用 python 3.6 开发的。需要 NVIDIA GPU。使用 8 个 NVIDIA V100 GPU 卡进行开发和测试。其他平台或 GPU 卡尚未经过全面测试。

论文:https://openaccess.thecvf.com/content/CVPR2021/papers/Yu_Lite-HRNet_A_Lightweight_High-Resolution_Network_CVPR_2021_paper.pdf

代码:https://github.com/HRNet/Lite-HRNet.

【我用的是autodl云服务器】

1、安装包

pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu118/torch2.0.0/index.html

注意:cu118和torch2.0.0需要换成自己的cuda和torch版本,在linux终端中,查看自己的版本,这里看到是2.0.0+118,那么就把cu118/torch2.0.0改成自己的就好了:

>>> import torch
>>> print(torch.__version__)
2.0.0+cu118
>>> print(torch.version.cuda)
11.8
>>> print(torch.cuda.is_available())
True
>>> print(torch.cuda.device_count())
1

【安装mmcv报错记录】

按照上面指令下载的时候,warning提示:

WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead:https://pip.pypa.io/warnings/venv

提示:以root用户身份运行pip安装Python包可能导致权限问题和与系统包管理器的冲突行为。主要原因是pip在root权限下安装的包可能会覆盖系统级别的包,或者修改系统级别的Python环境,这可能不是预期的行为,并且可能破坏系统的稳定性和安全性。

为了避免这些问题,建议采取以下措施:使用虚拟环境(Virtual Environment)

python3 -m venv .net

代表在当前的目录下,创建了一个.net的虚拟环境

然后激活虚拟环境:

source .net/bin/activate

激活后,命令行提示符前会出现虚拟环境的名字(.net)

然后,继续下载:

pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu118/torch2.0.0/index.html

这时候,又出现提示,让我更新pip,的提示,按照提示把pip更新了。

到这里,查看mmcv-full有没有下载成功,输入命令:pip show mmcv-full

出现了版本号,说明,mmcv-full安装成功。

2、pip install -r requirements.txt

出现报错:

解决措施:进行更新

python3 m pip install-upgrade pip setuptools wheel

然后就一直下载了,注意把代理打开。

如果直到最后,出现提示:不影响运行。其他都是正常下载的。

标题

2、准备数据集

论文:“For COCO data, please download from COCO download, 2017 Train/Val is needed for COCO keypoints training and validation.”

数据集来源:数据集来自COCO2017的数据集,train和val数据集。

现在,从autodl直接下载coco数据集。

创建data数据文件夹,把数据下载在这里面,分别下载train,和val数据集的zip

wget http://images.cocodataset.org/zips/train2017.zip

wget http://images.cocodataset.org/zips/val2017.zip

下载注释

wget http://images.cocodataset.org/annotations/annotations_trainval2017.zip

等待下载。。。

巨慢

  • 36
    点赞
  • 28
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
以下是使用PyTorch复现PointNet的基本步骤: 1. 导入必要的库 ```python import torch import torch.nn as nn import torch.nn.functional as F ``` 2. 定义PointNet的基本操作 ```python class TNet(nn.Module): def __init__(self, k=3): super(TNet, self).__init__() self.conv1 = nn.Conv1d(k, 64, 1) self.conv2 = nn.Conv1d(64, 128, 1) self.conv3 = nn.Conv1d(128, 1024, 1) self.fc1 = nn.Linear(1024, 512) self.fc2 = nn.Linear(512, 256) self.fc3 = nn.Linear(256, k*k) def forward(self, x): batch_size = x.size(0) x = F.relu(self.conv1(x)) x = F.relu(self.conv2(x)) x = F.relu(self.conv3(x)) x = torch.max(x, 2, keepdim=True)[0] x = x.view(-1, 1024) x = F.relu(self.fc1(x)) x = F.relu(self.fc2(x)) x = self.fc3(x) iden = torch.eye(x.size(1)).view(1, x.size(1)*x.size(1)).repeat(batch_size,1) if x.is_cuda: iden = iden.cuda() x = x + iden x = x.view(-1, x.size(1), x.size(1)) return x ``` 3. 定义PointNet的分类模型 ```python class PointNetCls(nn.Module): def __init__(self, k=2): super(PointNetCls, self).__init__() self.tnet1 = TNet(k=3) self.conv1 = nn.Conv1d(3, 64, 1) self.conv2 = nn.Conv1d(64, 64, 1) self.tnet2 = TNet(k=64) self.conv3 = nn.Conv1d(64, 128, 1) self.conv4 = nn.Conv1d(128, 1024, 1) self.fc1 = nn.Linear(1024, 512) self.fc2 = nn.Linear(512, 256) self.fc3 = nn.Linear(256, k) def forward(self, x): batch_size = x.size(0) x = self.tnet1(x) x = torch.bmm(x, x.transpose(2,1)) x = x.unsqueeze(1) x = F.relu(self.conv1(x)) x = F.relu(self.conv2(x)) x = torch.max(x, 2, keepdim=True)[0] x = x.repeat(1, 1, 1024) x = torch.cat([x, self.tnet2(x)], 1) x = F.relu(self.conv3(x)) x = self.conv4(x) x = torch.max(x, 2, keepdim=True)[0] x = x.view(-1, 1024) x = F.relu(self.fc1(x)) x = F.relu(self.fc2(x)) x = self.fc3(x) return F.log_softmax(x, dim=1) ``` 4. 定义损失函数和优化器 ```python model = PointNetCls() criterion = nn.NLLLoss() optimizer = torch.optim.Adam(model.parameters(), lr=0.001) ``` 5. 进行训练 ```python for epoch in range(50): running_loss = 0.0 for i, data in enumerate(trainloader, 0): inputs, labels = data optimizer.zero_grad() outputs = model(inputs) loss = criterion(outputs, labels) loss.backward() optimizer.step() running_loss += loss.item() print('Epoch %d loss: %.3f' %(epoch+1, running_loss/len(trainloader))) ``` 6. 进行测试 ```python correct = 0 total = 0 with torch.no_grad(): for data in testloader: inputs, labels = data outputs = model(inputs) _, predicted = torch.max(outputs.data, 1) total += labels.size(0) correct += (predicted == labels).sum().item() print('Accuracy: %.2f %%' % (100 * correct / total)) ``` 这就是使用PyTorch复现PointNet的基本步骤。可以根据需要进行调整和改进,以获得更好的性能。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值