Skip to content

Commit

Permalink
add MANIFEST and update README
Browse files Browse the repository at this point in the history
  • Loading branch information
SimJeg committed Oct 3, 2023
1 parent d3e8d29 commit c6f2a5b
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ notebooks/
__pycache__/
*.py[cod]
*$py.class
.vscode

# C extensions
*.so
Expand Down
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include LICENSE
include assets/balaitous.npz
42 changes: 40 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pip install balaitous

Using the command line interface:
```bash
balaitous run path/to/image
balaitous --path path/to/image
````

or using python (recommanded for batch predictions):
Expand All @@ -42,7 +42,7 @@ The input image must be readable using the `SimpleITK.ReadImage` function (*e.g.
`PatientAge` and `PatientSex` metadata keys are automatically parsed from the input image. If not available, age (in years, *e.g.* 65) and sex (1 for male, 0 for female) can be optionnaly passed to Balaitous :

```bash
balaitous run /path/to/image --age age --sex sex
balaitous --path /path/to/image --age age --sex sex
```

or:
Expand All @@ -52,6 +52,44 @@ p_covid, p_severe = model('path/to/image', age=age, sex=sex)

*Note: Balaitous runs much faster on GPU : 2-4 sec/sample on a GPU (NVIDIA GTX 1080Ti) compared to 2-4 min/sample on CPU (Intel i7, 8 cores).*

## Example

The following code runs Balaitous on 2 CT scans from the [MosMed database](https://mosmed.ai/en/datasets/covid191110/)

```python
import requests
import SimpleITK as sitk
import matplotlib.pyplot as plt
from tempfile import NamedTemporaryFile
from balaitous import Balaitous
url1 = "https://zenodo.org/record/8401695/files/covid.nii.gz"
url2 = "https://zenodo.org/record/8401695/files/no_covid.nii.gz"
model = Balaitous()
for i, url in enumerate([url1, url2]):
with NamedTemporaryFile(suffix=".nii.gz") as f:
# Download image
f.write(requests.get(url).content)
# Run inference
p_covid, p_severe = model(f.name)
# Load middle slice
image = sitk.ReadImage(f.name)
image = sitk.GetArrayFromImage(image)
image = image[image.shape[0] // 2][::-1]
# Display image and probabilities
plt.subplot(1, 2, i + 1)
plt.imshow(image, cmap="gray")
plt.axis("off")
plt.title(f"proba covid: {p_covid:.2f}\nproba severe: {p_severe:.2f}")
plt.show()
```
## Model description
<img src="https://github.com/SimJeg/balaitous/blob/master/assets/diagram.png?raw=true">
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
long_description_content_type="text/markdown",
packages=find_packages(),
license ='MIT',
include_package_data=True,
install_requires=[
'numpy',
'SimpleITK',
Expand Down

0 comments on commit c6f2a5b

Please sign in to comment.