{"action":"created","issue":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/1029","repository_url":"https://api.github.com/repos/tensorflow/tensorflow","labels_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/1029/labels{/name}","comments_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/1029/comments","events_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/1029/events","html_url":"https://github.com/tensorflow/tensorflow/issues/1029","id":132415754,"number":1029,"title":"tf.image.resize_images() has no effect on image shape","user":{"login":"mackcmillion","id":6370271,"avatar_url":"https://avatars.githubusercontent.com/u/6370271?v=3","gravatar_id":"","url":"https://api.github.com/users/mackcmillion","html_url":"https://github.com/mackcmillion","followers_url":"https://api.github.com/users/mackcmillion/followers","following_url":"https://api.github.com/users/mackcmillion/following{/other_user}","gists_url":"https://api.github.com/users/mackcmillion/gists{/gist_id}","starred_url":"https://api.github.com/users/mackcmillion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mackcmillion/subscriptions","organizations_url":"https://api.github.com/users/mackcmillion/orgs","repos_url":"https://api.github.com/users/mackcmillion/repos","events_url":"https://api.github.com/users/mackcmillion/events{/privacy}","received_events_url":"https://api.github.com/users/mackcmillion/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"shlens","id":13385191,"avatar_url":"https://avatars.githubusercontent.com/u/13385191?v=3","gravatar_id":"","url":"https://api.github.com/users/shlens","html_url":"https://github.com/shlens","followers_url":"https://api.github.com/users/shlens/followers","following_url":"https://api.github.com/users/shlens/following{/other_user}","gists_url":"https://api.github.com/users/shlens/gists{/gist_id}","starred_url":"https://api.github.com/users/shlens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shlens/subscriptions","organizations_url":"https://api.github.com/users/shlens/orgs","repos_url":"https://api.github.com/users/shlens/repos","events_url":"https://api.github.com/users/shlens/events{/privacy}","received_events_url":"https://api.github.com/users/shlens/received_events","type":"User","site_admin":false},"milestone":null,"comments":1,"created_at":"2016-02-09T13:12:08Z","updated_at":"2016-03-08T01:00:46Z","closed_at":null,"body":"It looks like the op `tf.image.resize_images()` has no effect on the image shape when the parameters `new_height` and `new_width` are dynamically computed (this is possible since the fix of issue #1001).\r\n\r\nFor example, this piece of code\r\n\r\n    shape = tf.shape(image)\r\n    height = shape[0]\r\n    width = shape[1]\r\n    new_shorter_edge = tf.constant(400, dtype=tf.int32)\r\n\r\n    height_smaller_than_width = tf.less_equal(height, width)\r\n    new_height_and_width = tf.cond(\r\n        height_smaller_than_width,\r\n        lambda: (new_shorter_edge, _compute_longer_edge(height, width, new_shorter_edge)),\r\n        lambda: (_compute_longer_edge(width, height, new_shorter_edge), new_shorter_edge)\r\n    )\r\n\r\n    image = tf.image.resize_images(image, new_height_and_width[0], new_height_and_width[1])\r\n    image = tf.Print(image, [tf.shape(image), height, width, new_height_and_width[0], new_height_and_width[1]])\r\n    return tf.image.random_crop(image, [224, 224])\r\n\r\nthrows the following exception:\r\n\r\n    I tensorflow/core/kernels/logging_ops.cc:79] [122 160 3][122][160][400][524]\r\n    W tensorflow/core/common_runtime/executor.cc:1096] 0x7f9c08008490 Compute status: Failed precondition: width must be >= target_width: width = 160, target_width = 224\r\n\r\nSo as you can see in the first line of the printout, the shape of the image is not affected by `tf.image.resize_images`. Is this a bug or am I doing something wrong?\r\n\r\n-----------------\r\n\r\nI also made up a workaround for this:\r\n\r\n    image = tf.expand_dims(image, 0)\r\n    image = tf.image.resize_bilinear(image, tf.pack(new_height_and_width))\r\n    image = tf.squeeze(image, [0])\r\n    image = tf.Print(image, [tf.shape(image), height, width, new_height_and_width[0], new_height_and_width[1]])\r\n    return tf.image.random_crop(image, [224, 224])\r\n\r\nfor example prints\r\n\r\n    I tensorflow/core/kernels/logging_ops.cc:79] [400 711 3][281][500][400][711]"},"comment":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/comments/193534093","html_url":"https://github.com/tensorflow/tensorflow/issues/1029#issuecomment-193534093","issue_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/1029","id":193534093,"user":{"login":"girving","id":70511,"avatar_url":"https://avatars.githubusercontent.com/u/70511?v=3","gravatar_id":"","url":"https://api.github.com/users/girving","html_url":"https://github.com/girving","followers_url":"https://api.github.com/users/girving/followers","following_url":"https://api.github.com/users/girving/following{/other_user}","gists_url":"https://api.github.com/users/girving/gists{/gist_id}","starred_url":"https://api.github.com/users/girving/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/girving/subscriptions","organizations_url":"https://api.github.com/users/girving/orgs","repos_url":"https://api.github.com/users/girving/repos","events_url":"https://api.github.com/users/girving/events{/privacy}","received_events_url":"https://api.github.com/users/girving/received_events","type":"User","site_admin":false},"created_at":"2016-03-08T01:00:46Z","updated_at":"2016-03-08T01:00:46Z","body":"@shlens: Do you know the correct way to fix this?"}}