尽管在目录中,但找不到模块/文件夹



我运行Yolov5+StrongSort和Yolov7+StrongSort跟踪,它们有结构:

> yolov5
> yolov7
> strongsort
main.py

我将它们与main.py中的代码连接起来,如下所示:

FILE = Path(__file__).resolve()
ROOT = FILE.parents[0]  # yolov5 strongsort root directory
WEIGHTS = ROOT / 'weights'
if str(ROOT) not in sys.path:
sys.path.append(str(ROOT))  # add ROOT to PATH
if str(ROOT / 'yolov5') not in sys.path:
sys.path.append(str(ROOT / 'yolov5'))  # add yolov7 ROOT to PATH
if str(ROOT / 'yolov7') not in sys.path:
sys.path.append(str(ROOT / 'yolov7'))  # add yolov7 ROOT to PATH
if str(ROOT / 'strong_sort') not in sys.path:
sys.path.append(str(ROOT / 'strong_sort'))  # add strong_sort ROOT to PATH
ROOT = Path(os.path.relpath(ROOT, Path.cwd()))  # relative

代码我从2链接github:https://github.com/mikel-brostrom/Yolov5_StrongSORT_OSNet,https://github.com/mikel-brostrom/Yolov7_StrongSORT_OSNet.当我从yolov7这样的模型:

model = attempt_load('model/yolov7.pt', map_location=torch.device('cpu'))
print(model)

他们有错误CCD_ 1。我知道他们在yolov5中使用了attempt_load,而没有使用yolov7。请帮我解决这个问题

Yolov7型号由加载

https://github.com/mikel-brostrom/yolov7/blob/60978d6acd409cb8089d44813659ced59d41aa96/models/experimental.py#L237

Yolov5由加载

https://github.com/ultralytics/yolov5/blob/91a81d48fa4e34dbdbaf0e45a1f841c11216aab5/models/experimental.py#L73

这意味着两个attempt_load是不同的。Yolov5不能用于加载Yolov7,反之亦然。

相关内容

  • 没有找到相关文章

最新更新