mmskeletonwindows安装(mmdetection)及ST-GCN测试和训练
⾸先安装mmdetection:
OS: Win10
VS: 2015
mmdetection: 1.1.0
mmcv:0.6.0智能训练
torch=1.3.1
torchvision=0.4.2
python:3.7.9
cuda:10.1
查看cuda版本:nvcc -V
⼀、Pytorch环境安装
创建虚拟环境:
conda create -n mmd python=3.7
conda activate mmd
conda install pytorch=1.3 torchvision cudatoolkit=10.1 -c pytorch
pip install cython opencv-python pillow matplotlib
环境⽬录是指刚刚创建的mm2虚拟环境位置。
修改 环境⽬录下\Lib\site-packages\torch\include\c10\util\flat_hash_map.h
1> 删掉 #include <stdexcept>
2> 1379-1398⾏左右,注释或删掉:
// std::pair<typename Table::iterator, bool> emplace()
// {
// return emplace(key_type(), convertible_to_value());
// }
// template<typename M>
// std::pair<typename Table::iterator, bool> insert_or_assign(const key_type & key, M && m)
// {
// auto emplace_result = emplace(key, std::forward<M>(m));
// if(!emplace_result.second)
// emplace_result.first->second = std::forward<M>(m);
/
/ return emplace_result;
// }
// template<typename M>
// std::pair<typename Table::iterator, bool> insert_or_assign(key_type && key, M && m)
// {
// auto emplace_result = emplace(std::move(key), std::forward<M>(m));
// if(!emplace_result.second)
// emplace_result.first->second = std::forward<M>(m);
// return emplace_result;
// }
1473-1493⾏左右,注释或删掉
/
/ }
// std::pair<typename Table::iterator, bool> emplace(const key_type & arg)
// {smdv-17
// return Table::emplace(arg);
// }
// std::pair<typename Table::iterator, bool> emplace(key_type & arg)
// {
// return Table::emplace(arg);
// }
// std::pair<typename Table::iterator, bool> emplace(const key_type && arg)
// {
/
/ return Table::emplace(std::move(arg));
// }
// std::pair<typename Table::iterator, bool> emplace(key_type && arg)
// {
// return Table::emplace(std::move(arg));
// }
2.修改 环境⽬录下\Lib\site-packages\torch\include\c10\util\order_preserving_flat_hash_map.h 注释或删除1499-1518⾏
// std::pair<typename Table::iterator, bool> emplace()
// {
// return emplace(key_type(), convertible_to_value());
// }
// template<typename M>
tm2005// std::pair<typename Table::iterator, bool> insert_or_assign(const key_type & key, M && m)
// {
// auto emplace_result = emplace(key, std::forward<M>(m));
// if(!emplace_result.second)
// emplace_result.first->second = std::forward<M>(m);
// return emplace_result;
// }
// template<typename M>
// std::pair<typename Table::iterator, bool> insert_or_assign(key_type && key, M && m)
// {
/
/ auto emplace_result = emplace(std::move(key), std::forward<M>(m));
// if(!emplace_result.second)
// emplace_result.first->second = std::forward<M>(m);
拉丝模激光打孔机// return emplace_result;
// }
注释或删除1593-1613⾏
// }
// std::pair<typename Table::iterator, bool> emplace(const key_type & arg)
// {
// return Table::emplace(arg);
// }
/
/ std::pair<typename Table::iterator, bool> emplace(key_type & arg)
// {
// return Table::emplace(arg);
// }
// std::pair<typename Table::iterator, bool> emplace(const key_type && arg)
// {
// return Table::emplace(std::move(arg));
// }
// std::pair<typename Table::iterator, bool> emplace(key_type && arg)
高精度室内定位// {
// return Table::emplace(std::move(arg));
/
/ }
3.修改 环境⽬录下\Lib\site-packages\torch\utils\cpp_extension.py
185⾏修改成:
match = re.search(r'(\d+)\.(\d+)\.(\d+)', compiler_info.decode("utf8","ignore").strip())
4.修改 环境⽬录下\Lib\site-packages\torch\include\torch\csrc\jit\argument_spec.h 190⾏左右修改:
将 static conststr size_t DEPTH_LIMIT = 128;
替换成 static const size_t DEPTH_LIMIT = 128;
5.修改 环境⽬录下\Lib\site-packages\torch\include\pybind11\cast.h
1448⾏左右
将 explicit operator type&() { return *(this->value); }
python setup.py build_ext --inplace
python setup.py build_ext install
三、mmdeteciton安装
利⽤pip install mmcv==1.1.5
安装完成后,⼿动去
环境⽬录下\Lib\site-packages\mmcv\utils到config.py⽂件
在100⾏左右新加:temp_config_file.close()
修改后如下所⽰:
with tempfile.TemporaryDirectory()as temp_config_dir:
temp_config_file = tempfile.NamedTemporaryFile(
dir=temp_config_dir, suffix='.py')
# 新加的
temp_config_file.close()
temp_config_name = osp.basename(temp_config_file.name)
osp.join(temp_config_dir, temp_config_name))
temp_module_name = osp.splitext(temp_config_name)[0]
sys.path.insert(0, temp_config_dir)
Config._validate_py_syntax(filename)
mod = import_module(temp_module_name)
pip install -煤矿井下用绞车
修改setup.py⽂件中CUDAExtension中extra_compile_args相关代码,增加cxx的"-DMS_WIN64","-MD" python setup.py develop pip install -
python setup.py develop (或者 python setup.py install)
四、安装mmskeleton:
python setup.py develop
with open('README.rst', encoding='utf-8') as infile:
readme = ad()
保存。 打开prompt 进⼊解压路径
执⾏“python setup.py install”进⾏安装即可。
问题⼆: No module named 's.cpu_nms’
解决⽅法:暴⼒解决(主要其他⽅法⾏不通)
修改s下的nms.py⽂件
注释13,14⾏,增加cpu_nms函数:
def cpu_nms(dets, thresh):
x1 = dets[:,0]
y1 = dets[:,1]
x2 = dets[:,2]
y2 = dets[:,3]
areas =(y2-y1+1)*(x2-x1+1)
scores = dets[:,4]
keep =[]
index = scores.argsort()[::-1]
while index.size >0:
i = index[0]# every time the first is the biggst, and add it directly
keep.append(i)
x11 = np.maximum(x1[i], x1[index[1:]])# calculate the points of overlap y11 = np.maximum(y1[i], y1[index[1:]])
x22 = np.minimum(x2[i], x2[index[1:]])
y22 = np.minimum(y2[i], y2[index[1:]])
w = np.maximum(0, x22-x11+1)# the weights of overlap
h = np.maximum(0, y22-y11+1)# the height of overlap
overlaps = w*h
ious = overlaps /(areas[i]+areas[index[1:]]- overlaps)
idx = np.where(ious<=thresh)[0]
index = index[idx+1]# because index start from 1
return keep
修改后的nms.py⽂件内容如下: