A computer-implemented method of training a machine learning model to determine representations of lens flare from images, the method comprising: obtaining a plurality of baseline images and a plurality of lens flare images; generating a plurality of training images by combining each respective baseline image of the plurality of baseline images with a corresponding lens flare image of a plurality of lens flare images; for each respective training image of the plurality of training images: determining a modified image by processing the respective training image by the machine learning model, wherein the modified image comprises the respective training image with at least part of a corresponding representation of lens flare removed; determining a loss value based on a loss function configured to compare the modified image to a corresponding baseline image used to generate the respective training image; determining a recovered lens flare image by the machine learning model or based on a difference between the modified image and the respective training image; and determining the loss value further based on a second loss function configured to compare the recovered lens flare image to a corresponding lens flare image used to generate the respective training image; and adjusting one or more parameters of the machine learning model based on the loss value determined for each respective training image, the loss function, and the second loss function. obtaining a plurality of baseline images and a plurality of lens flare images; generating a plurality of training images by combining each respective baseline image of the plurality of baseline images with a corresponding lens flare image of a plurality of lens flare images; for each respective training image of the plurality of training images: determining a modified image by processing the respective training image by the machine learning model, wherein the modified image comprises the respective training image with at least part of a corresponding representation of lens flare removed; determining a loss value based on a loss function configured to compare the modified image to a corresponding baseline image used to generate the respective training image; determining a recovered lens flare image by the machine learning model or based on a difference between the modified image and the respective training image; and determining the loss value further based on a second loss function configured to compare the recovered lens flare image to a corresponding lens flare image used to generate the respective training image; and determining a modified image by processing the respective training image by the machine learning model, wherein the modified image comprises the respective training image with at least part of a corresponding representation of lens flare removed; determining a loss value based on a loss function configured to compare the modified image to a corresponding baseline image used to generate the respective training image; determining a recovered lens flare image by the machine learning model or based on a difference between the modified image and the respective training image; and determining the loss value further based on a second loss function configured to compare the recovered lens flare image to a corresponding lens flare image used to generate the respective training image; adjusting one or more parameters of the machine learning model based on the loss value determined for each respective training image, the loss function, and the second loss function. <EOS>