Closed khalilxg closed 1 year ago
Yes, it is a known limitation. We have it on our todo list. As for now I suggest you iterating over frames of your video sequence manually and running per-frame prediction and processing results according to your needs:
predict_pipeline = model._get_pipeline()
for frame in frames:
predictions = predict_pipeline(frame)
... do something with predictions
@BloodAxe but in this way the pricessing of the video will take super too long, while we eliminated in this way the speeding mechanism of supergradients. This is a big problem
predict() was not designed for processing long videos in the first place. It was not designed to be efficient for inference tasks either. As I said earlier this is known issue and suggested you a workaround for now. Yes, I'm this version you won't get batched inference speedup, but it won't crash. It may change in future but as of now this is how it is
@BloodAxe thank you for ur support. Ill try to manage to edit video quality etc cuz in that way it can be processed ( change codex to rawvideo( doesnt vompress videos but itll make them super large) + resize the video
🐛 Describe the bug
im using super-gradients 3.3.0rc27211 my laptop is rtx30602ti i7 12th g 32G ram
i want to predict a one hour traffic video dimension 840*440 so im gonne predict it with batch size
but it seems anyway im running out of memory like the batch size param is not working !
// full code import os import cv2 import numpy as np import math from sort import Sort import os import cv2 import numpy as np import math from sort import Sort import torch from super_gradients.common.object_names import Models from super_gradients.training import models import cv2 import numpy as np import math from sort import *
Initialize class counters
class_counts_ns = [0] 8 # Counters for north to south direction class_counts_sn = [0] 8 # Counters for south to north direction tracked_vehicles = {} # To keep track of tracked vehicle IDs and their positions
Specify the path to your input video folder and output folder for text files
input_folder = 'input' output_folder = 'output'
Create the output folder if it doesn't exist
if not os.path.exists(output_folder): os.makedirs(output_folder)
Load the YOLO model
...
model = models.get(Models.YOLO_NAS_S, pretrained_weights='coco', checkpoint_path='/home/ubuntu/Downloads/convids/Dataset/test2/ckpt_best.pth', num_classes=8, batch_size=32) model = model.to("cuda" if torch.cuda.is_available() else "cpu")
Define class names
class_names = ["motorcycle", "car", "bus", "small truck", "big truck", "CM1"]
Confidence threshold for detections
confidence_threshold = 0.65
Font settings for displaying class counts
font = cv2.FONT_HERSHEY_SIMPLEX font_scale = 0.3 # Reduce font size to 0.3 font_thickness = 1 # Reduce font thickness to 1 font_color = (255, 255, 255) # White text color
Define table position and row height
row_height = 10 # Height of each row in the table
Initialize SORT tracker
tracker = Sort(max_age=1, min_hits=1, iou_threshold=0.01)
Create and open the results.txt file for appending
results_file_path = os.path.join(output_folder, 'results.txt') results_file = open(results_file_path, 'a')
Get the list of video files
video_files = sorted([f for f in os.listdir(input_folder) if f.endswith('.mp4')]) BATCH_SIZE=32
Process each video in the input folder in order
for video_file in video_files: MEDIA_PATH = os.path.join(input_folder, video_file)
Close the results file
results_file.close()
Close OpenCV windows
cv2.destroyAllWindows()
Versions
super-gradients 3.3.0rc27211