https://codechina.csdn.net/mirrors/ifzhang/FairMOT
https://www.zhouchen1998.cn/2020/10/24/fairmot-realtime/
cannot import name ‘amp‘
原因:
1.只有PyTorch1.6版本以上才可以从torch.cuda中import amp;
解决措施:
https://blog.csdn.net/lucifer479/article/details/111322564
You can train FairMOT on custom dataset by following several steps bellow:
例如:
,,,,,,,<cat>,
其中,表示目标出现在哪一帧,
表示目标所属的tracklet ID。接下来的四个值表示目标边界框在二维帧坐标中的位置,由左上角坐标及边界框的宽度和高度表示。
表示目标的完整性是否需要被考虑(1)或忽略(0),本数据集默认所有已标注目标均需考虑,均为1。
表示目标的类别,即飞机(1)或舰船(2)。
表示目标的可视化程度,本数据集默认目标完全可视,均为1。
<class> /img_width> /img_height> /img_width> /img_height>
class :目标类别
id :目标id
x_center/img_width :归一化中心列坐标
y_center/img_height :归一化中心行坐标
w/img_width :归一化宽
h/img_height :归一化高
import os
import os.path as osp
image_flder = "/home/lyp/FairMOT-master/data/trainData" #数据集所在位置
imgs = os.listdir(image_flder)
#print(imgs)
train_f = open("/home/lyp/FairMOT-master/src/data/trainData.train", "w") #生成.train文件位置
for img_name in imgs:
image_path=osp.join(image_flder,img_name)
print(image_path[30:])
image_names=os.listdir(image_path)
image_names.sort()
print(image_names)
for image_name in image_names:
save_str = image_path[30:] + '/' + image_name +"\n" #修改imgae_path来控制显示的路径
print(save_str)
train_f.write(save_str)
train_f.close()
通过修改num_classes来指定训练的类别个数,要不然会报错
[1]IndexError: index 1 is out of bounds for axis 0 with size 1
[2]ValueError: not enough values to unpack (expected 2, got 1)
绿色箭头处是open(path, ‘r’) 我下载下来源码的是open(path, ‘rb’)导致一直报错
[1]TypeError: Can't mix strings and bytes in path components
[2]路径/b'xxxxxx.txt' not found.
RuntimeError: module must have its parameters and buffers on device cuda:2 (device_ids[0]) but found
Traceback (most recent call last):
File "demo.py", line 44, in
demo(opt)
File "demo.py", line 33, in demo
use_cuda=opt.gpus!=[-1])
File "FairMOT-master/src/track.py", line 90, in eval_seq
online_targets = tracker.update(blob, img0)
File "FairMOT-master/src/lib/tracker/multitracker.py", line 264, in update
id_feature = id_feature[remain_inds]
IndexError: boolean index did not match indexed array along dimension 0; dimension is 500 but corresponding boolean dimension is 420
应该是维度没有对上,我的数据集图片是19201080的,FairMOT数据集格式是1088608为输入的,但是训练时进入网络好像是会统一resize的
网上也有人说说FairMOT只支持单类别的多目标追踪
我目前还未解决这个多类别报错的问题
基于FairMOT训练多个数据集可以参考这个链接
https://github.com/CaptainEven/MCMOT