DHEIVER commited on
Commit
b2fa953
1 Parent(s): 27be9af

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -14
app.py CHANGED
@@ -1,20 +1,16 @@
1
-
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)
 
 
1
  import gradio as gr
 
2
  import tensorflow
3
+ from tensorflow.keras.models import load_model
4
 
5
+ model = load_model('../input/cnn-model/cnn_model.h5') # aqui carregamos o modelo que treinamos e salvamos para avaliar sua capacidade de classificação
6
+ class_names = ['benign', 'malignant', 'normal']
 
7
 
8
  def predict_image(img):
9
+ img_4d = img.reshape(-1, 128, 128, 3)
10
+ img_4d = img_4d/255
11
+ prediction = model.predict(img_4d)[0]
12
+ return {class_names[i]: float(prediction[i]) for i in range(3)}
13
+
14
+ image = gr.inputs.Image(shape=(128, 128))
15
  label = gr.outputs.Label(num_top_classes=3)
16
+ gr.Interface(fn=predict_image, inputs=image, outputs=label).launch(debug=False, share=True)