Update app.py
Browse files
app.py
CHANGED
@@ -67,8 +67,8 @@ def process_video(video_path, target, progress=gr.Progress()):
|
|
67 |
break
|
68 |
|
69 |
# Resize the frame
|
70 |
-
img_resized = cv2.resize(img, (
|
71 |
-
pil_img = Image.fromarray(cv2.cvtColor(
|
72 |
|
73 |
batch_frames.append(pil_img)
|
74 |
batch_indices.append(i)
|
@@ -127,18 +127,17 @@ def process_video(video_path, target, progress=gr.Progress()):
|
|
127 |
def create_heatmap(frame_scores, current_frame):
|
128 |
plt.figure(figsize=(12, 3))
|
129 |
plt.imshow([frame_scores], cmap='hot_r', aspect='auto')
|
130 |
-
cbar = plt.colorbar(label='Confidence')
|
131 |
-
cbar.ax.yaxis.set_ticks_position('left')
|
132 |
-
cbar.ax.yaxis.set_label_position('left')
|
133 |
plt.title('Object Detection Heatmap')
|
134 |
plt.xlabel('Frame')
|
135 |
plt.yticks([])
|
136 |
|
|
|
137 |
num_frames = len(frame_scores)
|
138 |
-
step = max(1, num_frames // 10)
|
139 |
frame_numbers = range(0, num_frames, step)
|
140 |
plt.xticks(frame_numbers, [str(i) for i in frame_numbers])
|
141 |
|
|
|
142 |
plt.axvline(x=current_frame, color='blue', linestyle='--', linewidth=2)
|
143 |
|
144 |
plt.tight_layout()
|
|
|
67 |
break
|
68 |
|
69 |
# Resize the frame
|
70 |
+
#img_resized = cv2.resize(img, (1280, 720))
|
71 |
+
pil_img = Image.fromarray(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
|
72 |
|
73 |
batch_frames.append(pil_img)
|
74 |
batch_indices.append(i)
|
|
|
127 |
def create_heatmap(frame_scores, current_frame):
|
128 |
plt.figure(figsize=(12, 3))
|
129 |
plt.imshow([frame_scores], cmap='hot_r', aspect='auto')
|
|
|
|
|
|
|
130 |
plt.title('Object Detection Heatmap')
|
131 |
plt.xlabel('Frame')
|
132 |
plt.yticks([])
|
133 |
|
134 |
+
# Add more frame numbers on x-axis
|
135 |
num_frames = len(frame_scores)
|
136 |
+
step = max(1, num_frames // 10) # Show at most 10 frame numbers
|
137 |
frame_numbers = range(0, num_frames, step)
|
138 |
plt.xticks(frame_numbers, [str(i) for i in frame_numbers])
|
139 |
|
140 |
+
# Add vertical line for current frame
|
141 |
plt.axvline(x=current_frame, color='blue', linestyle='--', linewidth=2)
|
142 |
|
143 |
plt.tight_layout()
|