breast_cancer / main.py
DHEIVER's picture
Update main.py
1fde9b0
raw
history blame
792 Bytes
!pip install gradio
!pip install tensorflow
import gradio as gr
import tensorflow
from tensorflow.keras.models import load_model
model = load_model('../input/cnn-model/cnn_model.h5') # هنا احمل المودل بعد ما دربته وخزنتة حته اشوف قدرته على التصنيف
class_names=['benign','malignant','normal']
def predict_image(img):
img_4d=img.reshape(-1,128,128,3)
img_4d=img_4d/255
prediction=model.predict(img_4d)[0]
return {class_names[i]: float(prediction[i]) for i in range(3)}# range 1 if sigmoid , range=number of class if softmax
image = gr.inputs.Image(shape=(128,128))
label = gr.outputs.Label(num_top_classes=3)
gr.Interface(fn=predict_image, inputs=image,
outputs=label).launch(debug='False',share=True)