Created
May 7, 2019 10:55
-
-
Save NSLog0/07b3451ce1e5daa0c72f4afffe418fc5 to your computer and use it in GitHub Desktop.
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 argparse | |
import io | |
import time | |
import numpy as np | |
from edgetpu.detection.engine import DetectionEngine | |
import cv2 | |
def main(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument( | |
'--model', help='File path of Tflite model.', required=True) | |
parser.add_argument( | |
'--input', help='File path of the input image.', required=True) | |
parser.add_argument( | |
'--output', help='File path of the output image.') | |
args = parser.parse_args() | |
if not args.output: | |
output_name = 'object_detection_result.jpg' | |
else: | |
output_name = args.output | |
img = cv2.imread(args.input,0) | |
img = cv2.resize(img, dsize=(299, 299), interpolation = cv2.INTER_CUBIC) | |
img = np.asarray(img, dtype=np.float32) | |
engine = DetectionEngine(args.model) | |
ans = engine.DetectWithImage(img, threshold=0.05, keep_aspect_ratio=True, | |
relative_coord=False, top_k=10) | |
print(ans) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment