-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple.py
More file actions
60 lines (48 loc) · 1.66 KB
/
simple.py
File metadata and controls
60 lines (48 loc) · 1.66 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""Copyright (C) Square Factory SA - All Rights Reserved.
This source code is protected under international copyright law. All rights
reserved and protected by the copyright holders.
This file is confidential and only available to authorized individuals with the
permission of the copyright holders. If you encounter this file and do not have
permission, please contact the copyright holders and delete this file.
"""
import argparse
import time
import warnings
import cv2
import numpy as np
from i2_client import I2Client
parser = argparse.ArgumentParser()
parser.add_argument("--url", type=str, required=True)
parser.add_argument(
"--access_uuid",
type=str,
)
parser.add_argument(
"--access-key",
type=str,
)
parser.add_argument(
"--debug",
action="store_true",
)
args = parser.parse_args()
if args.access_uuid is not None:
warnings.warn("--access_uuid is deprecated, use --access-key", DeprecationWarning)
args.access_key = args.access_uuid
if args.access_uuid is None and args.access_key is None:
raise ValueError("You have to provide an access key with --access-key")
i2_client = I2Client(args.url, args.access_key, debug=args.debug)
img = cv2.imread("test.jpg")
if img is None:
raise FileNotFoundError("invalid image")
start = time.time()
success, output = i2_client.inference(img)[0]
duration = time.time() - start
print(f"duration: {duration:.4f} secs (open connection + send + inference + receive)")
if not success:
raise RuntimeError(output)
print("press on any key to quit...")
concatenate_imgs = np.concatenate((img, output), axis=1)
cv2.imshow("original / inference ", concatenate_imgs)
cv2.waitKey(0)
cv2.destroyAllWindows()