YoloNas slower than Yolov8

212 views Asked by At

as showed in the plot YoloNas-l should run much faster than YoloV8-l Inf times But when i am testing it my self in google-colab i am getting different results!

#installing pakcages
!pip install super-gradients==3.1.2
!pip install ultralytics
!pip install pytorch_quantization==2.1.3
!pip install boto3

import super_gradients
from ultralytics import YOLO
import time

!mkdir images
%cd ./images
!wget https://qph.cf2.poecdn.net/main-129957940_34140400692_36_1.png
!wget https://deci-pretrained-models.s3.amazonaws.com/sample_images/beatles-abbeyroad.jpg
!wget https://img.freepik.com/free-photo/view-tiger-animal-wild_23-2150374850.jpg
!wget https://www.fonedog.com/images/photo-compress/image-compressor-image.jpg
!wget https://static.addtoany.com/images/dracaena-cinnabari.jpg
!wget https://qph.cf2.poecdn.net/main-129957940_34139995188_34_1.png
!wget https://qph.cf2.poecdn.net/main-129957940_34139020340_37_1.png

%cd /content/images
import glob
types = ['*.png','*.jpg']
images =[]
for typ in types:
  for image in glob.glob(typ):
    images.append('/content/images/'+image)
    print('/content/images'+image)
nas_ult = NAS('yolo_nas_l.pt')
results = nas_ult.val(data='coco8.yaml')
yolov8 = YOLO("yolov8l.yaml")
yolov8 = YOLO("yolov8l.pt")
nas_inf= 0
nas_res=[]
v8_inf = 0
v8_res=[]
for image in images:
  nas_ult_preds = nas_ult(image,imgsz=640)
for image in images:
  yolov8_predictions = yolov8(image,imgsz=640)
for image in images:
  start = time.time()
  nas_ult_preds = nas_ult(image,imgsz=640)
  end = time.time()
  nas_res.append((nas_ult_preds, end-start))
  nas_inf += end-start
  start = time.time()
  yolov8_predictions = yolov8(image,imgsz=640)
  end = time.time()
  v8_res.append((yolov8_predictions, end-start))
  v8_inf += end-start

print('V8 time:',v8_inf)
print('NAS time:',nas_inf)

and this is my resualt

YoloNas-l time: 0.4496428966522217

YoloV8-l time: 0.399261474609375

why its happening?

2

There are 2 answers

2
Unreal Jack On

Its all about super_gradients VS ultralytics! just use yoloNAS with

1
Waleed Zaghloul On

Could You try on a file of 100 images, you will see the difference in speed in a case like this, yolo-nas takes a much longer time to call the model in the first run but after that, it is faster, but not that much of a difference. if you are looking for a fast model use the yolov8 Tensorrt it is said that it will give you x4 speed than the regular.pt model