keras-yolo3 icon indicating copy to clipboard operation
keras-yolo3 copied to clipboard

TypeError: unicode argument expected, got 'str'

Open hejie opened this issue 6 years ago • 7 comments

Using TensorFlow backend. Loading weights. ('Weights Header: ', 0, 2, 0, array([32013312])) Parsing Darknet config. Traceback (most recent call last): File "convert.py", line 262, in _main(parser.parse_args()) File "convert.py", line 83, in _main unique_config_file = unique_config_sections(config_path) File "convert.py", line 53, in unique_config_sections output_stream.write(line) TypeError: unicode argument expected, got 'str'

hejie avatar Jul 04 '18 06:07 hejie

@hejie the test environment is Python 3.5.2, I guess your environment is Python2.7.

subicWang avatar Jul 04 '18 08:07 subicWang

if your environment is Python2.7, you can change code : line 10 import io and line 47 output_stream·=io.StringIO()

to line 10 from io import BytesIO as StringIO line 47 output_stream·= StringIO()

zhoul14 avatar Jul 04 '18 12:07 zhoul14

@zhoul14 worked for me, thanks!

sgarcia22 avatar Jul 12 '18 16:07 sgarcia22

@zhoul14 Thanks for the solution.

sunilrebel avatar Jan 08 '19 06:01 sunilrebel

@hejie the test environment is Python 3.5.2, I guess your environment is Python2.7.

Make sure you use python3

If you need both python2 and python2 support you can/should opt for six.StringIO

import six

six.StringIO()

kerrermanisNL avatar Mar 01 '21 09:03 kerrermanisNL

if your environment is Python2.7, you can change code : line 10 import io and line 47 output_stream·=io.StringIO()

to line 10 from io import BytesIO as StringIO line 47 output_stream·= StringIO()

I used this tip to solve a problem in the plugin to generate migrations for laravel in MySQL Workbench.

Thank you very much!

leonardodevbr avatar Feb 24 '22 21:02 leonardodevbr