diff --git a/src/SciSharp.TensorFlow.Redist/README.md b/src/SciSharp.TensorFlow.Redist/README.md index 3131a307..26eec870 100644 --- a/src/SciSharp.TensorFlow.Redist/README.md +++ b/src/SciSharp.TensorFlow.Redist/README.md @@ -27,6 +27,6 @@ Related merged [commits](https://github.com/SciSharp/TensorFlow.NET/commit/854a5 On Windows, the tar command does not support extracting archives with symlinks. So when `dotnet pack` runs on Windows it will only package the Windows binaries. 1. Run `dotnet pack SciSharp.TensorFlow.Redist.nupkgproj` under `src/SciSharp.TensorFlow.Redist` directory in Linux. -2. Run `dotnet nuget push SciSharp.TensorFlow.Redist.2.3.0.nupkg -k APIKEY -s https://api.nuget.org/v3/index.json` +2. Run `dotnet nuget push SciSharp.TensorFlow.Redist.2.3.1.nupkg -k APIKEY -s https://api.nuget.org/v3/index.json -t 600` diff --git a/src/TensorFlowNET.Core/APIs/tf.image.cs b/src/TensorFlowNET.Core/APIs/tf.image.cs index 9d836560..433c573d 100644 --- a/src/TensorFlowNET.Core/APIs/tf.image.cs +++ b/src/TensorFlowNET.Core/APIs/tf.image.cs @@ -208,8 +208,8 @@ namespace Tensorflow => image_ops_impl.non_max_suppression_padded(boxes, scores, max_output_size, iou_threshold, score_threshold, pad_to_max_output_size, name, sorted_input, canonicalized_coordinates, tile_size); - public Tensor resize(Tensor image, TensorShape size) - => image_ops_impl.resize_images_v2(image, size); + public Tensor resize(Tensor image, TensorShape size, string method = ResizeMethod.BILINEAR) + => image_ops_impl.resize_images_v2(image, size, method: method); public Tensor resize_bilinear(Tensor images, Tensor size, bool align_corners = false, bool half_pixel_centers = false, string name = null) => gen_image_ops.resize_bilinear(images, size, align_corners: align_corners, half_pixel_centers: half_pixel_centers, name: name); diff --git a/src/TensorFlowNET.Core/APIs/tf.reshape.cs b/src/TensorFlowNET.Core/APIs/tf.reshape.cs index 334889bb..3952b82c 100644 --- a/src/TensorFlowNET.Core/APIs/tf.reshape.cs +++ b/src/TensorFlowNET.Core/APIs/tf.reshape.cs @@ -22,6 +22,10 @@ namespace Tensorflow TensorShape shape, string name = null) => gen_array_ops.reshape(tensor, shape, name); + public Tensor reshape(Tensor tensor, + Tensor[] shape, + string name = null) => gen_array_ops.reshape(tensor, shape, name); + public Tensor reshape(Tensor tensor, Tensor shape, string name = null) => gen_array_ops.reshape(tensor, shape, name); diff --git a/src/TensorFlowNET.Core/Operations/gen_image_ops.cs b/src/TensorFlowNET.Core/Operations/gen_image_ops.cs index def672da..17c3031c 100644 --- a/src/TensorFlowNET.Core/Operations/gen_image_ops.cs +++ b/src/TensorFlowNET.Core/Operations/gen_image_ops.cs @@ -15,6 +15,8 @@ ******************************************************************************/ using System; +using System.Linq; +using Tensorflow.Contexts; using static Tensorflow.Binding; namespace Tensorflow @@ -221,17 +223,21 @@ namespace Tensorflow public static Tensor resize_nearest_neighbor(Tensor images, Tsize size, bool align_corners = false, bool half_pixel_centers = false, string name = null) - { - var op = tf.OpDefLib._apply_op_helper("ResizeNearestNeighbor", name: name, args: new - { - images, - size, - align_corners, - half_pixel_centers - }); - - return op.output; - } + => tf.Context.RunInAutoMode(() + => tf.OpDefLib._apply_op_helper("ResizeNearestNeighbor", name: name, args: new + { + images, + size, + align_corners, + half_pixel_centers + }).output, () + => tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, + "ResizeNearestNeighbor", name, + null, + images, size, + "align_corners", align_corners, + "half_pixel_centers", half_pixel_centers).FirstOrDefault(), + images); public static Tensor resize_nearest_neighbor_grad(Tensor grads, Tsize size, bool align_corners = false, bool half_pixel_centers = false, string name = null) diff --git a/src/TensorFlowNET.Core/Operations/image_ops_impl.cs b/src/TensorFlowNET.Core/Operations/image_ops_impl.cs index 947a7b2e..e4ca8ec4 100644 --- a/src/TensorFlowNET.Core/Operations/image_ops_impl.cs +++ b/src/TensorFlowNET.Core/Operations/image_ops_impl.cs @@ -2168,7 +2168,10 @@ new_height, new_width"); { if (method == ResizeMethod.BILINEAR) return gen_image_ops.resize_bilinear(images, size, half_pixel_centers: true); - throw new NotImplementedException(""); + else if (method == ResizeMethod.NEAREST_NEIGHBOR) + return gen_image_ops.resize_nearest_neighbor(images, size, half_pixel_centers: true); + + throw new NotImplementedException("resize_images_v2"); }; return _resize_images_common(images, resize_fn, ops.convert_to_tensor(size), preserve_aspect_ratio: preserve_aspect_ratio,