forked from mryab/efficient-dl-systems
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient-url.py
29 lines (21 loc) · 798 Bytes
/
client-url.py
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
import argparse
import os
import concurrent.futures
import random
from collections import Counter
import requests
from furl import furl
import torchvision.transforms as transforms
from PIL import Image
def main_single(img_path, server_url):
if not img_path.startswith('https://'):
img_path = str(furl("http://image-server:9091") / img_path)
predict_url = str(furl(server_url) / "predict")
r = requests.post(predict_url, json={'image_url': img_path})
print("It is {}".format(r.json()['label']))
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("img", help="path to img")
parser.add_argument("--url", help="url to server", default="http://localhost:8081")
args = parser.parse_args()
main_single(args.img, args.url)