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()