Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,45 +1,31 @@
|
|
1 |
-
|
2 |
import gradio as gr
|
3 |
-
import tensorflow as tf
|
4 |
-
import tensorflow.keras
|
5 |
-
import matplotlib.pyplot as plt
|
6 |
-
import cv2
|
7 |
import tensorflow_io as tfio
|
8 |
import numpy as np
|
9 |
|
10 |
-
loaded_model = tf.keras.models.load_model(
|
11 |
-
|
12 |
-
def
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
r = str(r)
|
37 |
-
|
38 |
-
return {'cryst' : q ,'Normal' : w ,'Stone' : e ,'Tumour' : r }
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
image = gr.inputs.Image(shape=(224,224))
|
43 |
-
|
44 |
-
label = gr.outputs.Label('ok')
|
45 |
-
gr.Interface(fn=take_img, inputs=image, outputs="label",interpretation='default').launch(debug='True')
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import tensorflow as tf
|
|
|
|
|
|
|
3 |
import tensorflow_io as tfio
|
4 |
import numpy as np
|
5 |
|
6 |
+
loaded_model = tf.keras.models.load_model('kidney2.h5')
|
7 |
+
|
8 |
+
def classify_kidney_image(img):
|
9 |
+
resize = tf.image.resize(img, (224, 224))
|
10 |
+
gray = tfio.experimental.color.bgr_to_rgb(resize)
|
11 |
+
yhat = loaded_model.predict(np.expand_dims(gray / 255, 0))
|
12 |
+
label_names = {
|
13 |
+
"1": "Cyst",
|
14 |
+
"2": "Normal",
|
15 |
+
"3": "Stone",
|
16 |
+
"4": "Tumor"
|
17 |
+
}
|
18 |
+
classes_x = np.argmax(yhat, axis=1)
|
19 |
+
a = classes_x[0]
|
20 |
+
input_value = a + 1
|
21 |
+
input_str = str(input_value)
|
22 |
+
predicted_label = label_names[input_str]
|
23 |
+
q, w, e, r = yhat[0]
|
24 |
+
|
25 |
+
return {'Cyst': str(q), 'Normal': str(w), 'Stone': str(e), 'Tumor': str(r)}
|
26 |
+
|
27 |
+
image = gr.inputs.Image(shape=(224, 224))
|
28 |
+
label = gr.outputs.Label()
|
29 |
+
|
30 |
+
app = gr.Interface(fn=classify_kidney_image, inputs=image, outputs=label, interpretation='default', title='Kidney Image Classifier')
|
31 |
+
app.launch(debug=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|