Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,21 +2,35 @@ import gradio as gr
|
|
2 |
import tensorflow as tf
|
3 |
import numpy as np
|
4 |
import os
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
|
|
7 |
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
def detect(img):
|
11 |
-
|
12 |
-
prediction
|
13 |
-
|
14 |
-
|
15 |
-
return "Pneumonia Detected!"
|
16 |
|
17 |
return "Pneumonia Not Detected!"
|
18 |
|
19 |
|
|
|
|
|
|
|
|
|
|
|
20 |
input = gr.inputs.Image(shape=(100, 100))
|
21 |
|
22 |
examples = ['examples/n1.jpeg', 'examples/n2.jpeg', 'examples/n3.jpeg', 'examples/n4.jpeg', 'examples/n5.jpeg',
|
|
|
2 |
import tensorflow as tf
|
3 |
import numpy as np
|
4 |
import os
|
5 |
+
import tensorflow as tf
|
6 |
+
import numpy as np
|
7 |
+
from keras.models import load_model
|
8 |
+
from tensorflow.keras.utils import load_img
|
9 |
|
10 |
+
# Charger le modèle
|
11 |
+
model = load_model('/content/drive/MyDrive/T-DEV-810/model_cv.h5')
|
12 |
|
13 |
+
# Charger l'image
|
14 |
+
img = load_img('/content/drive/MyDrive/T-DEV-810/DS/test/NORMAL/IM-0063-0001.jpeg', target_size=(100, 100))
|
15 |
+
# Prétraiter l'image
|
16 |
+
# img = image.img_to_array(img)
|
17 |
+
img = np.expand_dims(img, axis=0)
|
18 |
+
img = img/255
|
19 |
|
20 |
def detect(img):
|
21 |
+
prediction = model.predict(img)[0]
|
22 |
+
print(prediction)
|
23 |
+
if prediction[0] <= 0.80:
|
24 |
+
return "Pneumonia Detected!"
|
|
|
25 |
|
26 |
return "Pneumonia Not Detected!"
|
27 |
|
28 |
|
29 |
+
result = detect(img)
|
30 |
+
print(result)
|
31 |
+
os.system("tar -zxvf examples.tar.gz")
|
32 |
+
|
33 |
+
|
34 |
input = gr.inputs.Image(shape=(100, 100))
|
35 |
|
36 |
examples = ['examples/n1.jpeg', 'examples/n2.jpeg', 'examples/n3.jpeg', 'examples/n4.jpeg', 'examples/n5.jpeg',
|