Fixed color channel swap (until retrain)
Browse files- helpers.py +7 -1
helpers.py
CHANGED
|
@@ -28,6 +28,9 @@ def load_video_from_url(youtube_url):
|
|
| 28 |
sampled_frames[3 * len(sampled_frames) // 4],
|
| 29 |
]
|
| 30 |
|
|
|
|
|
|
|
|
|
|
| 31 |
# DELETE VIDEO FILE
|
| 32 |
if os.path.exists(src):
|
| 33 |
os.remove(src)
|
|
@@ -117,8 +120,11 @@ def sample_frames_from_video_file(capture, sample_count=10, frames_per_sample=10
|
|
| 117 |
return np.array(result)
|
| 118 |
|
| 119 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
def format_frames(frame, output_size):
|
| 121 |
-
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
| 122 |
frame = tf.image.convert_image_dtype(frame, tf.float32)
|
| 123 |
frame = tf.image.resize_with_pad(frame, *output_size)
|
| 124 |
return frame
|
|
|
|
| 28 |
sampled_frames[3 * len(sampled_frames) // 4],
|
| 29 |
]
|
| 30 |
|
| 31 |
+
# SWAP COLOR CHANNELS FOR EXAMPLE FRAMES
|
| 32 |
+
example_frames = swap_color_channels(example_frames)
|
| 33 |
+
|
| 34 |
# DELETE VIDEO FILE
|
| 35 |
if os.path.exists(src):
|
| 36 |
os.remove(src)
|
|
|
|
| 120 |
return np.array(result)
|
| 121 |
|
| 122 |
|
| 123 |
+
def swap_color_channels(frames):
|
| 124 |
+
return [cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) for frame in frames]
|
| 125 |
+
|
| 126 |
+
|
| 127 |
def format_frames(frame, output_size):
|
|
|
|
| 128 |
frame = tf.image.convert_image_dtype(frame, tf.float32)
|
| 129 |
frame = tf.image.resize_with_pad(frame, *output_size)
|
| 130 |
return frame
|