kris524 commited on
Commit
d5f32c7
·
verified ·
1 Parent(s): 31db17e

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import tensorflow as tf
3
+ import numpy as np
4
+ from utils import preprocess_image
5
+
6
+ # Load model
7
+ model = tf.keras.models.load_model("model/model.h5")
8
+
9
+ def predict(image):
10
+ processed_image = preprocess_image(image)
11
+ prediction = model.predict(processed_image)[0][0]
12
+
13
+ if prediction > 0.5:
14
+ return {
15
+ "Fractured": float(prediction),
16
+ "Normal": float(1 - prediction)
17
+ }
18
+ else:
19
+ return {
20
+ "Normal": float(1 - prediction),
21
+ "Fractured": float(prediction)
22
+ }
23
+
24
+ interface = gr.Interface(
25
+ fn=predict,
26
+ inputs=gr.Image(type="pil"),
27
+ outputs=gr.Label(num_top_classes=2),
28
+ title="Bone Fracture Detection",
29
+ description="Upload an X-ray image to detect bone fracture using deep learning"
30
+ )
31
+
32
+ interface.launch()