HowieMa/DeepSORT_YOLOv5_Pytorch

TypeError: load() missing 1 required positional argument: 'Loader'

Opened this issue · 11 comments

TypeError: load() missing 1 required positional argument: 'Loader'

请问您这个问题解决了吗?

I am getting the same error as well.

After installing all the libraries in requirement.txt of yolov5 and deepsort, we run the command
python main.py --cam 0

and get the error as:

Traceback (most recent call last):
File "D:/Projects/yolov5-deepsort/DeepSORT_YOLOv5_Pytorch/main.py", line 259, in
with VideoTracker(args) as vdo_trk:
File "D:/Projects/yolov5-deepsort/DeepSORT_YOLOv5_Pytorch/main.py", line 53, in init
cfg.merge_from_file(args.config_deepsort)
File "D:\Projects\yolov5-deepsort\DeepSORT_YOLOv5_Pytorch\utils_ds\parser.py", line 23, in merge_from_f
self.update(yaml.load(fo.read()))
TypeError: load() missing 1 required positional argument: 'Loader'
Namespace(agnostic_nms=False, augment=False, cam=-1, classes=[0], conf_thres=0.5, config_deepsort='./configs/deep_sort.yaml', device='', display=False, display_height=600, display_width=800, fourcc='mp4v', frame_interval=2, img_size=640, input_path='input_480.mp4', iou_thres=0.5, save_path='output/', save_txt='output/predict/', weights='yolov5/weights/yolov5s.pt')

Initialize DeepSORT & YOLO-V5
Using CPU.

Please help.

In the file parser.py in line 34,

if name == "main":
cfg = YamlParser(config_file="../configs/yolov3.yaml")
cfg.merge_from_file("../configs/deep_sort.yaml")

import ipdb; ipdb.set_trace()

We are creating a cfg object by passing yolov3.yaml in the configs directory. This file is absent in the configs directory. Moreover, we are using yolov5 here. I guess this could be the error here. Will passing the yolov5 yaml file correct this error?

Still getting the same error. Please help.

Still getting the same error. Please help.

hi, i find a method to solve this. as stack-overflow, you can just change load() to safe_load() in ./ultils_ds/paser.py line23. OR !pip install pyyaml==5.4.1.
but other errors still occurs for some module not found, i think maybe requirements.txt need to be updated. i am try to find a Docker image which could run this repo or build one now.

Replace with this code
def merge_from_file(self, config_file): with open(config_file, 'r') as fo: self.update(yaml.load(fo.read(), Loader=yaml.FullLoader))

File "/root/miniconda3/envs/py38/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/root/MOT/DeepSORT_YOLOv5_Pytorch/yolov5/models/yolo.py", line 109, in forward
return self.forward_once(x, profile) # single-scale inference, train
File "/root/MOT/DeepSORT_YOLOv5_Pytorch/yolov5/models/yolo.py", line 129, in forward_once
x = m(x) # run
File "/root/miniconda3/envs/py38/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/root/miniconda3/envs/py38/lib/python3.8/site-packages/torch/nn/modules/upsampling.py", line 157, in forward
recompute_scale_factor=self.recompute_scale_factor)
File "/root/miniconda3/envs/py38/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1614, in getattr
raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'Upsample' object has no attribute 'recompute_scale_factor'

After modifying the parser, there is still error msg

zzzbut commented

请在后面加入这个,这是因为yaml文件的加载函数已经更新了。yaml.load(file,Loader=yaml.FullLoader)

replace yaml.load with yaml.safe_load