Browse Source

image resize.

tags/v0.30
Oceania2018 5 years ago
parent
commit
35a9f31012
5 changed files with 28 additions and 15 deletions
  1. +1
    -1
      src/SciSharp.TensorFlow.Redist/README.md
  2. +2
    -2
      src/TensorFlowNET.Core/APIs/tf.image.cs
  3. +4
    -0
      src/TensorFlowNET.Core/APIs/tf.reshape.cs
  4. +17
    -11
      src/TensorFlowNET.Core/Operations/gen_image_ops.cs
  5. +4
    -1
      src/TensorFlowNET.Core/Operations/image_ops_impl.cs

+ 1
- 1
src/SciSharp.TensorFlow.Redist/README.md View File

@@ -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`



+ 2
- 2
src/TensorFlowNET.Core/APIs/tf.image.cs View File

@@ -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);


+ 4
- 0
src/TensorFlowNET.Core/APIs/tf.reshape.cs View File

@@ -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);


+ 17
- 11
src/TensorFlowNET.Core/Operations/gen_image_ops.cs View File

@@ -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<Tsize>(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<Tsize>(Tensor grads, Tsize size, bool align_corners = false,
bool half_pixel_centers = false, string name = null)


+ 4
- 1
src/TensorFlowNET.Core/Operations/image_ops_impl.cs View File

@@ -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,


Loading…
Cancel
Save