import os import wfdb import numpy as np import gradio as gr from models.inception import * def load_data(): cwd = os.getcwd() sample_data = f"{cwd}/sample_data/ath_001" ecg = wfdb.rdsamp(sample_data) return np.asarray(ecg) def load_model(sample_frequency,recording_time, num_leads): cwd = os.getcwd() weights = f"{cwd}/models/weights/model_weights_leadI.h5" model = build_model((sample_frequency * recording_time, num_leads), 1) model.load_weights(weights) return model def run(ecg): SAMPLE_FREQUENCY = 100 TIME = 10 NUM_LEADS = 1 data = load_data() model = load_model(sample_frequency=SAMPLE_FREQUENCY,recording_time=TIME,num_leads=NUM_LEADS) predicion = model.predict(data) return predicion iface = gr.Interface(fn=run, inputs="text", outputs="text") iface.launch()