How to load and assign an image to a specific image node in the compositor?
Load your image using the path, add or get the image node in the compositor, and then simply assign your image data in memory to the image input of the node.

import bpy
from pathlib import Path

img_path = r"C:\MyDirectory\MyPicture.png"
if Path(img_path).is_file():
    img = bpy.data.images.load(img_path, check_existing=True)  # Load the image in data

    node_tree = bpy.context.scene.node_tree  # Get the current scene's compositor node tree

    img_comp_node = node_tree.nodes.new(type='CompositorNodeImage') #  Create a new image node
    # img_comp_node = node_tree.nodes.get('MyImageNodeName')  # Use this if your node already exists
    if img_comp_node:
        img_comp_node.image = img
else:
    print(f"The file at {img_path} doesn't exist")


Read: Controling compositor by python