File size: 1,130 Bytes
83f5eea 2a7ad43 83f5eea 2a7ad43 83f5eea 2a7ad43 f28a984 2a7ad43 83f5eea f28a984 83f5eea |
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 33 34 35 36 37 |
import os
import subprocess
import sys
import gradio as gr
# Clone the ECG interpretation repository if not already present
if not os.path.exists("Automated-ECG-Interpretation"):
subprocess.run(["git", "clone", "https://github.com/AutoECG/Automated-ECG-Interpretation.git"], check=True)
# Add the repo to Python path
sys.path.append("Automated-ECG-Interpretation")
# Import the ECG Interpreter
try:
from AutomatedECG.main import ECGInterpreter
except ModuleNotFoundError:
print("Error: Could not import ECGInterpreter. Check repository structure.")
# Initialize interpreter
interpreter = ECGInterpreter()
def analyze_ecg(ecg_file):
""" Analyze ECG file using the Automated-ECG-Interpretation model. """
result = interpreter.interpret(ecg_file.name) # Assuming it takes a file path
return str(result)
# Gradio UI
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) |