|
|
|
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): |
|
|
|
model = from_pretrained_keras('MUmairAB/Breast_Cancer_Detector') |
|
|
|
img = tf.convert_to_tensor(img) |
|
|
|
img = tf.expand_dims(img, axis=0) |
|
|
|
pred = model.predict(img) |
|
|
|
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!") |
|
|
|
|
|
input_img = gr.Image(shape=(50, 50)) |
|
|
|
output = 'text' |
|
|
|
|
|
interfac = 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=input_img, |
|
outputs=output) |
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
interfac.launch() |