运行DeepSORT_YOLOv5_Pytorch时出现的问题


前言

记录一下复现GitHub中以下这份代码时出现的一些问题。
代码链接:https://github.com/HowieMa/DeepSORT_YOLOv5_Pytorch/tree/master

问题1:Loader=yaml.FullLoader

【问题描述】

self.update(yaml.load(fo.read()))
TypeError: load() missing 1 required positional argument: 'Loader'

【解决方式】
找到deep_sort文件夹下的utils文件夹中的parser.py文件,将两处 cfg_dict.update(yaml.load(fo.read())) 改为 cfg_dict.update(yaml.load(fo, Loader=yaml.FullLoader))

在这里插入图片描述


问题2:utils. -> yolov5.utils.

【问题描述】

from utils.general import check_anchor_order, make_divisible, check_file
ModuleNotFoundError: No module named 'utils.general'

from utils.torch_utils import (
    time_synchronized, fuse_conv_and_bn, model_info, scale_img, initialize_weights, select_device)
ModuleNotFoundError: No module named 'utils.torch_utils'

【解决方式】
找到yolov5文件夹下的models文件夹中的yolo.py文件,将

from utils.general import check_anchor_order, make_divisible, check_file
from utils.torch_utils import (
    time_synchronized, fuse_conv_and_bn, model_info, scale_img, initialize_weights, select_device)

改为

from yolov5.utils.general import check_anchor_order, make_divisible, check_file
from yolov5.utils.torch_utils import (
    time_synchronized, fuse_conv_and_bn, model_info, scale_img, initialize_weights, select_device)

问题3:np.float -> float

【问题描述】

<class 'AttributeError'> module 'numpy' has no attribute 'float'.
`np.float` was a deprecated alias for the builtin `float`. To avoid this error in existing code, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.

【解决方式】
找到deep_sort文件夹下的sort文件夹中的detection.py文件和preprocessing.py文件,分别将30行代码和第40行代码中的np.float改为float


问题4:np.int -> int

【问题描述】

<class 'AttributeError'> module 'numpy' has no attribute 'int'.
`np.int` was a deprecated alias for the builtin `int`. To avoid this error in existing code, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` 

【解决方式】
找到deep_sort文件夹下的deep_sort.py文件,将第67行代码中的np.int 改为int


问题5:ImportError: cannot import name ‘time_synchronized’ from ‘yolov5.utils.torch_utils’

【问题描述】

from yolov5.utils.torch_utils import select_device, time_synchronized
ImportError: cannot import name 'time_synchronized' from 'yolov5.utils.torch_utils' 

【解决方式】
main.py中的

from yolov5.utils.torch_utils import select_device, time_synchronized

改为

from yolov5.utils.torch_utils import select_device, time_sync

time_synchronized()改为time_sync()
在这里插入图片描述


最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-05-01 05:46:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-05-01 05:46:02       100 阅读
  3. 在Django里面运行非项目文件

    2024-05-01 05:46:02       82 阅读
  4. Python语言-面向对象

    2024-05-01 05:46:02       91 阅读

热门阅读

  1. 安信天行-渗透测试实习生

    2024-05-01 05:46:02       30 阅读
  2. make构建自动化工具介绍

    2024-05-01 05:46:02       22 阅读
  3. redis工具类

    2024-05-01 05:46:02       21 阅读
  4. python-基础(7)-判断结构

    2024-05-01 05:46:02       33 阅读
  5. QT学习之QFileDialog

    2024-05-01 05:46:02       31 阅读
  6. FlaUI

    FlaUI

    2024-05-01 05:46:02      33 阅读
  7. Axios 库相关

    2024-05-01 05:46:02       33 阅读