Spaces:
Runtime error
Runtime error
dev-seek commited on
Commit ·
51fbbf9
1
Parent(s): c1582d2
Add application file
Browse files
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import tensorflow as tf:
|
| 3 |
+
|
| 4 |
+
def load_model():
|
| 5 |
+
model = tf.keras.models.load_model("model.h5")
|
| 6 |
+
return model
|
| 7 |
+
|
| 8 |
+
# from keras.preprocessing import image
|
| 9 |
+
def predict(image):
|
| 10 |
+
test_image = tf.keras.utils.load_img(image, target_size = (250,250,3))
|
| 11 |
+
test_image = tf.keras.utils.img_to_array(test_image)
|
| 12 |
+
test_image = np.expand_dims(test_image, axis = 0)
|
| 13 |
+
# print(test_image[:1])
|
| 14 |
+
#predict the resut
|
| 15 |
+
pred,probab = model_.predict_accident(test_image)
|
| 16 |
+
return pred
|
| 17 |
+
|
| 18 |
+
image = gr.inputs.Image()
|
| 19 |
+
outputs = gr.outputs.Textbox()
|
| 20 |
+
|
| 21 |
+
demo = gr.Interface(fn=predict , inputs=image, outputs="text")
|
| 22 |
+
demo.launch()
|
| 23 |
+
|