Skip to content
This repository has been archived by the owner on Mar 3, 2024. It is now read-only.

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

Open
hanifizzudinrahman opened this issue Oct 7, 2022 · 11 comments

Comments

@hanifizzudinrahman
Copy link

No description provided.

@Gt0812
Copy link

Gt0812 commented Nov 23, 2022

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

@sidb236
Copy link

sidb236 commented Dec 19, 2022

I am getting the same error as well.

@sidb236
Copy link

sidb236 commented Dec 19, 2022

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.

@sidb236
Copy link

sidb236 commented Dec 19, 2022

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?

@sidb236
Copy link

sidb236 commented Dec 19, 2022

Still getting the same error. Please help.

@Li-Jun-SD
Copy link

Li-Jun-SD commented Dec 22, 2022

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.

@pepequ
Copy link

pepequ commented Apr 25, 2023

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))

@Everloom-129
Copy link

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
Copy link

zzzbut commented Aug 22, 2023

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

@DwyaneYan
Copy link

@Everloom-129
https://blog.csdn.net/Thebest_jack/article/details/124723687

@zixuxu000
Copy link

replace yaml.load with yaml.safe_load

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants