{
  "id": 340052,
  "title": "Process images with `pyvips` package and handle the memory limitation issue",
  "url": "/competitions/mayo-clinic-strip-ai/discussion/340052",
  "author_name": "xxxxyyyy80008",
  "post_date": "2022-07-27T10:27:42.943000",
  "votes": 10,
  "comment_count": 1,
  "views": 0,
  "content": "<p>When using <code>Pillow</code> package to read and process (mostly resizing) images, 2 big files (1 in train folder and 1 in other folder) can trigger the message that tells you the notebook is trying to allocate more memory than what's available (i.e. 16GB) and the notebooks restarts. </p>\n<p>This notebook <a href=\"https://www.kaggle.com/code/jirkaborovec/bloodclots-eda-load-wsi-prune-background?scriptVersionId=101797769\" target=\"_blank\">BloodClots🔬: EDA🔎 &amp; load WSI + prune background</a> provided a solution to avoid the <strong>out of memory</strong> issue using <code>pyvips</code> package. (scroll to the bottom of this notebook where you can see image processing scripts)</p>\n<p>Compared to <code>PIL</code> (pillow package), <code>pyvips</code> package has its own limitations such as not providing sampling options in its <code>resize</code> and <code>thumbnail</code> functions. </p>\n<p>Since Kaggle notebook environment does not come with <code>pyvips</code>, you have to install it yourself. Installing the <code>pyvips</code> package can be a bit troublesome to make it work in the submission notebook when the internet has to be set <em>offline</em>.</p>\n<p>Fortunately, this amazing notebook tells you how to install the package hassle free: <a href=\"https://www.kaggle.com/code/analokamus/how-to-use-pyvips-offline\" target=\"_blank\">How to use pyvips offline</a>. In fact, you can use this notebook directly by following these steps:</p>\n<ul>\n<li>click <code>+ Add data</code>  button on the upper right corner of your submission notebook</li>\n<li>click on <code>Notebook Output Files</code></li>\n<li>enter <code>pyvips</code> in the search box and click search</li>\n<li>you will see that <strong>How to use pyvips offline</strong> notebook on the top of the list, click <code>Add</code></li>\n<li>copy <code>!conda install /kaggle/input/how-to-use-pyvips-offline/*.tar.bz2</code> to a cell and run it</li>\n<li>now you can run <code>import pyvips</code> to import the package</li>\n</ul>",
  "messages": [
    {
      "id": 1872929,
      "postDate": "2022-07-27T10:27:42.943Z",
      "content": "<p>When using <code>Pillow</code> package to read and process (mostly resizing) images, 2 big files (1 in train folder and 1 in other folder) can trigger the message that tells you the notebook is trying to allocate more memory than what's available (i.e. 16GB) and the notebooks restarts. </p>\n<p>This notebook <a href=\"https://www.kaggle.com/code/jirkaborovec/bloodclots-eda-load-wsi-prune-background?scriptVersionId=101797769\" target=\"_blank\">BloodClots🔬: EDA🔎 &amp; load WSI + prune background</a> provided a solution to avoid the <strong>out of memory</strong> issue using <code>pyvips</code> package. (scroll to the bottom of this notebook where you can see image processing scripts)</p>\n<p>Compared to <code>PIL</code> (pillow package), <code>pyvips</code> package has its own limitations such as not providing sampling options in its <code>resize</code> and <code>thumbnail</code> functions. </p>\n<p>Since Kaggle notebook environment does not come with <code>pyvips</code>, you have to install it yourself. Installing the <code>pyvips</code> package can be a bit troublesome to make it work in the submission notebook when the internet has to be set <em>offline</em>.</p>\n<p>Fortunately, this amazing notebook tells you how to install the package hassle free: <a href=\"https://www.kaggle.com/code/analokamus/how-to-use-pyvips-offline\" target=\"_blank\">How to use pyvips offline</a>. In fact, you can use this notebook directly by following these steps:</p>\n<ul>\n<li>click <code>+ Add data</code>  button on the upper right corner of your submission notebook</li>\n<li>click on <code>Notebook Output Files</code></li>\n<li>enter <code>pyvips</code> in the search box and click search</li>\n<li>you will see that <strong>How to use pyvips offline</strong> notebook on the top of the list, click <code>Add</code></li>\n<li>copy <code>!conda install /kaggle/input/how-to-use-pyvips-offline/*.tar.bz2</code> to a cell and run it</li>\n<li>now you can run <code>import pyvips</code> to import the package</li>\n</ul>",
      "rawMarkdown": "When using `Pillow` package to read and process (mostly resizing) images, 2 big files (1 in train folder and 1 in other folder) can trigger the message that tells you the notebook is trying to allocate more memory than what's available (i.e. 16GB) and the notebooks restarts. \n\nThis notebook [BloodClots🔬: EDA🔎 & load WSI + prune background](https://www.kaggle.com/code/jirkaborovec/bloodclots-eda-load-wsi-prune-background?scriptVersionId=101797769) provided a solution to avoid the **out of memory** issue using `pyvips` package. (scroll to the bottom of this notebook where you can see image processing scripts)\n\nCompared to `PIL` (pillow package), `pyvips` package has its own limitations such as not providing sampling options in its `resize` and `thumbnail` functions. \n\n\nSince Kaggle notebook environment does not come with `pyvips`, you have to install it yourself. Installing the `pyvips` package can be a bit troublesome to make it work in the submission notebook when the internet has to be set *offline*.\n\nFortunately, this amazing notebook tells you how to install the package hassle free: [How to use pyvips offline](https://www.kaggle.com/code/analokamus/how-to-use-pyvips-offline). In fact, you can use this notebook directly by following these steps:\n - click `+ Add data`  button on the upper right corner of your submission notebook\n - click on `Notebook Output Files`\n - enter `pyvips` in the search box and click search\n - you will see that **How to use pyvips offline** notebook on the top of the list, click `Add`\n - copy `!conda install /kaggle/input/how-to-use-pyvips-offline/*.tar.bz2` to a cell and run it\n - now you can run `import pyvips` to import the package\n",
      "votes": 9
    },
    {
      "id": 1873535,
      "postDate": "2022-07-27T16:49:31.043Z",
      "content": "<p>Thanks for the information, this is a highly useful post for almost all image based assignments here and at work as well!</p>",
      "rawMarkdown": "Thanks for the information, this is a highly useful post for almost all image based assignments here and at work as well!"
    }
  ],
  "comments": [
    {
      "id": 1873535,
      "author_name": "Ravi Ramakrishnan",
      "author_url": "",
      "post_date": "2022-07-27T16:49:31.043000",
      "content": "<p>Thanks for the information, this is a highly useful post for almost all image based assignments here and at work as well!</p>",
      "votes": 0,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1872929": "When using `Pillow` package to read and process (mostly resizing) images, 2 big files (1 in train folder and 1 in other folder) can trigger the message that tells you the notebook is trying to allocate more memory than what's available (i.e. 16GB) and the notebooks restarts. \n\nThis notebook [BloodClots🔬: EDA🔎 & load WSI + prune background](https://www.kaggle.com/code/jirkaborovec/bloodclots-eda-load-wsi-prune-background?scriptVersionId=101797769) provided a solution to avoid the **out of memory** issue using `pyvips` package. (scroll to the bottom of this notebook where you can see image processing scripts)\n\nCompared to `PIL` (pillow package), `pyvips` package has its own limitations such as not providing sampling options in its `resize` and `thumbnail` functions. \n\n\nSince Kaggle notebook environment does not come with `pyvips`, you have to install it yourself. Installing the `pyvips` package can be a bit troublesome to make it work in the submission notebook when the internet has to be set *offline*.\n\nFortunately, this amazing notebook tells you how to install the package hassle free: [How to use pyvips offline](https://www.kaggle.com/code/analokamus/how-to-use-pyvips-offline). In fact, you can use this notebook directly by following these steps:\n - click `+ Add data`  button on the upper right corner of your submission notebook\n - click on `Notebook Output Files`\n - enter `pyvips` in the search box and click search\n - you will see that **How to use pyvips offline** notebook on the top of the list, click `Add`\n - copy `!conda install /kaggle/input/how-to-use-pyvips-offline/*.tar.bz2` to a cell and run it\n - now you can run `import pyvips` to import the package\n",
    "1873535": "Thanks for the information, this is a highly useful post for almost all image based assignments here and at work as well!"
  }
}