samyak152002
commited on
Commit
•
36b702b
1
Parent(s):
90e291d
Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,23 @@
|
|
1 |
import gradio as gr
|
2 |
import numpy as np
|
3 |
|
4 |
-
# Generate data for 100 seconds with variability
|
5 |
-
def generate_data(start_value, fluctuation, size):
|
6 |
time = np.arange(size)
|
7 |
-
data = start_value + fluctuation * np.sin(time / 10) + np.random.normal(scale=
|
8 |
data = np.clip(data, 0, None) # Ensure no negative values
|
9 |
return time.tolist(), data.tolist()
|
10 |
|
11 |
def fetch_blood_oxygen():
|
12 |
-
time, oxygen_level = generate_data(start_value=97, fluctuation=
|
13 |
return {"time": time, "oxygen_level": oxygen_level}
|
14 |
|
15 |
def fetch_heart_rate():
|
16 |
-
time, heart_rate = generate_data(start_value=75, fluctuation=
|
17 |
return {"time": time, "heart_rate": heart_rate}
|
18 |
|
19 |
def fetch_sugar_level():
|
20 |
-
time, sugar_level = generate_data(start_value=90, fluctuation=
|
21 |
return {"time": time, "sugar_level": sugar_level}
|
22 |
|
23 |
# Create Gradio interfaces for each of the APIs
|
|
|
1 |
import gradio as gr
|
2 |
import numpy as np
|
3 |
|
4 |
+
# Generate data for 100 seconds with unique variability
|
5 |
+
def generate_data(start_value, fluctuation, noise_scale, size):
|
6 |
time = np.arange(size)
|
7 |
+
data = start_value + fluctuation * np.sin(time / 10) + np.random.normal(scale=noise_scale, size=size)
|
8 |
data = np.clip(data, 0, None) # Ensure no negative values
|
9 |
return time.tolist(), data.tolist()
|
10 |
|
11 |
def fetch_blood_oxygen():
|
12 |
+
time, oxygen_level = generate_data(start_value=97, fluctuation=5, noise_scale=0.5, size=100)
|
13 |
return {"time": time, "oxygen_level": oxygen_level}
|
14 |
|
15 |
def fetch_heart_rate():
|
16 |
+
time, heart_rate = generate_data(start_value=75, fluctuation=10, noise_scale=1.0, size=100)
|
17 |
return {"time": time, "heart_rate": heart_rate}
|
18 |
|
19 |
def fetch_sugar_level():
|
20 |
+
time, sugar_level = generate_data(start_value=90, fluctuation=15, noise_scale=1.5, size=100)
|
21 |
return {"time": time, "sugar_level": sugar_level}
|
22 |
|
23 |
# Create Gradio interfaces for each of the APIs
|