jdhao's digital space

Recent content on jdhao's digital space

马上订阅 jdhao's digital space RSS 更新: https://jdhao.github.io/index.xml

Accelerate Batched Image Inference in PyTorch

2022年3月18日 22:59

I have a web service where the images come in a batch so I have to do inference for several images in PIL format at a time. Initially, I use a naive approach and just transform the images one by one, then combine them to form a single tensor and do the inference. The inference becomes really slow when I have a batch with more than 30 images. The inference time is about 1-2 seconds per batch.