Spaces:
Runtime error
Runtime error
File size: 1,098 Bytes
9821f8b 4e8c9b0 9821f8b aed0572 9821f8b 4e8c9b0 9821f8b b0e3127 4e8c9b0 aed0572 ba3419a 55af2c8 ba3419a 4e8c9b0 c5ee548 |
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 |
#import necessary libraries
import gradio as gr
import tensorflow as tf
from tensorflow.keras.preprocessing.image import load_img, img_to_array
from huggingface_hub import from_pretrained_keras
import numpy as np
def detect_cancer(img):
#Load the model
model = from_pretrained_keras('MUmairAB/Breast_Cancer_Detector')
#Convert the NumPy image to tensor
img = tf.convert_to_tensor(img)
#Convert the single images to batch image
img = tf.expand_dims(img, axis=0)
#Make predictions
pred = model.predict(img)
#Convert the "numpy.ndarray" object to a simple numebr
prediction = round(float(pred))
if prediction == 0:
return("Congratulation! you don't have breast cancer")
else:
return("Unfortunately! you have breast cancer. Kindly consult a doctor!")
gr.Interface(title="Breast Cancer Diagnosis\n(by Umair Akram)",
description="Enter the Histopathological image of the breast to predict the diagnosis.",
fn=detect_cancer,
inputs=gr.Image(shape=(50, 50)),
outputs='text').launch() |