import requests
import cv2
import json
import time
url =Given URL
headers = {
'accept': 'application/x-www-form-urlencoded'
}
path = './testdir/test1.jpg'#Free path
#file = {'file': open(path, 'rb')}
data = {'urls' : ['https://goo.gl/ICoiHc', 'https://goo.gl/ICoiHc']}
start = time.time()
#response = requests.post(url, auth=requests.auth.HTTPBasicAuth('Given', ''), files=file)
response = requests.post(url, auth=requests.auth.HTTPBasicAuth('Given', ''), data=data)
end = time.time()
print("Post time", end-start, "Seconds")
print(response.text)
jsondata = response.json()
result = jsondata["result"]
image = cv2.imread(path)
sep_score = 0.3
for r in result:
labells = []
score_ls = []
print(r)
for p in r["prediction"]:
print(p)
label, left, top, right, bottom, score = p["label"], p["xmin"], p["ymin"], p["xmax"], p["ymax"], p["score"]
if score >= sep_score and not label in labells:
labells.append(label)
score_ls.append(score_ls)
cv2.rectangle(image, (left, top), (right, bottom), (255, 0, 0), thickness=3)
color = (255, 0, 0)
fontScale = 1.0
fontFace = cv2.FONT_HERSHEY_COMPLEX
text = label + " " + str(round(score, 2))
org = (left, top)
cv2.putText(image, text, org, fontFace, fontScale, color, thickness=4, lineType=cv2.LINE_8)
cv2.imshow("pic", image)
cv2.waitKey(0)
cv2.destroyAllWindows()
import requests
import time
url = 'Given'
headers = {
'accept': 'application/x-www-form-urlencoded'
}
nls = ["test1.jpg ", "test2.jpg ", "test3.jpg ", "test4.jpg ", "test5.jpg ", "test6.jpg "]
for n in nls:
path = n
file = {'file': open(path, 'rb')}
data = {'modelId': 'Given'}
start = time.time()
response = requests.request('POST', url, headers=headers, auth=requests.auth.HTTPBasicAuth('Given', ''), data=data, files=file)
end = time.time()
print("Post time", end - start, "Seconds")
print(response.text)
jsondata = response.json()
result = jsondata["result"]
Recommended Posts