File size: 972 Bytes
b6b23bd 957622a b6b23bd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | """Prepare one image for all three QCS8550 EfficientDet network runtimes."""
import argparse
import json
from pathlib import Path
import numpy as np
from infer import preprocess
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument("--image", type=Path, required=True)
parser.add_argument("--output-dir", type=Path, required=True)
args = parser.parse_args()
image, size = preprocess(args.image)
args.output_dir.mkdir(parents=True, exist_ok=True)
(args.output_dir / "tflite").mkdir(exist_ok=True)
(args.output_dir / "float32").mkdir(exist_ok=True)
image.tofile(args.output_dir / "tflite/000000000000.bin")
((image.astype(np.float32) - 127) / 128).tofile(
args.output_dir / "float32/000000000000.bin")
(args.output_dir / "image_size.json").write_text(
json.dumps({"width": size[0], "height": size[1]}), encoding="utf-8")
print(args.output_dir)
if __name__ == "__main__":
main()
|