File size: 706 Bytes
e605d16
b7c2715
20de4d1
b0edaee
a0b676a
5333aab
a0b676a
be716a9
a0b676a
 
 
8b8f5a0
 
 
 
 
 
e605d16
8b8f5a0
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import gradio as gr

import tensorflow as tf
from tensorflow.keras.models import  load_model
#from livelossplot import PlotLossesKeras
#from keras.models import load_model

model = load_model('target_xception_model.h5')

class_names={0:'خبيث',1:'حميد'}

def predict_image(img):
    img_4d=img.reshape(-1,299,299,3)
    img_4d=img_4d/255
    prediction=model.predict(img_4d)[0]
    #prediction = [1 if x>0.5 else 0 for x in prediction]
    return {class_names[i]: float(prediction[i]) for i in range(1)}
    
image = gr.inputs.Image(shape=(299,299))
label = gr.outputs.Label(num_top_classes=1)
gr.Interface(fn=predict_image, inputs=image,
             outputs=label).launch(debug='False',share=True)