From python script, I am doing Torch serve on like:
arr = np.array(np.random.randn(x,y,z))
data = {'arr': arr.tolist()}
response = requests.post(url, json=data)
In the inference method of the custom handler I have:
def inference(self, ds, *args, **kwargs):
print("type of ds") ##### <class 'list'>
print(type(ds))
print("type of ds[0]")
print(type(ds[0])) ##### <class 'dict'>
count = 0
whatineed = None
for k, v in ds[0].items():
tk = type(k)
tv = type(v)
for kk, vv in v.items():
print("KK: " + str(kk)) ##### KK: arr
print("Len of vv: " + str(len(vv))) # 1
whatineed = vv
count = count+1
... [ other stuff ]
How can I avoid searching for whatineed?
Is there an easier way to package the input array on the request side?