Distributed learning and inference with compressed images