Spaces:
Runtime error
Runtime error
File size: 748 Bytes
27be9af 44a24c7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
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) |