{
  "id": 13082,
  "title": "Loading images for nolearn/lasagne?",
  "url": "/competitions/datasciencebowl/discussion/13082",
  "author_name": "",
  "post_date": "2015-03-26T14:08:24.453Z",
  "votes": 1,
  "comment_count": 1,
  "views": 1879,
  "content": "<p>This is probably a very basic thing and I should be able to figure it out but I feel like I'm missing something. Following the convnet tutorial on deeplearning.net I see the following steps using PIL for an rgb jpeg of size 256x256:</p>\n<p><code>images = np.empty(num_images, dtype = 'object')</code></p>\n<p><code></code><code>i = 0</code></p>\n<p><code>for files&nbsp;in directory:</code></p>\n<p><code>&nbsp; &nbsp; img = Image.open('file')</code></p>\n<p><code></code><code>&nbsp; &nbsp; img = np.asarray(img, dtype = 'float64') / 255.</code></p>\n<p><code>&nbsp; &nbsp; img = img.transpose(2,0,1).reshape(3, 256, 256)</code></p>\n<p><code>&nbsp; &nbsp; images[i] = img</code></p>\n<p><code>&nbsp; &nbsp; i += 1</code></p>\n<p>Would that then put the image into the correct format for nolearn/lasagne if I specify the input like this?</p>\n<p><code>input_shape=(None, 3, 256, 256),</code></p>\n<p>I'm sorry if this is a very basic question but any help would be greatly appreciated.&nbsp;</p>",
  "messages": [
    {
      "id": "68425",
      "postDate": "03/26/2015 14:08:24",
      "content": "<p>This is probably a very basic thing and I should be able to figure it out but I feel like I'm missing something. Following the convnet tutorial on deeplearning.net I see the following steps using PIL for an rgb jpeg of size 256x256:</p>\n<p><code>images = np.empty(num_images, dtype = 'object')</code></p>\n<p><code></code><code>i = 0</code></p>\n<p><code>for files&nbsp;in directory:</code></p>\n<p><code>&nbsp; &nbsp; img = Image.open('file')</code></p>\n<p><code></code><code>&nbsp; &nbsp; img = np.asarray(img, dtype = 'float64') / 255.</code></p>\n<p><code>&nbsp; &nbsp; img = img.transpose(2,0,1).reshape(3, 256, 256)</code></p>\n<p><code>&nbsp; &nbsp; images[i] = img</code></p>\n<p><code>&nbsp; &nbsp; i += 1</code></p>\n<p>Would that then put the image into the correct format for nolearn/lasagne if I specify the input like this?</p>\n<p><code>input_shape=(None, 3, 256, 256),</code></p>\n<p>I'm sorry if this is a very basic question but any help would be greatly appreciated.&nbsp;</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "69123",
      "postDate": "03/31/2015 05:34:08",
      "content": "<p>This is what I did when I use nolearn.</p>",
      "rawMarkdown": "",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 69123,
      "author_name": "pengpai",
      "author_url": "",
      "post_date": "03/31/2015 05:34:08",
      "content": "<p>This is what I did when I use nolearn.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "68425": "",
    "69123": ""
  },
  "source": "meta"
}