dbrmobdel / app.py
sarth123's picture
Update app.py
2f1f2e6 verified
raw
history blame
672 Bytes
import gradio as gr
import cv2
import numpy as np
from PIL import Image
from keras.preprocessing import image
import tensorflow as tf
#predict function
def predict(img):
print("hi")
model = tf.keras.models.load_model(r"model_adv.keras")
print("hi")
Retina_classes = ['DR', 'No_DR']
img = np.resize(img,(224,224))
img = np.expand_dims(img, axis=0)
prediction=model.predict(img)[0]
print(prediction)
return {Retina_classes[i]: float(prediction[i]) for i in range(2)}
#Just four line implementation
image = gr.Image(label="Upload Here")
label = gr.Label(num_top_classes=2)
gr.Interface(fn=predict, inputs="image", outputs=label).launch()