TensorFlow.NET.Samples/ImageProcessing/RetrainImageClassifierTransferLearningTFNET.cs
/// <summary>
/// Runs inference on an image to extract the 'bottleneck' summary layer.
/// </summary>
/// <param name="sess">Current active TensorFlow Session.</param>
/// <param name="image_data">Data of raw JPEG data.</param>
/// <param name="image_data_tensor">Input data layer in the graph.</param>
/// <param name="decoded_image_tensor">Output of initial image resizing and preprocessing.</param>
/// <param name="resized_input_tensor">The input node of the recognition graph.</param>
/// <param name="bottleneck_tensor">Layer before the final softmax.</param>
/// <returns></returns>
Runs inference on an image to extract the 'bottleneck' summary layer.
Runs inference on an image to extract the ' bottleneck ' summary layer .
private NDArray run_bottleneck_on_image(Session sess, byte[] image_data, Tensor image_data_tensor,
                            Tensor decoded_image_tensor, Tensor resized_input_tensor, Tensor bottleneck_tensor)
        {
            var resized_input_values = sess.run(decoded_image_tensor, new FeedItem(image_data_tensor, new Tensor(image_data, TF_DataType.TF_STRING)));
            var bottleneck_values = sess.run(bottleneck_tensor, new FeedItem(resized_input_tensor, resized_input_values));
            bottleneck_values = np.squeeze(bottleneck_values);
            return bottleneck_values;
        }
private NDArray run_bottleneck_on_image ( Session sess , byte [ ] image_data , Tensor image_data_tensor , Tensor decoded_image_tensor , Tensor resized_input_tensor , Tensor bottleneck_tensor ) { var resized_input_values = sess . run ( decoded_image_tensor , new FeedItem ( image_data_tensor , new Tensor ( image_data , TF_DataType . TF_STRING ) ) ) ; var bottleneck_values = sess . run ( bottleneck_tensor , new FeedItem ( resized_input_tensor , resized_input_values ) ) ; bottleneck_values = np . squeeze ( bottleneck_values ) ; return bottleneck_values ; }
Runs inference on an image to extract the 'bottleneck' summary layer.
Runs inference on an image to extract the ' bottleneck ' summary layer .
// First decode the JPEG image, resize it, and rescale the pixel values. // Then run it through the recognition network.
None
sess
Session
Current active TensorFlow Session.
Current active TensorFlow Session .
image_data
byte[]
Data of raw JPEG data.
Data of raw JPEG data .
image_data_tensor
Tensor
Input data layer in the graph.
Input data layer in the graph .
decoded_image_tensor
Tensor
Output of initial image resizing and preprocessing.
Output of initial image resizing and preprocessing .
resized_input_tensor
Tensor
The input node of the recognition graph.
The input node of the recognition graph .
bottleneck_tensor
Tensor
Layer before the final softmax.
Layer before the final softmax .