如何将 YOLOv4-CSP 暗网权重转换为 Tensorflow 格式? [英] How to convert YOLOv4-CSP darknet weight to Tensorflow format?

查看:154
本文介绍了如何将 YOLOv4-CSP 暗网权重转换为 Tensorflow 格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将 YOLOv4-CSP 暗网权重转换为 Tensorflow (tf) 格式?

我尝试过使用这个 repo,但没有用.>

我收到此错误消息:

回溯(最近一次调用最后一次):文件save_model.py",第 58 行,在 <module> 中.应用程序运行(主)文件C:\Python37\lib\site-packages\absl\app.py",第 303 行,运行中_run_main(main, args)文件C:\Python37\lib\site-packages\absl\app.py",第 251 行,在 _run_main 中sys.exit(main(argv))文件save_model.py",第 54 行,在主目录中save_tf()文件save_model.py",第 49 行,在 save_tf 中utils.load_weights(model, FLAGS.weights, FLAGS.model, FLAGS.tiny)文件D:\swap\20210319\tensorflow-yolov4-tflite\core\utils.py",第63行,load_weightsconv_weights = conv_weights.reshape(conv_shape).transpose([2, 3, 1, 0])ValueError:无法将大小为 3791890 的数组重塑为形状 (1024,512,3,3)

解决方案

您使用的存储库尚不支持 Scaled YoloV4 或 Yolov4-csp 的转换.根据this issue

,它仍然是一个功能请求

幸运的是有一个解决方法.我发现 this 存储库做同样的事情,唯一的区别是它转换在转换为 tensorflow 格式之前将模型转换为 .h5(keras 格式).这也支持yolov4-csp.

我制作了一个用于转换的 Google Colab 笔记本,可以在 这里.

How to convert YOLOv4-CSP darknet weights to Tensorflow (tf) format?

I have tried using this repo but it didn't work.

I had this error message:

Traceback (most recent call last):
  File "save_model.py", line 58, in <module>
    app.run(main)
  File "C:\Python37\lib\site-packages\absl\app.py", line 303, in run
    _run_main(main, args)
  File "C:\Python37\lib\site-packages\absl\app.py", line 251, in _run_main
    sys.exit(main(argv))
  File "save_model.py", line 54, in main
    save_tf()
  File "save_model.py", line 49, in save_tf
    utils.load_weights(model, FLAGS.weights, FLAGS.model, FLAGS.tiny)
  File "D:\swap\20210319\tensorflow-yolov4-tflite\core\utils.py", line 63, in load_weights
    conv_weights = conv_weights.reshape(conv_shape).transpose([2, 3, 1, 0])
ValueError: cannot reshape array of size 3791890 into shape (1024,512,3,3)

解决方案

The repository that you are using doesn't support conversion of Scaled YoloV4 or Yolov4-csp yet. It's still a feature request according to this issue

There's luckily a workaround. I found this repository that does the same thing, only difference being it converts the model to .h5 (keras format) before converting into tensorflow format. This also supports yolov4-csp.

I made a Google Colab notebook that does the conversion, which can be found here.

这篇关于如何将 YOLOv4-CSP 暗网权重转换为 Tensorflow 格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆