JJjdjka commited on
Commit
54d4586
1 Parent(s): 9720976

Upload 12 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ xception.keras filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import tensorflow as tf
3
+ import numpy as np
4
+ from PIL import Image
5
+
6
+ model_path = "xception.keras"
7
+ model = tf.keras.models.load_model(model_path)
8
+
9
+ # Define the core prediction function
10
+ def predict_tumor(image):
11
+ # Preprocess image
12
+ print(type(image))
13
+ image = Image.fromarray(image.astype('uint8')) # Convert numpy array to PIL image
14
+ image = image.resize((150, 150)) #resize the image to 28x28 and converts it to gray scale
15
+ image = np.array(image)
16
+ image = np.expand_dims(image, axis=0) # same as image[None, ...]
17
+
18
+ # Predict
19
+ prediction = model.predict(image)
20
+
21
+ # No need to apply sigmoid, as the output layer already uses softmax
22
+ # Convert the probabilities to rounded values
23
+ prediction = np.round(prediction, 2)
24
+
25
+ # Separate the probabilities for each class
26
+ p_non_tumor = prediction[0][0] # Probability for class 'charmander'
27
+ tumor = prediction[0][1] # Probability for class 'mewto'
28
+
29
+ return {'non_tumor': p_non_tumor, 'mewto': tumor}
30
+
31
+
32
+ # Create the Gradio interface
33
+ input_image = gr.Image()
34
+ iface = gr.Interface(
35
+ fn=predict_tumor,
36
+ inputs=input_image,
37
+ outputs=gr.Label(),
38
+ examples=["images/1 no.jpeg", "images/3 no.jpg", "images/2 no.jpeg", "images/5 no.jpg", "images/4 no.jpg", "images/Y1.jpg", "images/Y2.jpg", "images/Y7.jpg", "images/Y4.jpg", "images/Y8.jpg"],
39
+ description="TEST.")
40
+
41
+ iface.launch()
images/1 no.jpeg ADDED
images/2 no.jpeg ADDED
images/3 no.jpg ADDED
images/4 no.jpg ADDED
images/5 no.jpg ADDED
images/Y1.jpg ADDED
images/Y2.jpg ADDED
images/Y4.jpg ADDED
images/Y7.jpg ADDED
images/Y8.jpg ADDED
xception.keras ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7246cf7663baec611adec994e23e9622886524c660cc368806fc1fd500ec19bc
3
+ size 250535559