patlevin / tfjs-to-tf

A TensorFlow.js Graph Model Converter
MIT License
138 stars 18 forks source link

utf-8 #29

Open jan-grzybek-ampere opened 3 years ago

jan-grzybek-ampere commented 3 years ago

I'm getting Converting.... Error: utf-8 when converting posenet network. Any hints on how I can fix this?

patlevin commented 3 years ago

This seems to be an issue with the downloaded model json.

Can you try and open the model.json (or model-strideXX.json) in a text editor and confirm that it's actually a text file?

Problems like this can happen if the browser or download tool receives compressed files, but doesn't decompress them.

khg2478 commented 3 years ago

@patlevin Hello. I am facing the same issue. I have downloaded a model json file (blazepose) and tried conversion through your repository but couldn't due to utf-8 error. I checked the file and it indeed stores text. Any suggestions for conversion from those downloaded files?

patlevin commented 3 years ago

@khg2478 If the model files are OK, the only other reason might be the Python installation itself. Ever since version 3.0, the default encoding for Python source code is utf-8 but for some reason there are still Python installations that still expect ASCII source files.

Could you test real quick whether the following snippet also generates an error with your Python interpreter? Copy the snippet into a text editor and save the file with utf-8 encoding, e.g. as test.py. Then run python test.py.

import math

if __name__ == '__main__':
    r = int(input("Enter the radius of the sphere: "))
    # The area of a sphere is 4πr² ← your interpreter might choke on this part
    area = 4 * math.pi * (r**2)
    print(f"The area of the sphere is {area:.2f}")

If this results in the same error, your Python interpreter expects ASCII source files for some odd reason.