Spaces:
Sleeping
Sleeping
| import tensorflow as tf | |
| import gradio as gr | |
| from preprocessing import preprocess_dicom | |
| # Load model once | |
| model = tf.keras.models.load_model("pneumonia_model_clean.keras") | |
| def predict(file): | |
| img = preprocess_dicom(file.name) | |
| prob = float(model.predict(img)[0][0]) | |
| if prob >= 0.5: | |
| return f"PNEUMONIA (confidence: {prob:.2f})" | |
| else: | |
| return f"NORMAL (confidence: {1 - prob:.2f})" | |
| demo = gr.Interface( | |
| fn=predict, | |
| inputs=gr.File(label="Upload Chest X-ray (DICOM)"), | |
| outputs=gr.Textbox(label="Prediction"), | |
| title="Pneumonia Screening (DenseNet)", | |
| description="DICOM-based pneumonia screening model" | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() | |