Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import numpy as np
|
| 3 |
+
|
| 4 |
+
def analyze_heart_rate(bpm):
|
| 5 |
+
try:
|
| 6 |
+
bpm = float(bpm)
|
| 7 |
+
if bpm < 60:
|
| 8 |
+
return "Low heart rate (Bradycardia). Consider consulting a doctor."
|
| 9 |
+
elif 60 <= bpm <= 100:
|
| 10 |
+
return "Normal heart rate. Keep up the healthy lifestyle!"
|
| 11 |
+
else:
|
| 12 |
+
return "High heart rate (Tachycardia). Monitor your activity level."
|
| 13 |
+
except ValueError:
|
| 14 |
+
return "Please enter a valid number."
|
| 15 |
+
|
| 16 |
+
with gr.Blocks() as demo:
|
| 17 |
+
gr.Markdown("# Cardio Health Analyzer")
|
| 18 |
+
gr.Markdown("Enter your heart rate (BPM) to analyze your cardiovascular health.")
|
| 19 |
+
|
| 20 |
+
with gr.Row():
|
| 21 |
+
bpm_input = gr.Textbox(label="Heart Rate (BPM)")
|
| 22 |
+
with gr.Row():
|
| 23 |
+
submit_button = gr.Button("Analyze")
|
| 24 |
+
|
| 25 |
+
result_output = gr.Textbox(label="Analysis", interactive=False)
|
| 26 |
+
submit_button.click(analyze_heart_rate, inputs=bpm_input, outputs=result_output)
|
| 27 |
+
|
| 28 |
+
demo.launch()
|