Skip to content

Commit

Permalink
ImageToTensor
Browse files Browse the repository at this point in the history
  • Loading branch information
johnhaddon committed Nov 6, 2024
1 parent 48bdfd2 commit 2ed52f7
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions src/GafferML/ImageToTensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,6 @@ void ImageToTensor::compute( Gaffer::ValuePlug *output, const Gaffer::Context *c
vector<float> &buffer = bufferData->writable();
buffer.resize( numPixels * channels.size() );

// boost::container::flat_map<std::string, float *> channelBuffers;
// for( size_t i = 0; i < channels.size(); ++i )
// {
// channelBuffers[channels[i]] = buffer.data() + numPixels * i;
// }

boost::container::flat_map<std::string, size_t> channelIndices;
for( size_t i = 0; i < channels.size(); ++i )
{
Expand All @@ -233,7 +227,6 @@ void ImageToTensor::compute( Gaffer::ValuePlug *output, const Gaffer::Context *c
ConstFloatVectorDataPtr channelData = image->channelDataPlug()->getValue();
const Box2i tileBound( tileOrigin, tileOrigin + V2i( ImagePlug::tileSize() ) );
const Box2i validTileBound = BufferAlgo::intersection( tileBound, dataWindow );
//float *channelBuffer = channelBuffers[channelName];

const size_t channelIndex = channelIndices[channelName];
float *dstData = buffer.data();
Expand All @@ -260,24 +253,18 @@ void ImageToTensor::compute( Gaffer::ValuePlug *output, const Gaffer::Context *c
dstData[dstIndex] = sourceData[srcIndex++];
dstIndex += dstStride;
}

// std::copy(
// channelData->readable().begin() + srcIndex,
// channelData->readable().begin() + srcIndex + validTileBound.size().x,
// channelBuffer + dstIndex
// );
}
}
);

vector<int64_t> shape;
if( interleaveChannels )
{
shape = { 1, dataWindow.size().x, dataWindow.size().y, (int64_t)channels.size() }; // TODO : SHOULD THIS BE YX?
shape = { 1, dataWindow.size().y, dataWindow.size().x, (int64_t)channels.size() };
}
else
{
shape = { 1, (int64_t)channels.size(), dataWindow.size().x, dataWindow.size().y }; // TODO : SHOULD THIS BE YX?
shape = { 1, (int64_t)channels.size(), dataWindow.size().y, dataWindow.size().x };
}

ConstTensorPtr tensor = new Tensor( bufferData, shape );
Expand Down

0 comments on commit 2ed52f7

Please sign in to comment.