File size: 811 Bytes
d5f32c7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import gradio as gr
import tensorflow as tf
import numpy as np
from utils import preprocess_image

# Load model
model = tf.keras.models.load_model("model/model.h5")

def predict(image):
    processed_image = preprocess_image(image)
    prediction = model.predict(processed_image)[0][0]

    if prediction > 0.5:
        return {
            "Fractured": float(prediction),
            "Normal": float(1 - prediction)
        }
    else:
        return {
            "Normal": float(1 - prediction),
            "Fractured": float(prediction)
        }

interface = gr.Interface(
    fn=predict,
    inputs=gr.Image(type="pil"),
    outputs=gr.Label(num_top_classes=2),
    title="Bone Fracture Detection",
    description="Upload an X-ray image to detect bone fracture using deep learning"
)

interface.launch()