preprocess for inference