marianeft's picture
Rename interface.py to app.py
286184c verified
import gradio as gr
import kagglehub
import os
from processing import analyze_pneumothorax
# Download dataset
dataset_path = kagglehub.dataset_download("kmader/siim-medical-images")
print("Path to dataset files:", dataset_path)
# Find a DICOM file in the dataset (for testing)
def find_dicom_file(dataset_path):
for root, _, files in os.walk(dataset_path):
for file in files:
if file.endswith(".dcm"):
return os.path.join(root, file)
return None
test_dicom_path = find_dicom_file(dataset_path)
if test_dicom_path is None:
print("No DICOM files found in the dataset.")
else:
print(f"Found a DICOM file for testing: {test_dicom_path}")
iface = gr.Interface(
fn=analyze_pneumothorax,
inputs=gr.File(type="filepath", label="Upload DICOM Image"),
outputs=gr.Image(type="pil", label="Segmented Image"),
title="Pneumothorax Segmentation",
description="This is a simplified application that uses machine learning to analyze images using segmentation."
)
iface.launch()