Hello,
First, consider what your data processing steps are: More often than not, PIL suffices as it includes many, many types of image transforms, from simple ones like resizing to more complex ones like applying a custom kernel. So, PIL is required (unless you use another library like OpenCV, but I advise against it for basic tasks like cropping.), but it is also often enough, and you don’t need any other dependencies.
For making predictions with the model, you don’t need fastai; PyTorch alone would do because remember, the underlying models used by fastai are all PyTorch models (accessible via learn.model
). You could, after processing your image, feed it to the PyTorch model, and there’d be no need for fastai.
The only caveat is that there are a few post-processing actions you may have to perform: If your task is single-label classification, the model likely outputs logits that have to be turned into probabilities with a normalizer like the softmax function. In the case of image-to-image translation, the output of the model would have to be denormalized and potentially scaled to a [0, 255] range. Whichever the case though, it’s nothing impossible, and only a few extra lines of code would have to be written.
Another available option would be ONNX. It requires converting the PyTorch model into an ONNX model (occasionally a headache), but the upside is that it is superbly fast and efficient. The pre- and post-processing steps remain the same, but they would need to be done in NumPy rather than PyTorch because ONNX models accept and spit back NumPy arrays.
The bottom line is, fastai is by no means necessary (although it does make life easier), and you have two other options: PyTorch (which ships with NumPy, but you can usually go ahead and remove it), or ONNX + NumPy. The former is easier to use, whereas the latter is faster and leaves a smaller memory footprint at the expense of generally being more difficult to deal with, particularly when the model includes lesser-known layers.
Good luck!