upload_image does not handle certain pngs
kmjoshi opened this issue · comments
when querying the application locally, the following image: https://tattle-services.s3.ap-south-1.amazonaws.com/115c08f0-d90c-11e9-ba13-838b5376152a
using command:
curl -X POST $LIVE_SERVER/upload_image -H "Content-Type: application/json" -d '{"image_url": "https://tattle-services.s3.ap-south-1.amazonaws.com/115c08f0-d90c-11e9-ba13-838b5376152a"}'
gives the error:
File "/mnt/d/tattle-api/application.py", line 190, in upload_image
image_vec = resnet18.extract_feature(image)
File "/mnt/d/tattle-api/analyzer.py", line 67, in extract_feature
self.to_tensor(self.scaler(img))).unsqueeze(0))
File "/home/kjoshi/py36/lib/python3.6/site-packages/torchvision/transforms/transforms.py", line 166, in __call__
return F.normalize(tensor, self.mean, self.std, self.inplace)
File "/home/kjoshi/py36/lib/python3.6/site-packages/torchvision/transforms/functional.py", line 217, in normalize
tensor.sub_(mean[:, None, None]).div_(std[:, None, None])
RuntimeError: The size of tensor a (4) must match the size of tensor b (3) at non-singleton dimension 0
but it works for other pngs such as: https://png.pngtree.com/element_our/sm/20180327/sm_5aba147bcacf2.png