Download examples/prepare_efficientdet_input.py from anan19990108/efficientdet-lite0-htp: direct link, hf CLI and curl.
- Browser
- Download file 972 Bytes
-
https://huggingface.co/anan19990108/efficientdet-lite0-htp/resolve/main/examples/prepare_efficientdet_input.py
- Command line
-
hf download hf://anan19990108/efficientdet-lite0-htp/examples/prepare_efficientdet_input.py
-
curl -L -o prepare_efficientdet_input.py https://huggingface.co/anan19990108/efficientdet-lite0-htp/resolve/main/examples/prepare_efficientdet_input.py
972 Bytes
| """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() | |