derronqi / yolov8-face Goto Github PK
View Code? Open in Web Editor NEWyolov8 face detection with landmark
License: GNU General Public License v3.0
yolov8 face detection with landmark
License: GNU General Public License v3.0
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
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?
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);
}
}
`
@derronqi I want to use this repo in my project, If I have the Ultralytics license can I use this one freely?
Hello,
where is yolov8-lite-t yaml files, please?
数据集在哪里下载?
ONNX and pt , please!
请问你训练使用的数据集是哪一个,可以分享吗
Will you be releasing other weights files?
Thanks
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'>
Is it similar to yolov5-face-n?
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.
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`
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?
你好,我输出模型并没有5个关键点,模型添加了关键点检测了吗?
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?
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)
conv2d() received an invalid combination of arguments - got (Tensor, Parameter, Parameter, tuple, tuple, tuple, int), but expected one of:
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 !!!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.