{
  "id": 398013,
  "title": "any suggestions about the memory explosion caused by torch.stack?",
  "url": "/competitions/vesuvius-challenge-ink-detection/discussion/398013",
  "author_name": "YOYOYOYO1995",
  "post_date": "2023-03-28T07:47:27.286000",
  "votes": 2,
  "comment_count": 1,
  "views": 0,
  "content": "<p>my code:</p>\n<p>I tried to stack \"z_slices\" which is a list containing [50 * 2D resized images] loaded from test/a/surface_volume.<br>\nwhile I loaded \" test/b/surface_volume\" or any folder in the training dataset is totally okay.<br>\ncan anyone help??</p>\n<pre><code>    for z, filename in tqdm(enumerate(z_slices_fnames),desc='load_volume-&gt;'+f\"{DATA_DIR}/{split}/{index}/surface_volume\"):\n        img = Image.open(filename)\n        img = resize(img)\n        z_slice = np.array(img, dtype=\"float32\")\n        z_slices.append(torch.from_numpy(z_slice)\n    return  torch.stack(z_slices, dim=0)\n</code></pre>",
  "messages": [
    {
      "id": 2200007,
      "postDate": "2023-03-28T07:47:27.287Z",
      "content": "<p>my code:</p>\n<p>I tried to stack \"z_slices\" which is a list containing [50 * 2D resized images] loaded from test/a/surface_volume.<br>\nwhile I loaded \" test/b/surface_volume\" or any folder in the training dataset is totally okay.<br>\ncan anyone help??</p>\n<pre><code>    for z, filename in tqdm(enumerate(z_slices_fnames),desc='load_volume-&gt;'+f\"{DATA_DIR}/{split}/{index}/surface_volume\"):\n        img = Image.open(filename)\n        img = resize(img)\n        z_slice = np.array(img, dtype=\"float32\")\n        z_slices.append(torch.from_numpy(z_slice)\n    return  torch.stack(z_slices, dim=0)\n</code></pre>",
      "rawMarkdown": "my code:\n\nI tried to stack \"z_slices\" which is a list containing [50 * 2D resized images] loaded from test/a/surface_volume.\nwhile I loaded \" test/b/surface_volume\" or any folder in the training dataset is totally okay.\ncan anyone help??\n\n        for z, filename in tqdm(enumerate(z_slices_fnames),desc='load_volume->'+f\"{DATA_DIR}/{split}/{index}/surface_volume\"):\n            img = Image.open(filename)\n            img = resize(img)\n            z_slice = np.array(img, dtype=\"float32\")\n            z_slices.append(torch.from_numpy(z_slice)\n        return  torch.stack(z_slices, dim=0)",
      "votes": 2
    },
    {
      "id": 2205934,
      "postDate": "2023-04-02T05:40:39.283Z",
      "rawMarkdown": "",
      "isDeleted": true
    }
  ],
  "comments": [
    {
      "id": 2205934,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-04-02T05:40:39.283000",
      "content": "",
      "votes": 0,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "2200007": "my code:\n\nI tried to stack \"z_slices\" which is a list containing [50 * 2D resized images] loaded from test/a/surface_volume.\nwhile I loaded \" test/b/surface_volume\" or any folder in the training dataset is totally okay.\ncan anyone help??\n\n        for z, filename in tqdm(enumerate(z_slices_fnames),desc='load_volume->'+f\"{DATA_DIR}/{split}/{index}/surface_volume\"):\n            img = Image.open(filename)\n            img = resize(img)\n            z_slice = np.array(img, dtype=\"float32\")\n            z_slices.append(torch.from_numpy(z_slice)\n        return  torch.stack(z_slices, dim=0)",
    "2205934": ""
  }
}