From: 김정현/동작제어Lab(SR)/Senior Engineer/삼성전자 Date: Mon, 26 Mar 2018 07:25:31 +0000 (+0900) Subject: Introduce image importer (#205) X-Git-Tag: 0.1~592 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=65967c3ea19e9c8a559903801e9d6f23f02419f1;p=platform%2Fcore%2Fml%2Fnnfw.git Introduce image importer (#205) This commit introduces image importer to convert jpeg or png images to bin. The binary file only has the pixel values. It does not have size. The output will be used for `tflite_run`. Signed-off-by: Junghyun Kim --- diff --git a/tools/image_importer/image_importer.py b/tools/image_importer/image_importer.py new file mode 100755 index 0000000..26aa2e4 --- /dev/null +++ b/tools/image_importer/image_importer.py @@ -0,0 +1,18 @@ +#!/usr/bin/python +from PIL import Image +import sys +import struct + +if( len(sys.argv) < 3 ): + print("Usage: %s "%(sys.argv[0])); + exit(0) + +img = Image.open(sys.argv[1]) +outfile = sys.argv[2] + +print "Image format = ", img.bits, img.size, img.format + +with open(outfile, 'wb') as f: + f.write(img.tobytes()) + +print "Done."