File size: 1,706 Bytes
ab04ca6
 
 
cf5f013
0023eaf
81b8453
56b6474
ab04ca6
 
 
 
 
 
 
 
cf5f013
ab04ca6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53c609d
ab04ca6
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import gradio as gr
import pandas as pd
import numpy as np 

from keras.models import model_from_json
from tensorflow.keras.preprocessing import image
#from keras.preprocessing import image
from keras.applications.vgg16 import VGG16, preprocess_input

file = open("womanlife.json", 'r')
model_json2 = file.read()
file.close()
loaded_model = model_from_json(model_json2)
loaded_model.load_weights("womanlife.h5")

objects = ('There is a benign nodule', 'There is a malignant nodule', 'Normal Breast')
y_pos = np.arange(len(objects))



def predict_image(pic):

    img = image.load_img(pic, target_size=(224, 224))
    x = image.img_to_array(img) 
    x = np.expand_dims(x, axis=0)
    x = preprocess_input(x)

    custom = loaded_model.predict(x)

    m=0.000000000000000000001
    a=custom[0]
    for i in range(0,len(a)):
        if a[i]>m:
            m=a[i]
            ind=i
        
    return ('Result of the analysis:',objects[ind])
    
iface = gr.Interface(
    predict_image,
    [
        
        gr.inputs.Image(source="upload",type="filepath", label="Imagen")
    ],

    "text",
    
    
    interpretation="default",
    title = 'WomanLife: Deep Learning for the detection  of breast cancer',
    description = 'Breast cancer is the most common type of cancer in women and is also one of the main causes of death according to the WHO (WHO, 2020). Early detection is the single most important factor in lowering cancer treatment costs and mortality. https://saturdays.ai/2021/12/31/womanlife-deep-learning-for-the-detection-and-classification-of-breast-cancer-2/',
    examples=[["A.png"], ["B.png"], ["C.png"], ["D.png"], ["E.png"], ["F.png"]],
    theme = 'peach'
 )


   
iface.launch()