IFMedTechdemo commited on
Commit
f2b80f5
·
verified ·
1 Parent(s): f7f6d5c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -16
app.py CHANGED
@@ -4,8 +4,7 @@ import cv2
4
  import numpy as np
5
  from collections import deque
6
  import time
7
- import plotly.graph_objects as go
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
- # Plotly-style figure
110
- plot_data = go.Figure(
111
- data=[
112
- go.Scatter(x=time_list, y=red_list, mode='lines', name='Red PPG'),
113
- go.Scatter(x=time_list, y=green_list, mode='lines', name='Green PPG'),
114
- ],
115
- layout=go.Layout(
116
- title='Red & Green PPG',
117
- xaxis=dict(title='Time (s)'),
118
- yaxis=dict(title='Intensity'),
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})