{
  "id": 28928,
  "title": "Need help in code provided by Deepsense team",
  "url": "/competitions/noaa-right-whale-recognition/discussion/28928",
  "author_name": "quest",
  "post_date": "2017-02-17T12:48:53.839000",
  "votes": 0,
  "comment_count": 0,
  "views": 0,
  "content": "<p>Hi, anyone tried to run the code provided by the DeepSense team, please? I am getting the following error, can anyone help ? thank you very much.</p>\n\n<p>//error call stack</p>\n\n<p>Traceback (most recent call last):\nFile \"/media/samihaq/Quest2/deepsense-whales/whales/dataloading.py\", line 425, in fetch_example_anno_indygo img = fast_warp(img, AffineTransform(tform_res._inv_matrix), output_shape=(target_h, target_w))\nFile \"/media/samihaq/Quest2/deepsense-whales/augmentation.py\", line 108, in fast_warp m = tf._matrix AttributeError: 'AffineTransform' object has no attribute '_matrix'</p>\n\n<p>/////////////////////////////////////////////////////////////////////////// AffineTransform class is from \"scikit-image\" and indeed it does not have any member \"_matrix\" but the code provided by DeepSense team refers to that.</p>\n\n<p>// function call</p>\n\n<pre><code>img = fast_warp(img, AffineTransform(tform_res._inv_matrix), output_shape=(target_h, target_w)) \n\n// function\n\ndef fast_warp(img, tf, output_shape=(50, 50), mode='constant', order=1):\n    \"\"\"\n    This wrapper function is faster than skimage.transform.warp\n    \"\"\"\n    m = tf._matrix\n    res = np.zeros(shape=(output_shape[0], output_shape[1], 3), dtype=floatX)\n    from scipy.ndimage import affine_transform\n    trans, offset = m[:2, :2], (m[0, 2], m[1, 2])\n    res[:, :, 0] = affine_transform(img[:, :, 0].T, trans, offset=offset, output_shape=output_shape, mode=mode, order=order)\n    res[:, :, 1] = affine_transform(img[:, :, 1].T, trans, offset=offset, output_shape=output_shape, mode=mode, order=order)\n    res[:, :, 2] = affine_transform(img[:, :, 2].T, trans, offset=offset, output_shape=output_shape, mode=mode, order=order)\n    return res\n</code></pre>\n\n<p>Regards</p>",
  "messages": [
    {
      "id": 162156,
      "postDate": "2017-02-17T12:48:53.840Z",
      "content": "<p>Hi, anyone tried to run the code provided by the DeepSense team, please? I am getting the following error, can anyone help ? thank you very much.</p>\n\n<p>//error call stack</p>\n\n<p>Traceback (most recent call last):\nFile \"/media/samihaq/Quest2/deepsense-whales/whales/dataloading.py\", line 425, in fetch_example_anno_indygo img = fast_warp(img, AffineTransform(tform_res._inv_matrix), output_shape=(target_h, target_w))\nFile \"/media/samihaq/Quest2/deepsense-whales/augmentation.py\", line 108, in fast_warp m = tf._matrix AttributeError: 'AffineTransform' object has no attribute '_matrix'</p>\n\n<p>/////////////////////////////////////////////////////////////////////////// AffineTransform class is from \"scikit-image\" and indeed it does not have any member \"_matrix\" but the code provided by DeepSense team refers to that.</p>\n\n<p>// function call</p>\n\n<pre><code>img = fast_warp(img, AffineTransform(tform_res._inv_matrix), output_shape=(target_h, target_w)) \n\n// function\n\ndef fast_warp(img, tf, output_shape=(50, 50), mode='constant', order=1):\n    \"\"\"\n    This wrapper function is faster than skimage.transform.warp\n    \"\"\"\n    m = tf._matrix\n    res = np.zeros(shape=(output_shape[0], output_shape[1], 3), dtype=floatX)\n    from scipy.ndimage import affine_transform\n    trans, offset = m[:2, :2], (m[0, 2], m[1, 2])\n    res[:, :, 0] = affine_transform(img[:, :, 0].T, trans, offset=offset, output_shape=output_shape, mode=mode, order=order)\n    res[:, :, 1] = affine_transform(img[:, :, 1].T, trans, offset=offset, output_shape=output_shape, mode=mode, order=order)\n    res[:, :, 2] = affine_transform(img[:, :, 2].T, trans, offset=offset, output_shape=output_shape, mode=mode, order=order)\n    return res\n</code></pre>\n\n<p>Regards</p>",
      "rawMarkdown": "Hi, anyone tried to run the code provided by the DeepSense team, please? I am getting the following error, can anyone help ? thank you very much.\n\n//error call stack\n\nTraceback (most recent call last):\nFile \"/media/samihaq/Quest2/deepsense-whales/whales/dataloading.py\", line 425, in fetch_example_anno_indygo img = fast_warp(img, AffineTransform(tform_res._inv_matrix), output_shape=(target_h, target_w))\nFile \"/media/samihaq/Quest2/deepsense-whales/augmentation.py\", line 108, in fast_warp m = tf._matrix AttributeError: 'AffineTransform' object has no attribute '_matrix'\n\n/////////////////////////////////////////////////////////////////////////// AffineTransform class is from \"scikit-image\" and indeed it does not have any member \"_matrix\" but the code provided by DeepSense team refers to that.\n\n// function call\n\n    img = fast_warp(img, AffineTransform(tform_res._inv_matrix), output_shape=(target_h, target_w)) \n    \n    // function\n    \n    def fast_warp(img, tf, output_shape=(50, 50), mode='constant', order=1):\n        \"\"\"\n        This wrapper function is faster than skimage.transform.warp\n        \"\"\"\n        m = tf._matrix\n        res = np.zeros(shape=(output_shape[0], output_shape[1], 3), dtype=floatX)\n        from scipy.ndimage import affine_transform\n        trans, offset = m[:2, :2], (m[0, 2], m[1, 2])\n        res[:, :, 0] = affine_transform(img[:, :, 0].T, trans, offset=offset, output_shape=output_shape, mode=mode, order=order)\n        res[:, :, 1] = affine_transform(img[:, :, 1].T, trans, offset=offset, output_shape=output_shape, mode=mode, order=order)\n        res[:, :, 2] = affine_transform(img[:, :, 2].T, trans, offset=offset, output_shape=output_shape, mode=mode, order=order)\n        return res\n\nRegards"
    }
  ],
  "comments": [],
  "raw_markdown_by_id": {
    "162156": "Hi, anyone tried to run the code provided by the DeepSense team, please? I am getting the following error, can anyone help ? thank you very much.\n\n//error call stack\n\nTraceback (most recent call last):\nFile \"/media/samihaq/Quest2/deepsense-whales/whales/dataloading.py\", line 425, in fetch_example_anno_indygo img = fast_warp(img, AffineTransform(tform_res._inv_matrix), output_shape=(target_h, target_w))\nFile \"/media/samihaq/Quest2/deepsense-whales/augmentation.py\", line 108, in fast_warp m = tf._matrix AttributeError: 'AffineTransform' object has no attribute '_matrix'\n\n/////////////////////////////////////////////////////////////////////////// AffineTransform class is from \"scikit-image\" and indeed it does not have any member \"_matrix\" but the code provided by DeepSense team refers to that.\n\n// function call\n\n    img = fast_warp(img, AffineTransform(tform_res._inv_matrix), output_shape=(target_h, target_w)) \n    \n    // function\n    \n    def fast_warp(img, tf, output_shape=(50, 50), mode='constant', order=1):\n        \"\"\"\n        This wrapper function is faster than skimage.transform.warp\n        \"\"\"\n        m = tf._matrix\n        res = np.zeros(shape=(output_shape[0], output_shape[1], 3), dtype=floatX)\n        from scipy.ndimage import affine_transform\n        trans, offset = m[:2, :2], (m[0, 2], m[1, 2])\n        res[:, :, 0] = affine_transform(img[:, :, 0].T, trans, offset=offset, output_shape=output_shape, mode=mode, order=order)\n        res[:, :, 1] = affine_transform(img[:, :, 1].T, trans, offset=offset, output_shape=output_shape, mode=mode, order=order)\n        res[:, :, 2] = affine_transform(img[:, :, 2].T, trans, offset=offset, output_shape=output_shape, mode=mode, order=order)\n        return res\n\nRegards"
  }
}