abdabbas commited on
Commit
44a24c7
1 Parent(s): 9d8fac0

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ !pip install gradio
2
+ import gradio as gr
3
+
4
+ import tensorflow
5
+ from tensorflow.keras.models import load_model
6
+
7
+ model = load_model('../input/cnn-model/cnn_model.h5') # هنا احمل المودل بعد ما دربته وخزنتة حته اشوف قدرته على التصنيف
8
+
9
+ class_names=['benign','malignant','normal']
10
+
11
+ def predict_image(img):
12
+ img_4d=img.reshape(-1,128,128,3)
13
+ img_4d=img_4d/255
14
+ prediction=model.predict(img_4d)[0]
15
+ return {class_names[i]: float(prediction[i]) for i in range(3)}# range 1 if sigmoid , range=number of class if softmax
16
+
17
+ image = gr.inputs.Image(shape=(128,128))
18
+ label = gr.outputs.Label(num_top_classes=3)
19
+ gr.Interface(fn=predict_image, inputs=image,
20
+ outputs=label).launch(debug='False',share=True)