Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,20 +1,28 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
| 2 |
from huggingface_hub import from_pretrained_keras
|
| 3 |
|
| 4 |
def predict_diagnosis(loops):
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
model = from_pretrained_keras("layai/priya-loop-model")
|
| 9 |
-
single_data = model.predict(
|
| 10 |
single_data = single_data[0]
|
| 11 |
return np.argmax(single_data)
|
| 12 |
|
| 13 |
-
input = gr.inputs.Image(
|
| 14 |
output = gr.outputs.Textbox(label='Predicted diagnosis')
|
| 15 |
iloops = gr.Interface( fn=predict_diagnosis,
|
| 16 |
inputs=input,
|
| 17 |
outputs=output,
|
| 18 |
capture_session=True)
|
| 19 |
|
| 20 |
-
iloops.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import tensorflow as tf
|
| 3 |
+
import numpy as np
|
| 4 |
from huggingface_hub import from_pretrained_keras
|
| 5 |
|
| 6 |
def predict_diagnosis(loops):
|
| 7 |
+
if loops.shape[2] == 4:
|
| 8 |
+
loops = np.delete(loops, 3, axis=2)
|
| 9 |
+
|
| 10 |
+
n_img = np.ndarray((1, 255, 906, 3))
|
| 11 |
+
for i in range(n_img.shape[0]):
|
| 12 |
+
n_img[i] = tf.keras.utils.img_to_array(tf.image.resize(loops, [255, 906]))
|
| 13 |
+
|
| 14 |
+
n_img = n_img.astype(np.float32)/255.0
|
| 15 |
+
|
| 16 |
model = from_pretrained_keras("layai/priya-loop-model")
|
| 17 |
+
single_data = model.predict(n_img)
|
| 18 |
single_data = single_data[0]
|
| 19 |
return np.argmax(single_data)
|
| 20 |
|
| 21 |
+
input = gr.inputs.Image()
|
| 22 |
output = gr.outputs.Textbox(label='Predicted diagnosis')
|
| 23 |
iloops = gr.Interface( fn=predict_diagnosis,
|
| 24 |
inputs=input,
|
| 25 |
outputs=output,
|
| 26 |
capture_session=True)
|
| 27 |
|
| 28 |
+
iloops.launch(debug=True)
|