Tfjs: tf.image.cropAndResize not working after update from 0.13.5 to 0.14.2

Created on 27 Jan 2019  路  3Comments  路  Source: tensorflow/tfjs

TensorFlow.js version

0.14.2

Describe the problem or feature request

I built a small browser interface for tensorflow js and one of the possible augmentations is random cropping.
Until I decided to update the tfs package from 0.13.5 to 0.14.2 it was working flawlessly, now I am receiving this error:
DataAugComponent.html:42 ERROR TypeError: Cannot read property 'name' of null
at e.runKernel (tf-core.esm.js:17)
at Object.cropAndResize_ [as cropAndResize] (tf-core.esm.js:17)
at randomCrop (image-operations.ts:115)
at DataAugComponent.crop (dataaug.component.ts:36)
at MnistShowCaseComponent.push../src/app/mnist-showcase/mnistshowcase.component.ts.MnistShowCaseComponent.init (mnistshowcase.component.ts:34)
at MnistShowCaseComponent.push../src/app/mnist-showcase/mnistshowcase.component.ts.MnistShowCaseComponent.ngOnChanges (mnistshowcase.component.ts:63)
at checkAndUpdateDirectiveInline (core.js:18616)
at checkAndUpdateNodeInline (core.js:19884)
at checkAndUpdateNode (core.js:19846)
at debugCheckAndUpdateNode (core.js:20480)

Code to reproduce the bug / link to feature request

export function randomCrop(image: number[], height: number, maxX: number, maxY?: number, width?: number) {
  if (width === undefined) {
    width = height;
  }

  if (maxY === undefined) {
    maxY = maxX;
  }

  let norm_x = width - 1;
  let norm_y = height - 1;

  let y1 = maxY / norm_y;
  let x1 = maxX / norm_x;
  let y2 = (height - maxY) / norm_y;
  let x2 = (width - maxX) / norm_x;

  y1 = math.random(0, y1);
  x1 = math.random(0, x1);
  y2 = math.random(y2, 1);
  x2 = math.random(x2, 1);

  let bc = tf.image.cropAndResize(
    tf.reshape(image, [1, height, width, 1]),
    [[y1, x1, y2, x2]],
    [0],
    [height, width]
  );

  return Array.from(bc.dataSync());

Am I using it incorrectly, did something change?

bug

Most helpful comment

Reassigning the issue to people who might have more context about it.

All 3 comments

Reassigning the issue to people who might have more context about it.

This will be fixed after we release https://github.com/tensorflow/tfjs-core/pull/1506

Alright thanks for the feedback, closing this for now

Was this page helpful?
0 / 5 - 0 ratings