From 0c9cde38fabf5a2ab33344db2727f8de3c0d8f4c Mon Sep 17 00:00:00 2001 From: John Haddon Date: Fri, 1 Nov 2024 22:49:10 +0000 Subject: [PATCH] ImageToTensor --- python/GafferMLUI/ImageToTensorUI.py | 69 +++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 6 deletions(-) diff --git a/python/GafferMLUI/ImageToTensorUI.py b/python/GafferMLUI/ImageToTensorUI.py index f9fc11ce50d..b932ac870d9 100644 --- a/python/GafferMLUI/ImageToTensorUI.py +++ b/python/GafferMLUI/ImageToTensorUI.py @@ -41,19 +41,76 @@ GafferML.ImageToTensor, - # "description", - # """ - # Converts Gaffer data to tensors for use with the Inference node. - # Potential data sources include PrimitiveVariableQuery nodes to fetch data - # from 3D scenes, or expressions to generate arbitrary input data. - # """, + "description", + """ + Converts images to tensors for use with the Inference node. + + > Note : Only the data window is converted, as it would typically be + > wasteful to convert and process the empty pixels outside the data window. + > If this is necessary, merge the image over a Constant image before + > conversion. + """, plugs = { + "image" : [ + + "description", + """ + The image to be converted. + """, + + ], + "view" : [ + "description", + """ + The image view to take the tensor data from. + """, + "plugValueWidget:type", "GafferImageUI.ViewPlugValueWidget", + "noduleLayout:visible", False, + + ], + + "channels" : [ + + "description", + """ + The list of channels to convert. Channels are added to the + tensor in the order specified, so can be shuffled by changing + the order. For example, an order of `[ "B", "G", "R" ]` might + be needed for use with model trained on images using OpenCV + conventions. + """, + + "noduleLayout:visible", False, + + ], + + "interleaveChannels" : [ + + "description", + """ + Interleaves the channel data, so that all channels for a single + pixel are adjacent in memory. + """, + + "noduleLayout:visible", False, + + ], + + "tensor" : [ + + "description", + """ + The output tensor. + """, + + "layout:visibilityActivator", lambda plug : False, + ], }