pytracking网址:https://github.com/visionml/pytrackingpytracking
强烈推荐这个视频
最大的难点在于这个视频cuda是用cuda10+pytorch1.2.0,cuda10+pytorch1.2.0的朋友看这个视频就完事了,应该没啥问题。
本人用的是3090显卡,不能用cuda10,用的是cuda11.3+pytroch1.10
安装命令:conda install pytorch1.10.0 torchvision0.11.0 torchaudio==0.10.0 cudatoolkit=11.3 -c pytorch -c conda-forge
不推荐用命令conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch,我用之后pytorch格式和cuda11.3对不上。。
pytorch对应版本
除了pytorch,其他安装包按照install.sh一个个按就完事。
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
我遇到的问题
1.首先是otb数据集文件的问题,前面推荐的视频里面说了,自己debug也能解决。
2.local自己填上otb等数据集的存放位置
python -c "from pytracking.evaluation.environment import create_default_local_file; create_default_local_file()"
python -c "from ltr.admin.environment import create_default_local_file; create_default_local_file()"
创建用于配置路径的两个local.py
3.下载模型,模型地址
4./home/ubuntu/wl/pytracking/ltr/external/PreciseRoIPoolinggit里面没东西的要运行命令: submodule update --init
正常的PreciseRoIPoolinggit:
5.报错AttributeError: module ‘torch‘ has no attribute ‘irfft‘
报错原因 : toch.rfft和torch.ifft这个函数在pytorch-1.8被移除
解决:在/home/ubuntu/wl/pytracking/pytracking/libs/fourier.py中开头添加
from torch.fft import irfft2
from torch.fft import rfft2
def rfft(x, d):
t = rfft2(x, dim = (-d,-1))
return torch.stack((t.real, t.imag), -1)
def irfft(x, d, signal_sizes):
return irfft2(torch.complex(x[:,:,0], x[:,:,1]), s = signal_sizes, dim = (-d,-1))
然后把文件中出现的torch.rfft和torch.irfft改成rfft和irfft
这样改完之后运行atom会出现预测框不动的现象,但运行dimp和tomp正常。
6. rect = patches.Rectangle((box[0], box[1]), box[2], box[3], linewidth=1, edgecolor=col, facecolor=‘none’)出错,box和boxes格式总是对不上,原因不知道,但tomp和dimp没用到这个函数,所以没影响,只有atom用到了visual…
解决办法:/home/ubuntu/wl/pytracking/pytracking/evaluation/tracker.py640行改为以下:
def visualize(self, image, state, segmentation=None):
self.ax.cla()
self.ax.imshow(image)
if segmentation is not None:
self.ax.imshow(segmentation, alpha=0.5)
if isinstance(state, (OrderedDict, dict)):
boxes = [v for k, v in state.items()]
elif isinstance(state, list):
boxes = state
else:
boxes = (state,)
box = boxes
if len(box) == 1:
box = boxes[0]
col = _tracker_disp_colors[1]
col = [float(c) / 255.0 for c in col]
rect = patches.Rectangle((box[0], box[1]), box[2], box[3], linewidth=1, edgecolor=col, facecolor='none')
self.ax.add_patch(rect)
7.安装环境应该先对应最近的cuda版本,如自己的30系显卡,只能按cuda11.+,自己是11.3,所以pytorch要对应11.3
安装对应的pytorch,再解决出现的问题。
运行结果:
Evaluating 1 trackers on 1 sequences
Tracker: dimp dimp50 None , Sequence: Soccer
Setting up a new session...
/home/ubuntu/miniconda3/envs/pytracking1/lib/python3.7/site-packages/torch/nn/functional.py:3635: UserWarning: Default upsampling behavior when mode=bilinear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details.
"See the documentation of nn.Upsample for details.".format(mode)
Using /home/ubuntu/.cache/torch_extensions/py37_cu113 as PyTorch extensions root...
Detected CUDA files, patching ldflags
Emitting ninja build file /home/ubuntu/.cache/torch_extensions/py37_cu113/_prroi_pooling/build.ninja...
Building extension module _prroi_pooling...
Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
ninja: no work to do.
Loading extension module _prroi_pooling...
/home/ubuntu/miniconda3/envs/pytracking1/lib/python3.7/site-packages/torch/nn/functional.py:3635: UserWarning: Default upsampling behavior when mode=bilinear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details.
"See the documentation of nn.Upsample for details.".format(mode)
Visdom failed to handle a handler for {'target': 'block_list', 'eid': 'main', 'event_type': 'Click', 'image_coord': {'x': 3, 'y': 69, 'visibility': 'hidden'}, 'pane_data': {'command': 'window', 'id': 'block_list', 'title': 'Block List', 'inflate': True, 'width': None, 'height': None, 'contentID': '822e549d-772f-4463-b00a-0eafdd43c7e2', 'content': [{'type': 'checkbox', 'name': 'Help', 'value': True}, {'type': 'checkbox', 'name': 'Training Loss', 'value': False}, {'type': 'checkbox', 'name': 'Score Map', 'value': False}, {'type': 'checkbox', 'name': 'Status', 'value': True}], 'type': 'properties', 'i': 0}}: 'propertyId'
Traceback (most recent call last):
File "/home/ubuntu/miniconda3/envs/pytracking1/lib/python3.7/site-packages/visdom/__init__.py", line 634, in on_message
handler(message)
File "/home/ubuntu/wl/pytracking/pytracking/../pytracking/utils/visdom.py", line 390, in block_list_callback_handler
field_name = self.blocks_list[data['propertyId']]['name']
KeyError: 'propertyId'
FPS: 33.407621186015774
Done
用visdom就能看了python -m visdom.server
查看显存占比watch -n 2 -d nvidia-smi
其他:
E.T.track没有训练代码,环境用transt的环境就行:torch1.5.1,和我的cuda11.3没有对应上,但也能正常运行。
用E.T.track中的pytracking运行atom或者其他的运行不了,应该还是版本不对。。
pytracking最主要的问题还是这个报错:RuntimeError: Error building extension ‘_prroi_pooling’
其实还是pytorch的版本问题,cuda11.0可能没办法编译PreciseRolPooling,我的11.3是可以正常编译的。
或者看看些文章:
https://blog.csdn.net/laizi_laizi/article/details/124458464?spm=1001.2014.3001.5501
https://blog.csdn.net/qqsuiying/article/details/121593987