import os
import numpy as np
from flask import Flask, request, render_template
from [Link] import load_model
from [Link] import image
app = Flask(__name__)
# Load trained model
MODEL_PATH =
'C:/Users/leesm/Downloads/SI-GuidedProject-78335-1656736746-main/flask/ECG.h5'
model = load_model(MODEL_PATH)
# Class labels
LABELS = ['Left Bundle Branch Block', 'Normal', 'Premature Atrial Contraction',
'Premature Ventricular Contractions', 'Right Bundle Branch Block',
'Ventricular Fibrillation']
@[Link]("/") # Home page
def home():
return render_template("[Link]")
@[Link]("/about")
def about():
return render_template("[Link]")
@[Link]("/info")
def information():
return render_template("[Link]")
@[Link]("/upload", methods=["GET", "POST"])
def upload():
if [Link] == "POST":
if "file" not in [Link] or [Link]["file"].filename == "":
return render_template("[Link]", error="No file uploaded.")
f = [Link]["file"]
filename = [Link] # Get uploaded file name
filepath = [Link]("uploads", filename)
[Link]("uploads", exist_ok=True) # Ensure directory exists
[Link](filepath)
# Load and preprocess the image
img = image.load_img(filepath, target_size=(64, 64))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
# Make prediction
pred = [Link](x)
result = LABELS[[Link](pred)] # Get predicted class
return render_template("[Link]", prediction=result,
filename=filename)
return render_template("[Link]")
if __name__ == "__main__":
[Link](debug=True)