# Why I am not getting the same FPS for YuNet model

**URL:** <https://forum.opencv.org/t/why-i-am-not-getting-the-same-fps-for-yunet-model/20458>\
**Category:** Python\
**Tags:** dnn\
**Created:** [March 8, 2025, 1:48am UTC](https://forum.opencv.org/t/why-i-am-not-getting-the-same-fps-for-yunet-model/20458 "2025-03-08T01:48:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![KamalLagh](https://avatars.discourse-cdn.com/v4/letter/k/a5b964/32.png) [@KamalLagh](https://forum.opencv.org/u/KamalLagh)\
**Post date:** [March 8, 2025, 1:48am UTC](https://forum.opencv.org/t/why-i-am-not-getting-the-same-fps-for-yunet-model/20458/1 "2025-03-08T01:48:20Z")

</div>

Hello everyone,

I’m running a face detection application using OpenCV’s official YuNet model (`face_detection_yunet_2023mar.onnx`).

- **First Approach:** I use `cv2.FaceDetectorYN.create()` and call `.detect()`.
- **Second Approach:** I use `cv2.dnn.readNet(theonnxmodel)`, as shown in the code below.

When measuring FPS:

- The first approach achieves **35 FPS**.
- The second approach, using `cv2.dnn.readNet()`, achieves **only 3.5 FPS**.

### Question:

Could someone provide a detailed explanation of why there is such a large FPS difference between the two methods?

Thanks in advance!

```auto
    def detect(self, input_image):
        if input_image is None or input_image.size == 0:
            return None
        
        if input_image.shape[:2] != (self.inputH, self.inputW):
            raise ValueError("Size does not match. Call set_input_size(size) if input size does not match the preset size")

        pad_image = pad_with_divisor(input_image, self.padH, self.padW, self.inputH, self.inputW)
        input_blob = cv2.dnn.blobFromImage(pad_image)
        
        self.net.setInput(input_blob)
        output_names = ["cls_8", "cls_16", "cls_32", "obj_8", "obj_16", "obj_32", "bbox_8", "bbox_16", "bbox_32", "kps_8", "kps_16", "kps_32"]
        output_blobs = self.net.forward(output_names)

        return post_process(output_blobs, self.strides, self.padW, self.padH, self.scoreThreshold, self.nmsThreshold, self.topK)

```
