Home > Back-end >  Replacing append with concat for yolo predictions
Replacing append with concat for yolo predictions

Time:08-05

I have read a bunch of posts related to the similar problems but I still don't understand how i can replace append with concat for my use case. I was using it for months as it is by just slapping this

warnings.simplefilter(action='ignore', category=FutureWarning)

car_model is a yolov5 model, whose results i have to iterate one by one, while confirming if the confidence is above a specific value. I just want to ask, does it even make sense for my use case to use concat instead of append since i have to iterate all the output ever single time anyway.

pred0 = car_model(frame, augment=False)
pred_df = pd.DataFrame()
for i, row in pred0.pandas().xyxy[0].iterrows():
   if row['confidence'] > confidence:
         pred_df = pred_df.append(row)
    

CodePudding user response:

You don't need to iterate over the dataframe. In fact, if the dataframe is huge then this would be very slow. You can avoid concatenating altogether by getting your pred_df like below:

pred0 = car_model(frame, augment=False)
pred0_df = pred0.pandas().xyxy[0]

pred_df = pred0_df[pred0_df['confidence'] > confidence]
  • Related