The predict method seems to initialize the complete model, transformation, loads the data, processes the forward pass, and returns the class probabilities for a single input image.
I’m not a webapp expert, but this seems very inefficient. I would recommend to take a look at chapter 15 in Deep Learning with PyTorch 9 (which is still free) by @elistevens, @lantiga, and @tom.