5/02/2023

Yolo V7 vs V8

 

V7 vs V8 comparison

https://youtu.be/k1dOZFcLOek

https://youtu.be/tpOGDclq7KY

https://youtu.be/u5qxN2ACEP4

https://youtu.be/85SH08jN4dY

This is a comparison video between yolo v7 and v8.

Here is information for each version

Testing Computer :

  • Intel(R) Core(TM) i7-9800X CPU @ 3.80GHz
  • RTX 4090

Something might be useful code

  • yolo v8, video writer for detection result
import cv2
import time
from ultralytics import YOLO

def process_video(model, video_path, output_path):
cap = cv2.VideoCapture(video_path)
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
fps = int(cap.get(cv2.CAP_PROP_FPS))

# Create a VideoWriter object to save the annotated video
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
out = cv2.VideoWriter(output_path, fourcc, fps, (width, height))

while cap.isOpened():
success, frame = cap.read()

if success:
start_time = time.time()
results = model(frame)
end_time = time.time()
processing_time = end_time - start_time
fps = 1/processing_time
# Visualize the results on the frame
annotated_frame = results[0].plot()
# Display the processing time on the annotated frame
cv2.putText(annotated_frame, f"Processing time: {processing_time:.4f} seconds / {fps:.4f} fps",
(10, 30), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2)

# Write the annotated frame to the output video
out.write(annotated_frame)

# cv2.imshow("YOLOv8 Inference", annotated_frame)
# if cv2.waitKey(1) & 0xFF == ord("q"):
# break
else:
break

cap.release()
out.release()

def main():
# Load the YOLO model
model = YOLO('yolov8x.pt')

# List of video files
video_paths = [
"../video/videoplayback-1.mp4",
"../video/videoplayback-2.mp4",
"../video/videoplayback-3.mp4",
"../video/videoplayback-4.mp4",
]

# Loop through video files and process them
for i, video_path in enumerate(video_paths):
output_path = f"../video/yolo_88_output_{i+1}.mp4"
process_video(model, video_path, output_path)

cv2.destroyAllWindows()

if __name__ == '__main__':
main()
  • make 2 video to side by side

Combine Two Videos Side by Side with OpenCV python

Thank you! ๐Ÿ˜บ

No comments:

Post a Comment