Yes, probably the first step would be to just replace the resnet with your own but also to move everything above Image.open and the reading of the classes out of the predict function.
If you’re looking at multithreading or so, using the JIT is important (it was mainly my theory when I wrote that chapter, but we’ve seen it in the wild in these forums since).