sarth123 commited on
Commit
f3618e8
·
verified ·
1 Parent(s): 0cd381d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -16
app.py CHANGED
@@ -1,18 +1,22 @@
1
  import gradio as gr
2
- from transformers import pipeline
 
 
 
 
 
 
 
3
 
4
- pipeline = pipeline(task="image-classification", model="sarth123/dbrdetectionmodel")
5
-
6
- def predict(input_img):
7
- predictions = pipeline(input_img)
8
- return input_img, {p["label"]: p["score"] for p in predictions}
9
-
10
- gradio_app = gr.Interface(
11
- predict,
12
- inputs=gr.Image(label="Retinopathy score", sources=['upload', 'webcam'], type="pil"),
13
- outputs=[gr.Image(label="Processed Image"), gr.Label(label="Result", num_top_classes=2)],
14
- title="Retinopathy score",
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()