Created
February 27, 2020 23:55
-
-
Save petewarden/493294425ac522f00ff45342c71939d7 to your computer and use it in GitHub Desktop.
Example of converting a .cc TensorFlow Lite C data array file back into a binary flatbuffer on disk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
output_data = bytearray() | |
with open('tensorflow/tensorflow/lite/micro/examples/magic_wand/magic_wand_model_data.cc', 'r') as file: | |
for line in file: | |
values_match = re.match(r"\W*(0x[0-9a-fA-F,x ]+).*", line) | |
if values_match: | |
list_text = values_match.group(1) | |
values_text = filter(None, list_text.split(",")) | |
values = [int(x, base=16) for x in values_text] | |
output_data.extend(values) | |
with open('converted.tfl', 'wb') as output_file: | |
output_file.write(output_data) |
olivia1205
commented
Feb 29, 2020
via email
It is ok now to open it with Netron. but I don’t know why I can not see the graph in Netron yesterday.
hsjpumc1205
邮箱:[email protected]
Signature is customized by Netease Mail Master
On 02/29/2020 03:25, Pete Warden wrote: What error are you having when you try to open the result with Netron?
—You are receiving this because you commented.Reply to this email directly, view it on GitHub, or unsubscribe.
[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://gist.github.com/493294425ac522f00ff45342c71939d7?email_source=notifications\u0026email_token=AOVQUIGKFLRIFG33JQTYHUTRFFQKLA5CNFSM4K5GVAV2YY3PNVWWK3TUL52HS4DFVNDWS43UINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAGC5GM#gistcomment-3193446",
"url": "https://gist.github.com/493294425ac522f00ff45342c71939d7?email_source=notifications\u0026email_token=AOVQUIGKFLRIFG33JQTYHUTRFFQKLA5CNFSM4K5GVAV2YY3PNVWWK3TUL52HS4DFVNDWS43UINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAGC5GM#gistcomment-3193446",
"name": "View Gist"
},
"description": "View this Gist on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment