allanzelener / YAD2K

YAD2K: Yet Another Darknet 2 Keras
Other
2.71k stars 877 forks source link

Convert .h5 to .weights #55

Closed Ahziel closed 7 years ago

Ahziel commented 7 years ago

Hi,

I was wondering how to convert the .h5 file of Keras to the .weights file used by Darknet. If I undertsand, the .h5 file created with YAD2K is the entire model. I find on Keras documentation that you can save only the weight of this model, but the data of this .h5 is not the same as the data in the .weight file.

What transformations I have to do to convert this file into .weight ?

Thank you for your attention and your help!

Firyuza commented 7 years ago

https://github.com/allanzelener/YAD2K/issues/52

Firyuza commented 7 years ago

I this issue you can find how to convert .weight to .h5 extension. Just using the yad2k command in terminal.

Ahziel commented 7 years ago

Thank's for your answer but, I don't want to convert .weights to .h5 but .h5 to .weights

Firyuza commented 7 years ago

Oh, didn't understand clearly. Maybe look into script that convert to .h5 and find the way how to do vice versa.

Ahziel commented 7 years ago

The real problem is that I don't know how are organize the information of the .weights file and the .h5 file, what information is in it. Maybe there is an easy way to find this information but I'm kind of a newbie (I'm totally a newbie...) in deep learning and this type of thing. On top of that when I whatch the code I don't understand a lot.

Ahziel commented 7 years ago

I solved the problem, I just reversed the process of yad2k.py. Now, it worked, thanks for your time !

demcoderseinnachbar commented 6 years ago

Would yu mind to share the result?

alice17 commented 6 years ago

@Ahziel Could you please share the code?

Ahziel commented 6 years ago

Hi,

It's been a long time since I've done deep learning and I don't have the YOLO code anymore and I don't remember how was my code. Thus I can't help you with your problems. I hope you'll excuse me, I'm really sorry and I hope you'll succeed in your projects.

With kind regards

saivineethkumar commented 6 years ago

Hi @alice17 @demcoderseinnachbar Did u guys find the code for converting .h5 to .weight file? If yes, can u share the code! thanks

shuli163love commented 6 years ago

@saivineethkumar

Hi. I have the save issue. If you find a way to convert .h5 to .weihts, please share the code. Thanks! My email is lishuli@ruijie.com.cn

sevenseablue commented 5 years ago

@shuli163love Hi. I have the save issue. If you find a way to convert .h5 to .weihts, can you share me. Thanks! My email is 178129482@qq.com

Caliber2 commented 5 years ago

Hey, did anybody find the solution? Sharing the solution would be appreciated.

Wintersara commented 4 years ago

Somebody solved it?

saminhasan commented 4 years ago

Same issue

Kenny-Snub-Nose-Monk commented 4 years ago

Here ~ But Chinese, I think you can translate it by Google~ I successfully deal with it by this website

https://www.cnblogs.com/shouhuxianjian/p/10567201.html

Kenny-Snub-Nose-Monk commented 4 years ago

Here ~ Another solution~

3. Convert the Darknet YOLO model to a Keras model:

https://github.com/YuXiuChen/Object-Detection-and-Tracking/blob/master/OneStage/yolo/deep_sort_yolov3/README.md or

https://github.com/YuXiuChen/Darknet-yolov3.cfg-and-yolov3.weights-transform-to-keras.h5/blob/master/README.md

chandanadittyo commented 4 years ago

@YuXiuChen Does it work for h5 to weight convert??

ywj55555 commented 4 years ago

Here ~ Another solution~

3. Convert the Darknet YOLO model to a Keras model:

https://github.com/YuXiuChen/Object-Detection-and-Tracking/blob/master/OneStage/yolo/deep_sort_yolov3/README.md or

https://github.com/YuXiuChen/Darknet-yolov3.cfg-and-yolov3.weights-transform-to-keras.h5/blob/master/README.md Hi,I used the second solution you provide,then it occur nameerror that my function is not defined,but I train the model noramlly. is there some bugs in the code?

ywj55555 commented 4 years ago

@YuXiuChen Does it work for h5 to weight convert??

When I run the second,it occurs nameerror that my function is not defined, but I train the model noramlly,I can't solve the bug. I think this code has some bugs for certain h5 files,it's not common for all h5 files.

ywj55555 commented 4 years ago

Does anyone have other ways?please

SauravRai commented 4 years ago

@YuXiuChen That is just the reverse of what is being asked. The question is to convert .h5 to .weights file and not the other way. Anyone who was able to do it, kindly share the code. I will do the same if I am able to do it. Thanks.