Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,8 +4,7 @@ import cv2
|
|
| 4 |
import numpy as np
|
| 5 |
from collections import deque
|
| 6 |
import time
|
| 7 |
-
import
|
| 8 |
-
|
| 9 |
# Length of signal history to display (in samples)
|
| 10 |
MAX_LEN = 500
|
| 11 |
|
|
@@ -106,20 +105,18 @@ def snap(frame, state):
|
|
| 106 |
"name": "Green PPG",
|
| 107 |
}
|
| 108 |
|
| 109 |
-
#
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
return img, plot_data, state
|
| 122 |
-
|
| 123 |
with gr.Blocks() as demo:
|
| 124 |
# Stateful object to store signals across frames
|
| 125 |
state = gr.State({"red": red_signal, "green": green_signal, "time": timestamps})
|
|
|
|
| 4 |
import numpy as np
|
| 5 |
from collections import deque
|
| 6 |
import time
|
| 7 |
+
import matplotlib.pyplot as plt
|
|
|
|
| 8 |
# Length of signal history to display (in samples)
|
| 9 |
MAX_LEN = 500
|
| 10 |
|
|
|
|
| 105 |
"name": "Green PPG",
|
| 106 |
}
|
| 107 |
|
| 108 |
+
# Create matplotlib figure for plotting
|
| 109 |
+
fig, ax = plt.subplots(figsize=(8, 4))
|
| 110 |
+
ax.plot(time_list, red_list, label='Red PPG', color='red')
|
| 111 |
+
ax.plot(time_list, green_list, label='Green PPG', color='green')
|
| 112 |
+
ax.set_xlabel('Time (s)')
|
| 113 |
+
ax.set_ylabel('Intensity')
|
| 114 |
+
ax.set_title('Red & Green PPG')
|
| 115 |
+
ax.legend()
|
| 116 |
+
ax.grid(True)
|
| 117 |
+
plt.close(fig)
|
| 118 |
+
|
| 119 |
+
return img, fig, state
|
|
|
|
|
|
|
| 120 |
with gr.Blocks() as demo:
|
| 121 |
# Stateful object to store signals across frames
|
| 122 |
state = gr.State({"red": red_signal, "green": green_signal, "time": timestamps})
|