{ "info": { "author": "Karol Zak", "author_email": "karol.zak@hotmail.com", "bugtrack_url": null, "classifiers": [], "description": "# About\nHelper package with multiple U-Net implementations in Keras as well as useful utility tools helpful when working with image segmentation tasks\n\n# Features: \n- [x] U-Net models implemented in Keras \n - [x] Vanilla U-Net implementation based on [the original paper](https://arxiv.org/pdf/1505.04597.pdf)\n - [x] Customizable U-Net\n - [x] U-Net optimized for satellite images based on [DeepSense.AI Kaggle competition entry](https://deepsense.ai/deep-learning-for-satellite-imagery-via-image-segmentation/)\n- [x] Utility functions:\n - [x] Plotting images and masks with overlay\n - [x] Plotting images masks and predictions with overlay (prediction on top of original image)\n - [x] Plotting training history for metrics and losses\n - [x] Cropping smaller patches out of bigger image (e.g. satellite imagery) using sliding window technique (also with overlap if needed)\n - [x] Plotting smaller patches to visualize the cropped big image\n - [x] Reconstructing smaller patches back to a big image\n - [x] Data augmentation helper function\n- [x] Notebooks (examples):\n - [x] Training custom U-Net for whale tails segmentation\n - [ ] Semantic segmentation for satellite images\n - [x] Semantic segmentation for medical images [ISBI challenge 2015](https://biomedicalimaging.org/2015/program/isbi-challenges/)\n\n# Installation:\n```bash\npip install git+https://github.com/karolzak/keras-unet\n```\nor\n```bash\npip install keras-unet\n```\n\n# Usage examples:\n\n- U-Net implementations in Keras: \n - [Vanilla U-Net](#Vanilla-U-Net) \n - [Customizable U-Net](#Customizable-U-Net) \n - [U-Net for satellite images](#U-Net-for-satellite-images) \n- Utils:\n - [Plot training history](#Plot-training-history) \n - [Plot images and segmentation masks](#Plot-images-and-segmentation-masks) \n - [Get smaller patches/crops from bigger image](#Get-smaller-patches/crops-from-bigger-image) \n - [Plot small patches into single big image](#Plot-small-patches-into-single-big-image) \n - [Reconstruct a bigger image from smaller patches/crops](#Reconstruct-a-bigger-image-from-smaller-patches/crops)\n
\n\n### Vanilla U-Net\n\n[Model scheme can be viewed here](docs/vanilla_unet.png)\n\n```python\nfrom keras_unet.models import vanilla_unet\n\nmodel = vanilla_unet(input_shape=(512, 512, 3))\n```\n\n[[back to usage examples]](#usage-examples)\n\n
\n\n### Customizable U-Net \n\n[Model scheme can be viewed here](docs/custom_unet.png)\n\n```python\nfrom keras_unet.models import custom_unet\n\nmodel = custom_unet(\n input_shape=(512, 512, 3),\n use_batch_norm=False,\n num_classes=1,\n filters=64,\n dropout=0.2,\n output_activation='sigmoid')\n```\n\n\n[[back to usage examples]](#usage-examples)\n\n
\n\n### U-Net for satellite images\n[Model scheme can be viewed here](docs/satellite_unet.png)\n\n```python\nfrom keras_unet.models import satellite_unet\n\nmodel = satellite_unet(input_shape=(512, 512, 3))\n```\n\n\n[[back to usage examples]](#usage-examples)\n\n
\n\n### Plot training history \n\n```python\nhistory = model.fit_generator(...)\n\nfrom keras_unet.utils import plot_segm_history\n\nplot_segm_history(\n history, # required - keras training history object\n metrics=['iou', 'val_iou'], # optional - metrics names to plot\n losses=['loss', 'val_loss']) # optional - loss names to plot\n```\n\nOutput: \n![metric history](docs/metric_history.png)\n![loss history](docs/loss_history.png)\n\n[[back to usage examples]](#usage-examples)\n\n
\n\n### Plot images and segmentation masks\n\n```python\nfrom keras_unet.utils import plot_imgs\n\nplot_imgs(\n org_imgs=x_val, # required - original images\n mask_imgs=y_val, # required - ground truth masks\n pred_imgs=y_pred, # optional - predicted masks\n nm_img_to_plot=9) # optional - number of images to plot\n```\n\nOutput: \n![plotted images, masks and predictions](docs/plotted_imgs.png)\n\n\n[[back to usage examples]](#usage-examples)\n\n
\n\n### Get smaller patches/crops from bigger image\n\n```python\nfrom PIL import Image\nimport numpy as np\nfrom keras_unet.utils import get_patches\n\nx = np.array(Image.open(\"../docs/sat_image_1.jpg\"))\nprint(\"x shape: \", str(x.shape))\n\nx_crops = get_patches(\n img_arr=x, # required - array of images to be cropped\n size=100, # default is 256\n stride=100) # default is 256\n\nprint(\"x_crops shape: \", str(x_crops.shape))\n```\n\nOutput:\n```output\nx shape: (1000, 1000, 3) \nx_crops shape: (100, 100, 100, 3)\n```\n\n\n[[back to usage examples]](#usage-examples)\n\n
\n\n### Plot small patches into single big image\n\n```python\nfrom keras_unet.utils import plot_patches\n\nprint(\"x_crops shape: \", str(x_crops.shape)) \nplot_patches(\n img_arr=x_crops, # required - array of cropped out images\n org_img_size=(1000, 1000), # required - original size of the image\n stride=100) # use only if stride is different from patch size\n```\n\nOutput: \n```output\nx_crops shape: (100, 100, 100, 3)\n```\n![plotted patches](docs/plotted_patches.png)\n\n[[back to usage examples]](#usage-examples)\n\n
\n\n### Reconstruct a bigger image from smaller patches/crops \n\n```python\nimport matplotlib.pyplot as plt\nfrom keras_unet.utils import reconstruct_from_patches\n\nprint(\"x_crops shape: \", str(x_crops.shape))\n\nx_reconstructed = reconstruct_from_patches(\n img_arr=x_crops, # required - array of cropped out images\n org_img_size=(1000, 1000), # required - original size of the image\n stride=100) # use only if stride is different from patch size\n\nprint(\"x_reconstructed shape: \", str(x_reconstructed.shape))\n\nplt.figure(figsize=(10,10))\nplt.imshow(x_reconstructed[0])\nplt.show()\n```\nOutput: \n```output\nx_crops shape: (100, 100, 100, 3)\nx_reconstructed shape: (1, 1000, 1000, 3)\n```\n![reconstructed image](docs/reconstructed_image.png)\n\n[[back to usage examples]](#usage-examples)\n\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/karolzak/keras-unet", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "keras-unet", "package_url": "https://pypi.org/project/keras-unet/", "platform": "", "project_url": "https://pypi.org/project/keras-unet/", "project_urls": { "Homepage": "http://github.com/karolzak/keras-unet" }, "release_url": "https://pypi.org/project/keras-unet/0.0.7/", "requires_dist": [ "keras" ], "requires_python": "", "summary": "Helper package with multiple U-Net implementations in Keras as well as useful utility tools helpful when working with image segmentation tasks", "version": "0.0.7" }, "last_serial": 5739334, "releases": { "0.0.5": [ { "comment_text": "", "digests": { "md5": "2f986c1c42b1a353a7815d5d2ff6842e", "sha256": "86aaa36f6e734b3432dfada87608f9f23099e7e0f7f669a334f87f1220489fd3" }, "downloads": -1, "filename": "keras_unet-0.0.5-py3-none-any.whl", "has_sig": false, "md5_digest": "2f986c1c42b1a353a7815d5d2ff6842e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9795, "upload_time": "2019-05-31T09:45:34", "url": "https://files.pythonhosted.org/packages/9c/b6/ad1f8723b140f5de0c56b299c469f3a3304cac4982a74dab70088d6b9558/keras_unet-0.0.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1993291aa6efa136ea6bd43a3388232b", "sha256": "7834c0ce75f366c7760cf726cc6c0c2fd09a99f2367070049b04509e084bb12b" }, "downloads": -1, "filename": "keras-unet-0.0.5.tar.gz", "has_sig": false, "md5_digest": "1993291aa6efa136ea6bd43a3388232b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6717, "upload_time": "2019-05-31T09:45:35", "url": "https://files.pythonhosted.org/packages/a5/70/d64a3bb64eae255c51585a6d8a02e2dc1b149180afb0a29442f6cd54900f/keras-unet-0.0.5.tar.gz" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "50c86b6d126e45a0750dbeace405fe04", "sha256": "f895538a3507e3200b7f94046606bb014a7c82eff4bbbc36c47a449edaadc29f" }, "downloads": -1, "filename": "keras_unet-0.0.6-py3-none-any.whl", "has_sig": false, "md5_digest": "50c86b6d126e45a0750dbeace405fe04", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10273, "upload_time": "2019-06-11T20:44:41", "url": "https://files.pythonhosted.org/packages/4d/3d/265ee8a955421291e80bc30077464b97f7ad8fa405d758dd3df9f8720e15/keras_unet-0.0.6-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "681b8ceb729ab534b9a9603f91da57a7", "sha256": "3755ab7a4214e5c9ad7f208adcb05b7a0d7b97b34d28d5b2b3350d42d261ff8f" }, "downloads": -1, "filename": "keras-unet-0.0.6.tar.gz", "has_sig": false, "md5_digest": "681b8ceb729ab534b9a9603f91da57a7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8355, "upload_time": "2019-06-11T20:44:43", "url": "https://files.pythonhosted.org/packages/19/94/2b318e22471ba59eff2aad720a2a4cafa22fc9a95fd1c7153d70d0ae02f9/keras-unet-0.0.6.tar.gz" } ], "0.0.7": [ { "comment_text": "", "digests": { "md5": "85b5cf9b56ffd388a1ea6b9403de582d", "sha256": "474ba39c8776c443112ef781d69f89cb1eaafddc7e2bad9776eca6e9075fb3c9" }, "downloads": -1, "filename": "keras_unet-0.0.7-py3-none-any.whl", "has_sig": false, "md5_digest": "85b5cf9b56ffd388a1ea6b9403de582d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11933, "upload_time": "2019-08-27T20:18:49", "url": "https://files.pythonhosted.org/packages/e8/6a/06806e2a778e793e8023316a235ab1fd6c4642cca3a1f81dfa617d48c0f8/keras_unet-0.0.7-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "36ebfbf61a726b0db57daffa280a65a9", "sha256": "0f06b2c51f889081f62e17021794e9301ec43f1cedbc1da41545d17e282b199a" }, "downloads": -1, "filename": "keras-unet-0.0.7.tar.gz", "has_sig": false, "md5_digest": "36ebfbf61a726b0db57daffa280a65a9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8825, "upload_time": "2019-08-27T20:18:51", "url": "https://files.pythonhosted.org/packages/18/65/cea0a016f1c659c8513135fac3db3a1c0f8f9db59dff26c28402249bae03/keras-unet-0.0.7.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "85b5cf9b56ffd388a1ea6b9403de582d", "sha256": "474ba39c8776c443112ef781d69f89cb1eaafddc7e2bad9776eca6e9075fb3c9" }, "downloads": -1, "filename": "keras_unet-0.0.7-py3-none-any.whl", "has_sig": false, "md5_digest": "85b5cf9b56ffd388a1ea6b9403de582d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11933, "upload_time": "2019-08-27T20:18:49", "url": "https://files.pythonhosted.org/packages/e8/6a/06806e2a778e793e8023316a235ab1fd6c4642cca3a1f81dfa617d48c0f8/keras_unet-0.0.7-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "36ebfbf61a726b0db57daffa280a65a9", "sha256": "0f06b2c51f889081f62e17021794e9301ec43f1cedbc1da41545d17e282b199a" }, "downloads": -1, "filename": "keras-unet-0.0.7.tar.gz", "has_sig": false, "md5_digest": "36ebfbf61a726b0db57daffa280a65a9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8825, "upload_time": "2019-08-27T20:18:51", "url": "https://files.pythonhosted.org/packages/18/65/cea0a016f1c659c8513135fac3db3a1c0f8f9db59dff26c28402249bae03/keras-unet-0.0.7.tar.gz" } ] }