-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient_main.py
More file actions
61 lines (50 loc) · 1.76 KB
/
Copy pathclient_main.py
File metadata and controls
61 lines (50 loc) · 1.76 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
61
import argparse
import logging
from config.configure import DEFAULT_TARGETS
from api.client import MLInferenceClient
logging.basicConfig(
level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
)
logger = logging.getLogger(__name__)
def main():
parser = argparse.ArgumentParser(description="ML Inference Client")
parser.add_argument(
"--server",
type=str,
default="localhost",
help="Server host/IP (default: localhost)",
)
parser.add_argument(
"--port", type=int, default=8000, help="Server port (default: 8000)"
)
parser.add_argument("--image", type=str, required=True, help="Input image path")
parser.add_argument(
"--target_ids",
type=int, # Convert each argument to an integer
nargs="+", # Accept one or more values, which will be collected into a list
default=DEFAULT_TARGETS,
help="List of target IDs for segmentation (e.g., 1 2 3)",
)
parser.add_argument("--threshold", type=float, default=0.5, help="Input image path")
args = parser.parse_args()
# Initialize client
client = MLInferenceClient(server_host=args.server, server_port=args.port)
print("=" * 50)
print("ML INFERENCE CLIENT")
print("=" * 50)
print(f"Server: {args.server}:{args.port}")
print("=" * 50)
logger.info(f" Single Image Prediction ")
logger.info(f"Image {args.image}")
logger.info(f"Class ID {args.target_ids}")
logger.info(f"Threshold {args.threshold}")
result = client.predict_single_image(
image_path=args.image,
target_class_ids=args.target_ids,
threshold=args.threshold,
)
print("=" * 50)
logger.info(f"{result = }")
return result
if __name__ == "__main__":
main()