Coder Social home page Coder Social logo

derronqi / yolov8-face Goto Github PK

View Code? Open in Web Editor NEW
392.0 6.0 51.0 4.28 MB

yolov8 face detection with landmark

License: GNU General Public License v3.0

Dockerfile 0.22% Python 99.25% Shell 0.38% Cython 0.15%
insightface mtcnn retinaface yolov5 yolov5-face yolov7 yolov7-face yolov8 yolov8-face

yolov8-face's Introduction

yolov8-face

What's New

2024.04 ncnn-android-yolov8-face (🔥🔥🔥↑)

Method Test Size Easy Medium Hard FLOPs (B) @640 weights
yolov8-lite-t 640 90.3 87.5 72.8 - google
yolov8-lite-s 640 93.4 91.1 77.7 - google
yolov8n 640 94.5 92.2 79.0 - google
yolov8s 640 96.0 94.2 82.6 - -
yolov8m 640 96.6 95.0 84.1 - -
yolov9c 640 - - - - -
yolov9e 640 - - - - -

yolov8n-face

yolov8n-face

OpenCV demo

Android demo

QQ Group

QQ Group

References

yolov8-face's People

Contributors

derronqi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

yolov8-face's Issues

yolov8-face performance not as good as yolov7-face

Hello there,
I noticed that you have two repositories yolov7-face and yolov8-face that both use YOLO for face detection. However, it seems that the performance of yolov8-face is not as good as yolov7-face. I was wondering if you could share any insights on why this might be the case. Is there anything different between the two versions that could explain the performance difference?

How does the predictor postprocess the preds of model while infering? Cant find implementation.

I am trying to modify the predictor of ./ultralytics/yolo/engine/predictor.py,here is how it seems to perform postprocess :

with profilers[2]:
self.results = self.postprocess(preds, im, im0s)

but, the implementation of postprocess is nearly empty:

def postprocess(self, preds, img, orig_imgs):
"""Post-processes predictions for an image and returns them."""
return preds

So how does the postprocess happen? I can't find anything like NMS in the pipeline, really need help on understanding this, thanks in advance !!!

标注里没有landmark的框loss部分有做处理吗?

如题,新的yolov8face针对没有landmark框有做什么特别的处理吗?
我看代码里加载的模型是pose的,标注分3列,应该是x,y和visible,感觉没landm信息的可以通过visible决定是否计算loss,我用的yolov5face标注里是把没有landmark的框置为-1的,但是似乎v8不允许这种标注存在。
image

yolov8-lite-t AND yolov8-lite-s

How did you obtained the yolov8-lite-t and yolov8-lite-s. In the repo of https://github.com/ultralytics, there does not exists models yolov8-lite-t and yolov8-lite-t. I coould not find the source. Could you share with us? Did you do extra simplifications to obtain these onnx files?

Cannot use yolov8-lite-s

Hi,

I can use yolov8n but cannot seem to be able to use the other checkpoints: yolov8-lite-s and yolov8-lite-t

I tried installing latest version of ultralytics but then the weigths cannot be loaded.

I also tried using the custom folder ultralytics from this repo. In that case the weights can be loaded but inference then does not work.

Using YOLOv5s with this repo

Hi,

I am interested about investigating YOLOv5s based on this other repo of yours. However, I can see that this most recent repo implementing yolov8-face seems much cleaner and easy to use than the aforementioned repo, especially because you are using here the Ultralytics package.

Does this repo support training and inference of YOLOv5s? Thanks in advance.

Maxence

train model

Why output shape of the model trained with this code different from downloaded yolov8n-face.onnx?
train yolov8m-pose with my data
923a7c5e6a57af806487c7803c1d31d
yolov8n-face
2bdbb0c00e01ef68a577091b6db3bb1

数据集

请问你训练使用的数据集是哪一个,可以分享吗

5个关键点

你好,我输出模型并没有5个关键点,模型添加了关键点检测了吗?

widerface landmarks dataset

Could you please provide the dataset mentioned in this catalog?

path: /ssd2t/derron/datasets/ # dataset root dir
train: widerface/mixed # train images (relative to 'path') 4 images
val: widerface/val # val images (relative to 'path') 4 images
test: # test images (optional)

request

conv2d() received an invalid combination of arguments - got (Tensor, Parameter, Parameter, tuple, tuple, tuple, int), but expected one of:

  • (Tensor input, Tensor weight, Tensor bias, tuple of ints stride, tuple of ints padding, tuple of ints dilation, int groups)
    didn't match because some of the arguments have invalid types: (Tensor, !Parameter!, !Parameter!, !tuple of (int, int)!, !tuple of (int, int)!, !tuple of (bool, bool)!, int)
  • (Tensor input, Tensor weight, Tensor bias, tuple of ints stride, str padding, tuple of ints dilation, int groups)
    didn't match because some of the arguments have invalid types: (Tensor, !Parameter!, !Parameter!, !tuple of (int, int)!, !tuple of (int, int)!, !tuple of (bool, bool)!, int)

Can't load my own exported .onnx model from official yolov8n-face.pt, how to correctly export .pt to .onnx model?

I export official yolov8n-face.pt model to .onnx like this

pt_model = YOLO('../../../.deepface/weights/yolov8n-face.pt')
pt_model.export(format='onnx', opset=12)

Then I load my own .onnx after I export the model like this

onnx_model = YOLOv8_face('../../../.deepface/weights/yolov8n-face.onnx')

But, I got an error

---------------------------------------------------------------------------
error                                     Traceback (most recent call last)
Cell In[45], [line 4](vscode-notebook-cell:?execution_count=45&line=4)
      [1](vscode-notebook-cell:?execution_count=45&line=1) # onnx_model = YOLOv8('../../../.deepface/weights/yolov8n-face.onnx')
      [2](vscode-notebook-cell:?execution_count=45&line=2) # onnx_model = YOLOv8('c:/Users/febri/Downloads/yolov8n-face.onnx')
      [3](vscode-notebook-cell:?execution_count=45&line=3) # onnx_model = YOLOv8_face('c:/Users/febri/Downloads/yolov8n-face.onnx')
----> [4](vscode-notebook-cell:?execution_count=45&line=4) onnx_model = YOLOv8_face('../../../.deepface/weights/yolov8n-face.onnx')

File [c:\Users\febri\projects\EATS_AI\development\YOLOv8_OpenCV\main.py:13](file:///C:/Users/febri/projects/EATS_AI/development/YOLOv8_OpenCV/main.py:13), in YOLOv8_face.__init__(self, path, conf_thres, iou_thres)
     [11](file:///C:/Users/febri/projects/EATS_AI/development/YOLOv8_OpenCV/main.py:11) self.num_classes = len(self.class_names)
     [12](file:///C:/Users/febri/projects/EATS_AI/development/YOLOv8_OpenCV/main.py:12) # Initialize model
---> [13](file:///C:/Users/febri/projects/EATS_AI/development/YOLOv8_OpenCV/main.py:13) self.net = cv2.dnn.readNet(path)
     [14](file:///C:/Users/febri/projects/EATS_AI/development/YOLOv8_OpenCV/main.py:14) self.input_height = 640
     [15](file:///C:/Users/febri/projects/EATS_AI/development/YOLOv8_OpenCV/main.py:15) self.input_width = 640

error: OpenCV(4.8.1) [D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\onnx\onnx_importer.cpp:1083](file:///D:/a/opencv-python/opencv-python/opencv/modules/dnn/src/onnx/onnx_importer.cpp:1083): error: (-2:Unspecified error) in function 'cv::dnn::dnn4_v20230620::ONNXImporter::handleNode'
> Node [[email protected]]:(onnx_node!/model.10/Floor) parse error: OpenCV(4.8.1) [D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\layers\elementwise_layers.cpp:261](file:///D:/a/opencv-python/opencv-python/opencv/modules/dnn/src/layers/elementwise_layers.cpp:261): error: (-215:Assertion failed) src.size == dst.size && src.type() == dst.type() && src.isContinuous() && dst.isContinuous() && src.type() == CV_32F in function 'cv::dnn::ElementWiseLayer<struct cv::dnn::FloorFunctor>::forward'
>

Am I wrong in exporting the .pt model to .onnx?

CPP yolov8 detection boxes not right position

Hi,

I try to test with my images but boxes detection position all left corner not datected face what is the problem here:
left green

Best


`#include <iostream>
#include <vector>
#include <getopt.h>

#include <opencv2/opencv.hpp>

#include "inference.h"

using namespace std;
using namespace cv;

int main(int argc, char **argv)
{
    std::string projectBasePath = "/home/user/ultralytics"; // Set your ultralytics base path

    bool runOnGPU = true;

    //
    // Pass in either:
    //
    // "yolov8s.onnx" or "yolov5s.onnx"
    //
    // To run Inference with yolov8/yolov5 (ONNX)
    //

    // Note that in this example the classes are hard-coded and 'classes.txt' is a place holder.
    Inference inf("/data/dProjects/yolov8-face-landmarks-opencv-dnn/weights/yolov8n-face.onnx", cv::Size(640, 480), "classes.txt", runOnGPU);

    std::vector<std::string> imageNames;
    imageNames.push_back( "/home/alp2080/face_detector_3.jpg");
    imageNames.push_back( "/home/alp2080/detector_2.jpg");

    for (int i = 0; i < imageNames.size(); ++i)
    {
        cv::Mat frame = cv::imread(imageNames[i]);

        // Inference starts here...
        std::vector<Detection> output = inf.runInference(frame);

        int detections = output.size();
        std::cout << "Number of detections:" << detections << std::endl;

        for (int i = 0; i < detections; ++i)
        {
            Detection detection = output[i];

            cv::Rect box = detection.box;
            cv::Scalar color = detection.color;

            // Detection box
            cv::rectangle(frame, box, cv::Scalar(0, 255, 0), 3);

            // Detection box text
            std::string classString = detection.className + ' ' + std::to_string(detection.confidence).substr(0, 4);
            cv::Size textSize = cv::getTextSize(classString, cv::FONT_HERSHEY_DUPLEX, 1, 2, 0);
            cv::Rect textBox(box.x, box.y - 40, textSize.width + 10, textSize.height + 20);

            cv::rectangle(frame, textBox, color, cv::FILLED);
            cv::putText(frame, classString, cv::Point(box.x + 5, box.y - 10), cv::FONT_HERSHEY_DUPLEX, 1, cv::Scalar(0, 0, 0), 2, 0);
        }
        // Inference ends here...

        // This is only for preview purposes
        float scale = 0.8;
        cv::resize(frame, frame, cv::Size(frame.cols*scale, frame.rows*scale));
        cv::imshow("Inference", frame);

        cv::waitKey(-1);
    }
}
`
Screen Shot 2023-10-16 at 21 56 51

Error:IndexError: The shape of the mask [40, 40] at index 0 does not match the shape of the indexed tensor [80, 40, 40] at index 0

HI,When I infer using yolov8n-face.engine,it's not work,Has anyone encountered it?Details as below:

`Traceback (most recent call last):

File "/home/admin/PycharmProjects/yolov8_face/inference_trt.py", line 360, in
face_det_results, full_frames, fps, img_size, static = pre_init(face=face, img_size=img_size)

File "/home/admin/PycharmProjects/yolov8_face/inference_trt.py", line 189, in pre_init
face_det_results.extend(face_detect(full_frames[idx:idx + yolo_batch], box=box, static=static, pads=pads, nosmooth=nosmooth))

File "/home/admin/PycharmProjects/yolov8_face/yolov8_face.py", line 122, in face_detect
face_det_results = face_detect_yolo(frames, pads=pads, nosmooth=nosmooth) # BGR2RGB for CNN face detection

File "/home/admin/PycharmProjects/yolov8_face/yolov8_face.py", line 43, in face_detect_yolo
for result in results:

File "/home/admin/miniconda3/envs/w2ltrt/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 35, in generator_context
response = gen.send(None)

File "/home/admin/PycharmProjects/yolov8_face/yolov8-face/ultralytics/yolo/engine/predictor.py", line 256, in stream_inference
self.results = self.postprocess(preds, im, im0s)

File "/home/admin/PycharmProjects/yolov8_face/yolov8-face/ultralytics/yolo/v8/detect/predict.py", line 14, in postprocess
preds = ops.non_max_suppression(preds,

File "/home/admin/PycharmProjects/yolov8_face/yolov8-face/ultralytics/yolo/utils/ops.py", line 219, in non_max_suppression
x = x[xc[xi]] # confidence
IndexError: The shape of the mask [40, 40] at index 0 does not match the shape of the indexed tensor [80, 40, 40] at index 0`

export yolov8-lite-s and yolov8-lite-t error

yolo mode=export model=yolov8-lite-s.pt format=onnx simplify=True batch=1
Traceback (most recent call last):
File "/home/pcb/.local/bin/yolo", line 8, in
sys.exit(entrypoint())
File "/home/pcb/.local/lib/python3.8/site-packages/ultralytics/yolo/cfg/init.py", line 378, in entrypoint
model = YOLO(model, task=task)
File "/home/pcb/.local/lib/python3.8/site-packages/ultralytics/yolo/engine/model.py", line 107, in init
self._load(model, task)
File "/home/pcb/.local/lib/python3.8/site-packages/ultralytics/yolo/engine/model.py", line 156, in _load
self.model, self.ckpt = attempt_load_one_weight(weights)
File "/home/pcb/.local/lib/python3.8/site-packages/ultralytics/nn/tasks.py", line 578, in attempt_load_one_weight
ckpt, weight = torch_safe_load(weight) # load ckpt
File "/home/pcb/.local/lib/python3.8/site-packages/ultralytics/nn/tasks.py", line 518, in torch_safe_load
return torch.load(file, map_location='cpu'), file # load
File "/home/pcb/.local/lib/python3.8/site-packages/torch/serialization.py", line 607, in load
return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
File "/home/pcb/.local/lib/python3.8/site-packages/torch/serialization.py", line 882, in _load
result = unpickler.load()
File "/home/pcb/.local/lib/python3.8/site-packages/torch/serialization.py", line 875, in find_class
return super().find_class(mod_name, name)
AttributeError: Can't get attribute 'StemBlock' on <module 'ultralytics.nn.modules' from '/home/pcb/.local/lib/python3.8/site-packages/ultralytics/nn/modules/init.py'>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.