In networking communication over sockets is quite common if you want performance, alternatives would be using higher level API's, which I don't recommend for your use case. So basically you would have to setup a TCP connection between godot and your python app. Create a python tcp server, and connect to it from godot, and then send wanted data. You'll have to serialize the data (arrays and images) in godot and deserialize it on the python side, so don't expect python to know what the data is out of the box. You could create a higher level API with mimetypes, and than it would understand what the contents are, you could send pictures and arrays in json, but it's slower and you would have to have a rest framework (e.g. django rest framework). I suggest going with TCP connections.
Here are the tutorials for python tcp server and godot tcp client, they are very simple and easy to understand.
EDIT Use python for machine learning, godot is not meant for that. Python has big collection of machine learning libraries, godot is a game engine and thus, has none. There is some limited support for python, but I would avoid it for now and build a seperate system for ML.