|
import os |
|
import subprocess |
|
import sys |
|
import gradio as gr |
|
|
|
|
|
if not os.path.exists("Automated-ECG-Interpretation"): |
|
subprocess.run(["git", "clone", "https://github.com/AutoECG/Automated-ECG-Interpretation.git"], check=True) |
|
|
|
|
|
sys.path.append("Automated-ECG-Interpretation") |
|
|
|
|
|
try: |
|
from AutomatedECG.main import ECGInterpreter |
|
except ModuleNotFoundError: |
|
print("Error: Could not import ECGInterpreter. Check repository structure.") |
|
|
|
|
|
interpreter = ECGInterpreter() |
|
|
|
def analyze_ecg(ecg_file): |
|
""" Analyze ECG file using the Automated-ECG-Interpretation model. """ |
|
result = interpreter.interpret(ecg_file.name) |
|
return str(result) |
|
|
|
|
|
iface = gr.Interface( |
|
fn=analyze_ecg, |
|
inputs=gr.File(label="Upload ECG File"), |
|
outputs="text", |
|
title="ECG Analysis", |
|
description="Upload an ECG file for automated interpretation." |
|
) |
|
|
|
if __name__ == "__main__": |
|
iface.launch(server_name="0.0.0.0", server_port=7860) |