Spaces:
Runtime error
Runtime error
File size: 907 Bytes
ccd0c5e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
import gradio as gr
import tensorflow as tf
import tensorflow.keras
import matplotlib.pyplot as plt
import cv2
import tensorflow_io as tfio
import numpy as np
loaded_model = tf.keras.models.load_model( 'brain1.h5')
def take_img(img):
resize = tf.image.resize(img, (128,128))
gray = tfio.experimental.color.bgr_to_rgb(resize)
yhat = loaded_model.predict(np.expand_dims(gray/255, 0))
label_names = {
"1": "Tumor",
"2": "Normal"}
classes_x=np.argmax(yhat,axis=1)
a = classes_x[0]
input_value = a + 1
input_str = str(input_value)
predicted_label = label_names[input_str]
tumor = yhat[0][0]
tumor = str(tumor)
normal = yhat[0][1]
normal = str(normal)
return {'Tumour': tumor, 'Normal':normal}
image = gr.inputs.Image(shape=(128,128))
label = gr.outputs.Label('ok')
gr.Interface(fn=take_img, inputs=image, outputs="label",interpretation='default').launch(debug='True')
|