Spaces:
Runtime error
Runtime error
Update app.py
#1
by
DHEIVER
- opened
app.py
CHANGED
@@ -1,20 +1,16 @@
|
|
1 |
-
|
2 |
import gradio as gr
|
3 |
-
|
4 |
import tensorflow
|
5 |
-
from tensorflow.keras.models import
|
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)}
|
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)
|
|