Keras-yolo3: python convert.py yolov3.cfg yolov3.weights model_data/yolo.h5

Created on 15 Apr 2018  Â·  5Comments  Â·  Source: qqwweee/keras-yolo3

when i run python convert.py yolov3.cfg yolov3.weights model_data/yolo.h5
i meet a problem
Using TensorFlow backend.
Loading weights.
('Weights Header: ', array([ 0, 2, 0, 32013312, 0], dtype=int32))
Parsing Darknet config.
Traceback (most recent call last):
File "convert.py", line 243, in
_main(parser.parse_args())
File "convert.py", line 75, in _main
unique_config_file = unique_config_sections(config_path)
File "convert.py", line 49, in unique_config_sections
output_stream.write(line)
TypeError: unicode argument expected, got 'str'
how should i do ?

Most helpful comment

Caused by the difference of coding between Python2 and Python3. If you are using Python2, maybe replacing io.StringIO() with io.BytesIO() works.

All 5 comments

Caused by the difference of coding between Python2 and Python3. If you are using Python2, maybe replacing io.StringIO() with io.BytesIO() works.

Hi @qqwweee ,I replaced io.StringIO() with io.BytesIO(), but got new error as follows:
Using TensorFlow backend.
Loading weights.
('Weights Header: ', array([ 0, 2, 0, 32013312, 0], dtype=int32))
Parsing Darknet config.
Traceback (most recent call last):
File "convert.py", line 237, in
_main(parser.parse_args())
File "convert.py", line 74, in _main
unique_config_file = unique_config_sections(config_path)
File "convert.py", line 48, in unique_config_sections
output_stream.write(line)
TypeError: descriptor 'write' requires a '_io.BytesIO' object but received a 'str'

@leepand I am afraid that you forgot '()' in 'output_stream=io.BytesIO()'.

@qqwweee, thanks for your quickly response,'()' was really forgotten. ha

You can see at here. I tried it and success.
https://github.com/phanxuanduc1996/convert_yolo_weights

Was this page helpful?
0 / 5 - 0 ratings