AhmedBadrDev commited on
Commit
6d162c2
·
1 Parent(s): 5ce6e55

init brain model

Browse files
Files changed (6) hide show
  1. app.py +41 -0
  2. examples/0.jpg +0 -0
  3. examples/1.jpg +0 -0
  4. examples/2.jpg +0 -0
  5. model.h5 +3 -0
  6. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import tensorflow as tf
3
+ import numpy as np
4
+
5
+ # Load the model
6
+ model = tf.keras.models.load_model('model.h5')
7
+
8
+ # Define the class names
9
+ class_names = {
10
+ 0: 'Glioma',
11
+ 1: 'Menin',
12
+ 2: 'Tumor'
13
+ }
14
+
15
+
16
+ {'brain_glioma': 0, 'brain_menin': 1, 'brain_tumor': 2}
17
+
18
+ def classify_image(image):
19
+ # Preprocess the image
20
+ img_array = tf.image.resize(image, 200, 200])
21
+ img_array = tf.expand_dims(img_array, 0) / 255.0
22
+
23
+ # Make a prediction
24
+ prediction = model.predict(img_array)
25
+ predicted_class = tf.argmax(prediction[0], axis=-1)
26
+ confidence = np.max(prediction[0])
27
+
28
+ return class_names[predicted_class.numpy()], confidence
29
+
30
+
31
+ iface = gr.Interface(
32
+ fn=classify_image,
33
+ inputs="image",
34
+ outputs=["text", "number"],
35
+ interpretation="default",
36
+ examples=[
37
+ ['examples/0.jpg'],
38
+ ['examples/1.jpg'],
39
+ ['examples/2.jpg'],
40
+ ])
41
+ iface.launch()
examples/0.jpg ADDED
examples/1.jpg ADDED
examples/2.jpg ADDED
model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4a27c67a7b3ad82c32f9a4025e9743f37e2ed8bc9bdc674873db2cd0e73e562a
3
+ size 2915984
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ tensorflow
2
+ numpy
3
+ pillow
4
+ tensorflow_hub