Skip to content

Is there a way to use my GPU to apply a color transform to an image? #1690

@OverwriteDev

Description

@OverwriteDev

I'm using python 3.10 and I'd like to apply a color transform to an image. I've followed the code example and got everything set up as below. When I execute my program it loads in an EXR image, converts it to Numpy Array, and then passes it into the 'applyColorTransformToImage' function. In it, I do the config and env setup then set up the processor and apply the transform.
I was expecting to return either an ndarray or a python list but this returns None. I saw that applyRGB returns a list when a list is fed in, so I tried converting my ndarray to a list so that I can feed it into the applyRGB function but it is unreasonably slow to the point that I end up canceling the application.

def applyColorTransformToImage(imageToTransform):

iconfig_file_path = ('./opencolorio/nuke-default/config.ocio')
OCIO.SetEnvVariable('OCIO', config_file_path)
config = OCIO.GetCurrentConfig()

processor = config.getProcessor('linear','sRGB') 
cpu = processor.getDefaultCPUProcessor() 

transformedImage = imageToTransform
transformedImage = cpu.applyRGB(transformedImage)

return transformedImage

I got around this bottleneck by using cupy to offload the process onto my GPU which was orders of magnitude faster. Finally, with my list in hand I passed it into the applyRGB function and then I get the same deathly slow speed as when converting the ndarray to list mentioned previously.

Is there a faster way to apply a color transform that I'm just not seeing/finding in the documentation? Is it possible to use my GPU to apply a color transform instead of my CPU? If so, could someone kindly point me in the right direction with a code example?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions