ntsc207 commited on
Commit
167a63f
·
verified ·
1 Parent(s): fbf7466

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -39
app.py CHANGED
@@ -107,60 +107,32 @@ def yolov9_inference(model_id, img_path=None, vid_path=None, tracking_algorithm
107
 
108
  plt.tight_layout() # Ensure the entire plot fits into the figure area
109
  #ax.set_facecolor('#D3D3D3')
110
- elif output_extension.lower() in vid_extensions:
111
- output_video = output_path
112
  output_image = None
113
-
114
- # Interpolation preprocessing
115
- interpolated_data = []
116
-
117
- labels = frame_counts_df['label'].unique()
118
- for label in labels:
119
- df_label = frame_counts_df[frame_counts_df['label'] == label]
120
-
121
- # Sort data by frame to ensure smooth interpolation
122
- df_label = df_label.sort_values('frame')
123
-
124
- # Original data points
125
- x = df_label['frame']
126
- y = df_label['count']
127
-
128
- # Create spline interpolation
129
- x_smooth = np.linspace(x.min(), x.max(), 500)
130
- spline = make_interp_spline(x, y, k=3) # Cubic spline interpolation
131
- y_smooth = spline(x_smooth)
132
-
133
- # Append the smoothed data to the list
134
- interpolated_data.append(pd.DataFrame({'frame': x_smooth, 'count': y_smooth, 'label': label}))
135
-
136
- # Concatenate all interpolated data into a single DataFrame
137
- interpolated_df = pd.concat(interpolated_data)
138
-
139
  plt.style.use("ggplot")
140
  fig, ax = plt.subplots(figsize=(10, 6))
141
-
142
- # Plot using Seaborn
143
- sns.lineplot(ax=ax, data=interpolated_df, x='frame', y='count', hue='label', palette=palette, linewidth=2.5)
144
-
145
  ax.set_title('Count of Labels over Frames', fontsize=20, pad=20) # Increase padding for the title
146
  ax.set_xlabel('Frame', fontsize=16) # Increase font size
147
  ax.set_ylabel('Count', fontsize=16) # Increase font size
148
  ax.tick_params(axis='x', labelsize=12) # Increase label size for x-axis
149
  ax.tick_params(axis='y', labelsize=12) # Increase label size for y-axis
150
-
151
  # Add grid but make it lighter and put it behind bars
152
  ax.grid(True, linestyle=':', linewidth=0.6, color='gray', alpha=0.6)
153
  ax.set_axisbelow(True)
154
-
155
  # Change the background color to a lighter shade
156
  ax.set_facecolor('#F0F0F0')
157
-
158
  # Add a legend with a smaller font size
159
  ax.legend(fontsize=10)
160
-
161
- plt.tight_layout() # Ensure the entire plot is visible
162
-
163
- # Return the figure, output_image, and output_video
164
  return output_image, output_video, fig
165
 
166
 
 
107
 
108
  plt.tight_layout() # Ensure the entire plot fits into the figure area
109
  #ax.set_facecolor('#D3D3D3')
110
+ elif output_extension.lower() in vid_extensions:
111
+ output_video = output_path # Load the video file here
112
  output_image = None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  plt.style.use("ggplot")
114
  fig, ax = plt.subplots(figsize=(10, 6))
115
+ #for label in labels:
116
+ #df_label = frame_counts_df[frame_counts_df['label'] == label]
117
+ sns.lineplot(ax = ax, data = frame_counts_df, x = 'frame', y = 'count', hue = 'label', palette=palette,linewidth=2.5)
118
+
119
  ax.set_title('Count of Labels over Frames', fontsize=20, pad=20) # Increase padding for the title
120
  ax.set_xlabel('Frame', fontsize=16) # Increase font size
121
  ax.set_ylabel('Count', fontsize=16) # Increase font size
122
  ax.tick_params(axis='x', labelsize=12) # Increase label size for x-axis
123
  ax.tick_params(axis='y', labelsize=12) # Increase label size for y-axis
124
+
125
  # Add grid but make it lighter and put it behind bars
126
  ax.grid(True, linestyle=':', linewidth=0.6, color='gray', alpha=0.6)
127
  ax.set_axisbelow(True)
128
+
129
  # Change the background color to a lighter shade
130
  ax.set_facecolor('#F0F0F0')
131
+
132
  # Add a legend with a smaller font size
133
  ax.legend(fontsize=10)
134
+
135
+ plt.tight_layout() # Ensure the entire
 
 
136
  return output_image, output_video, fig
137
 
138