Skip to content

Commit 7787099

Browse files
authored
Merge pull request #38 from DataScientest-Studio/develop
Develop
2 parents 4e618d5 + b160cda commit 7787099

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+2381
-215
lines changed

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ __pycache__/
55

66
# C extensions
77
*.so
8-
98
# Distribution / packaging
109
.Python
1110
build/
@@ -165,5 +164,5 @@ cython_debug/
165164
data/raw/*
166165
data/processed/*
167166

168-
# models folder
169-
models/*
167+
# weights for del model
168+
src/streamlit/models/model_densenet_masked.weights.h5

README.md

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,39 @@
1-
Project Name
1+
Data Science Project: COVID Lung X-Rays Classification
22
==============================
33

4-
This repo is a Starting Pack for DS projects. You can rearrange the structure to make it fits your project.
4+
View the streamlit app on [Huggingface](https://huggingface.co/spaces/fdayde/streamlit-dl-radio) 🤗
55

6+
------------
7+
This project was made during the Data Scientist course of [Datascientest](https://datascientest.com/), and uses the COVID-QU-Ex dataset available on Kaggle: https://www.kaggle.com/datasets/anasmohammedtahir/covidqu
8+
9+
10+
[1] A. M. Tahir, M. E. H. Chowdhury, A. Khandakar, Y. Qiblawey, U. Khurshid, S. Kiranyaz, N. Ibtehaz, M. S. Rahman, S. Al-Madeed, S. Mahmud, M. Ezeddin, K. Hameed, and T. Hamid, “COVID-19 Infection Localization and Severity Grading from Chest X-ray Images”, Computers in Biology and Medicine, vol. 139, p. 105002, 2021, https://doi.org/10.1016/j.compbiomed.2021.105002.
11+
[2] Anas M. Tahir, Muhammad E. H. Chowdhury, Yazan Qiblawey, Amith Khandakar, Tawsifur Rahman, Serkan Kiranyaz, Uzair Khurshid, Nabil Ibtehaz, Sakib Mahmud, and Maymouna Ezeddin, “COVID-QU-Ex .” Kaggle, 2021, https://doi.org/10.34740/kaggle/dsv/3122958.
12+
[3] T. Rahman, A. Khandakar, Y. Qiblawey A. Tahir S. Kiranyaz, S. Abul Kashem, M. Islam, S. Al Maadeed, S. Zughaier, M. Khan, M. Chowdhury, "Exploring the Effect of Image Enhancement Techniques on COVID-19 Detection using Chest X-rays Images," Computers in Biology and Medicine, p. 104319, 2021, https://doi.org/10.1016/j.compbiomed.2021.104319.
13+
[4] A. Degerli, M. Ahishali, M. Yamac, S. Kiranyaz, M. E. H. Chowdhury, K. Hameed, T. Hamid, R. Mazhar, and M. Gabbouj, "Covid-19 infection map generation and detection from chest X-ray images," Health Inf Sci Syst 9, 15 (2021), https://doi.org/10.1007/s13755-021-00146-8.
14+
[5] M. E. H. Chowdhury, T. Rahman, A. Khandakar, R. Mazhar, M. A. Kadir, Z. B. Mahbub, K. R. Islam, M. S. Khan, A. Iqbal, N. A. Emadi, M. B. I. Reaz, M. T. Islam, "Can AI Help in Screening Viral and COVID-19 Pneumonia?," IEEE Access, vol. 8, pp. 132665-132676, 2020, https://doi.org/10.1109/ACCESS.2020.3010287.
15+
16+
------------
17+
Team:
18+
- Thomas Baret [linkedin](https://linkedin.com/in/thomas-baret-080050107) [github](https://github.com/tom-b974)
19+
- Nicolas Bouzinbi [linkedin](https://linkedin.com/in/nicolas-bouzinbi-7916481b4) [github](https://github.com/NicolasBouzinbi)
20+
- Florent Daydé [linkedin](https://linkedin.com/in/florent-daydé-16431469) [github](https://github.com/fdayde)
21+
- Nicolas Fenassile [linkedin](https://linkedin.com/in/nicolasfenassile) [github](https://github.com/NicoFena)
22+
23+
supervised by: Gaël Penessot
24+
25+
------------
26+
How to deploy the streamlit app on Huggingface:
27+
28+
- Create a new space on Huggingface and clone the repository
29+
- Push the content of the `src/streamlit` directory
30+
- Add the model's weights file to the `models` folder
31+
- Store the model weights in Git LFS by adding the following line to the `.gitattributes` file:
32+
```*.h5 filter=lfs diff=lfs merge=lfs -text```
33+
- Push to Huggingface
34+
- Do not modify or delete the `REAMDE.md` file created by Huggingface during the initialization on the space.
35+
36+
------------
637
Project Organization
738
------------
839

@@ -12,16 +43,17 @@ Project Organization
1243
│   ├── processed <- The final, canonical data sets for modeling.
1344
│   └── raw <- The original, immutable data dump.
1445
15-
├── models <- Trained and serialized models, model predictions, or model summaries
46+
├── demo <- Samples from the dataset for demonstration in streamlit
47+
48+
├── models <- Trained and serialized models, model predictions, or model summaries, not on Github for size reasons
1649
1750
├── notebooks <- Jupyter notebooks. Naming convention is a number (for ordering),
1851
│ the creator's name, and a short `-` delimited description, e.g.
1952
│ `1.0-alban-data-exploration`.
2053
21-
├── references <- Data dictionaries, manuals, links, and all other explanatory materials.
2254
23-
├── reports <- The reports that you'll make during this project as PDF
24-
   └── figures <- Generated graphics and figures to be used in reporting
55+
├── reports <- The final report made during this project (PDF)
56+
2557
2658
├── requirements.txt <- The requirements file for reproducing the analysis environment, e.g.
2759
│ generated with `pip freeze > requirements.txt`
@@ -36,6 +68,8 @@ Project Organization
3668
│ │ │ predictions
3769
│   │   ├── predict_model.py
3870
│   │   └── train_model.py
71+
│ │
72+
│ │── streamlit <- Scripts for the Streamlit app
3973
│ │
4074
│   ├── visualization <- Scripts to create exploratory and results oriented visualizations
4175
│   │ └── visualize.py

demo/Normal (14).png

37.6 KB
Loading

demo/Normal (24).png

66.8 KB
Loading

demo/covid_24.png

64.3 KB
Loading

demo/covid_74.png

25.9 KB
Loading

demo/non_COVID (334).png

29 KB
Loading

demo/non_COVID (9986).png

51.4 KB
Loading

notebooks/02_nf_Preprocessing.ipynb

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,89 @@
245245
"normalization_HistEgal(normal_path)"
246246
]
247247
},
248+
{
249+
"cell_type": "code",
250+
"execution_count": 3,
251+
"metadata": {},
252+
"outputs": [],
253+
"source": [
254+
"def apply_clahe_normalization(img):\n",
255+
" \"\"\"\n",
256+
" Apply CLAHE normalization to an input image.\n",
257+
"\n",
258+
" Args:\n",
259+
" img (numpy.ndarray): Input image, either in grayscale or RGB format.\n",
260+
"\n",
261+
" Returns:\n",
262+
" numpy.ndarray: CLAHE normalized image.\n",
263+
"\n",
264+
" Raises:\n",
265+
" ValueError: If the input image is None or not a valid image.\n",
266+
" \"\"\"\n",
267+
" if img is None:\n",
268+
" raise ValueError(\"No image data received!\")\n",
269+
"\n",
270+
" if not isinstance(img, np.ndarray):\n",
271+
" raise ValueError(\"Input must be a numpy.ndarray\")\n",
272+
"\n",
273+
" # Convert image to grayscale if it's not already\n",
274+
" if len(img.shape) == 3 and img.shape[2] == 3: # RGB image\n",
275+
" img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)\n",
276+
" elif len(img.shape) != 2: # Not a grayscale or RGB image\n",
277+
" raise ValueError(\"Input image must be either grayscale or RGB\")\n",
278+
"\n",
279+
" # Ensure image is of type uint8 (required for CLAHE)\n",
280+
" if img.dtype != np.uint8:\n",
281+
" img = img.astype('uint8')\n",
282+
"\n",
283+
" # Apply CLAHE transformation\n",
284+
" clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8, 8))\n",
285+
" img = clahe.apply(img)\n",
286+
"\n",
287+
" return img\n",
288+
"\n",
289+
"def normalization_CLAHE(path):\n",
290+
" '''Cette fonction crée un nouveau dossier nommé \"CLAHE images\", et y stocke toutes les images après CLAHE'''\n",
291+
"\n",
292+
" CLAHE_images = \"CLAHE images\"\n",
293+
" CLAHE_images_path = os.path.join(path, CLAHE_images)\n",
294+
"\n",
295+
" if not os.path.exists(CLAHE_images_path):\n",
296+
" os.mkdir(CLAHE_images_path) # Création du nouveau dossier pour stocker la normalisation si il n'existe pas déjà\n",
297+
" else :\n",
298+
" print(\"Le dossier existe déjà, rien n'a été fait\")\n",
299+
" return\n",
300+
"\n",
301+
" images_path = os.path.join(path, \"images\") # Chemin vers le dossier contenant les images\n",
302+
"\n",
303+
" for image in os.listdir(images_path):\n",
304+
" image_path = os.path.join(images_path, image) # Chemin de l'image\n",
305+
" image_read = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE)\n",
306+
" normalized_image = apply_clahe_normalization(image_read) # On crée l'image normalisée\n",
307+
" normalized_image_path = os.path.join(CLAHE_images_path, image) # On récupère le chemin de l'image\n",
308+
"\n",
309+
" cv2.imwrite(normalized_image_path, normalized_image) # On met l'image dans le nouveau dossier"
310+
]
311+
},
312+
{
313+
"cell_type": "code",
314+
"execution_count": 4,
315+
"metadata": {},
316+
"outputs": [],
317+
"source": [
318+
"normalization_CLAHE(covid_path)"
319+
]
320+
},
321+
{
322+
"cell_type": "code",
323+
"execution_count": 5,
324+
"metadata": {},
325+
"outputs": [],
326+
"source": [
327+
"normalization_CLAHE(noncovid_path)\n",
328+
"normalization_CLAHE(normal_path)"
329+
]
330+
},
248331
{
249332
"cell_type": "code",
250333
"execution_count": 43,

notebooks/03_VGG19CNN_AM_tuning_pytorch_v3.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3629,7 +3629,7 @@
36293629
"name": "python",
36303630
"nbconvert_exporter": "python",
36313631
"pygments_lexer": "ipython3",
3632-
"version": "3.11.3"
3632+
"version": "3.12.2"
36333633
}
36343634
},
36353635
"nbformat": 4,

0 commit comments

Comments
 (0)