Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,22 @@
|
|
1 |
import gradio as gr
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
)
|
16 |
-
|
17 |
-
if __name__ == "__main__":
|
18 |
-
gradio_app.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import cv2
|
3 |
+
import numpy as np
|
4 |
+
from PIL import Image
|
5 |
+
from keras.preprocessing import image
|
6 |
+
import tensorflow as tf
|
7 |
+
#predict function
|
8 |
+
def predict(img):
|
9 |
+
print("hi")
|
10 |
|
11 |
+
model = tf.keras.models.load_model(r"model_adv.keras")
|
12 |
+
print("hi")
|
13 |
+
Retina_classes = ['DR', 'No_DR']
|
14 |
+
img = np.resize(img,(299,299,3))
|
15 |
+
img = np.expand_dims(img, axis=0)
|
16 |
+
prediction=model.predict(img)[0]
|
17 |
+
print(prediction)
|
18 |
+
return {Retina_classes[i]: float(prediction[i]) for i in range(2)}
|
19 |
+
#Just four line implementation
|
20 |
+
image = gr.Image(label="Upload Here")
|
21 |
+
label = gr.Label(num_top_classes=2)
|
22 |
+
gr.Interface(fn=predict, inputs="image", outputs=label).launch()
|
|
|
|
|
|