| | import gradio as gr |
| | import tensorflow as tf |
| | import numpy as np |
| | from utils import preprocess_image |
| |
|
| | |
| | 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() |