Metadata-Version: 2.1
Name: lungs-segmentation
Version: 1.1.1
Summary: High quality model for lungs segmentation.
Home-page: https://github.com/alimbekovKZ/lungs_segmentation/
Author: Renat Alimbekov, Ivan Vassilenko, Abylaikhan Turlassov
License: MIT
Platform: UNKNOWN
Classifier: License :: OSI Approved :: MIT License
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Description-Content-Type: text/markdown
Requires-Dist: albumentations (==0.5.2)
Requires-Dist: numpy (==1.17.4)
Requires-Dist: pandas (==0.25.3)
Requires-Dist: torchvision (==0.8.2)
Requires-Dist: tqdm (==4.40.2)
Requires-Dist: matplotlib (==3.1.3)
Requires-Dist: typing (==3.6.4)
Requires-Dist: joblib (==0.13.2)
Requires-Dist: opencv-python (==4.2.0.34)
Requires-Dist: setuptools (==49.2.0)
Requires-Dist: torch (==1.7.1)
Requires-Dist: imageio (==2.9.0)
Provides-Extra: test
Requires-Dist: pytest; extra == 'test'

# lungs_segmentation
Automated lung segmentation in chest-x ray 

![https://habrastorage.org/webt/vk/jv/8r/vkjv8rjd04f1oicbczq5hyadhv0.png](https://habrastorage.org/webt/vk/jv/8r/vkjv8rjd04f1oicbczq5hyadhv0.png)

## Installation

`pip install lungs-segmentation`

### Example inference

Jupyter notebook with the example: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1hNNl-tHipIBGmtexU2BH8qC80-QxXFZt?usp=sharing)

### WebApp

Comming soon ...

### Models weights

| model | best dice | Mb |
|-------|-----------|----|
|   resnet34    | 0.9657          |  103.4  |
|   densenet121    |  0.9655         |   62.8 |

### Usage

Code example for resnet34:

```
from lungs_segmentation.pre_trained_models import create_model
import lungs_segmentation.inference as inference

model = create_model("resnet34")
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
model = model.to(device)

plt.figure(figsize=(20,40))
plt.subplot(1,1,1)
image, mask = inference.inference(model,'739px-Chest_Xray_PA_3-8-2010.png', 0.2)
plt.imshow(inference.img_with_masks( image, [mask[0], mask[1]], alpha = 0.1))
```


### Results on data from the Internet

#### resnet34

![https://habrastorage.org/webt/e3/mb/kc/e3mbkcxsmos6q4jlw5-tybudzji.png](https://habrastorage.org/webt/e3/mb/kc/e3mbkcxsmos6q4jlw5-tybudzji.png)

#### densenet121

![https://habrastorage.org/webt/ef/01/zo/ef01zo2g2qgsux8ses4keg4g8is.png](https://habrastorage.org/webt/ef/01/zo/ef01zo2g2qgsux8ses4keg4g8is.png)

### Authors

![Renat Alimbekov](https://alimbekov.com)

![Ivan Vassilenko](https://www.linkedin.com/in/ivannvassilenko/)

![Abylaikhan Turlassov](https://www.linkedin.com/in/abylaikhan-turlassov-2727b2196/)


