You don't need to open the UI(*), you can use Gimp+Python in batch mode from a shell (or shell script), but your script still has to start a Gimp process and tell it to run your Python. See this example.
(*) Although another option is to write a plugin that takes a directory as input and process all images in that directory by itself. Called from the Gimp UI, but doesn't require user interaction once started.
(*) Although another option is to write a plugin that takes a directory as input and process all images in that directory by itself. Called from the Gimp UI, but doesn't require user interaction once started.