Removed uncompressed frame view and fixed predictor
This commit is contained in:
parent
b02503dca8
commit
93ef52e66f
1 changed files with 11 additions and 3 deletions
|
@ -35,11 +35,11 @@ def load_frame_from_video(video_file, frame_num):
|
|||
def predict_frame(uncompressed_frame):
|
||||
|
||||
#display_frame = np.clip(cv2.cvtColor(uncompressed_frame, cv2.COLOR_BGR2RGB) * 255.0, 0, 255).astype(np.uint8)
|
||||
cv2.imshow("uncomp", uncompressed_frame)
|
||||
#cv2.imshow("uncomp", uncompressed_frame)
|
||||
|
||||
combined_feature, frame = preprocess_frame(uncompressed_frame)
|
||||
frame = preprocess_frame(uncompressed_frame)
|
||||
|
||||
compressed_frame = MODEL.predict(np.expand_dims(combined_feature, axis=0))[0]
|
||||
compressed_frame = MODEL.predict([np.expand_dims(frame, axis=0)])[0]
|
||||
|
||||
display_frame = np.clip(cv2.cvtColor(compressed_frame, cv2.COLOR_BGR2RGB) * 255.0, 0, 255).astype(np.uint8)
|
||||
|
||||
|
@ -67,9 +67,17 @@ for i in range(total_frames):
|
|||
uncompressed_frame = load_frame_from_video(UNCOMPRESSED_VIDEO_FILE, frame_num=i)
|
||||
compressed_frame = predict_frame(uncompressed_frame)
|
||||
|
||||
compressed_frame = cv2.resize(compressed_frame, (width, height))
|
||||
|
||||
compressed_frame = np.clip(compressed_frame * 255.0, 0, 255).astype(np.uint8)
|
||||
|
||||
compressed_frame = cv2.cvtColor(compressed_frame, cv2.COLOR_RGB2BGR)
|
||||
|
||||
out.write(compressed_frame)
|
||||
|
||||
#if i % 10 == 0: # Print progress every 10 frames
|
||||
# print(f"Processed {i} / {total_frames} frames")
|
||||
|
||||
out.release()
|
||||
print("Compression completed.")
|
||||
|
||||
|
|
Reference in a new issue