depth_estimation / app (2).py
ahmedxeno's picture
Upload app (2).py
ccd0c5e
raw
history blame
907 Bytes
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')