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)