rushad7 / mask-detection Goto Github PK
View Code? Open in Web Editor NEWThis Python script is used to detect whether a people in the given image are wearing a mask or not. The custom dataset was trained using Darknet.
This Python script is used to detect whether a people in the given image are wearing a mask or not. The custom dataset was trained using Darknet.
./darknet detector train ./cfg/voc.data ./cfg/yolov3-custom.cfg darknet53.conv.74
running in your guide using your test data
https://towardsdatascience.com/real-time-mask-detection-with-yolov3-21ae0a1724b4
darknet: ./src/parser.c:315: parse_yolo: Assertion `l.outputs == params.inputs' failed.
Aborted (core dumped)
Hello,
I got errors both running live video and image samples. What can be the problem?
python yolo-live-cv2.py --yolo yolo
[INFO] loading YOLO from disk
Traceback (most recent call last):
File "yolo-live-cv2.py", line 32, in
net = cv2.dnn.readNetFromDarknet(configPath, weightsPath)
cv2.error: OpenCV(4.2.0) /io/opencv/modules/dnn/src/darknet/darknet_io.cpp:712: error: (-213:The function/feature is not implemented) Transpose the weights (except for convolutional) is not implemented in function 'ReadDarknetFromWeightsStream'
python custom_detector.py --image /home/fikret/project/yolov3_projects/face-mask-detector/dataset/with_mask/0-with-mask.jpg --config cfg/yolov3-custom.cfg --weights weights/yolov3-custom_final.weights --names class_names/custom.names
Traceback (most recent call last):
File "custom_detector.py", line 18, in
net = cv2.dnn.readNetFromDarknet(args.config, args.weights)
cv2.error: OpenCV(4.2.0) /io/opencv/modules/dnn/src/darknet/darknet_io.cpp:712: error: (-213:The function/feature is not implemented) Transpose the weights (except for convolutional) is not implemented in function 'ReadDarknetFromWeightsStream'
how many images did you use to train the model.
i used approx 500 images for 1 class but still the output is not correct.
Like it is not showing bounding boxes for all the images and in some cases wrong,
what could be the possible error?
The weights file does not seem to contain the pre-trained weights. I think there may be some git large file error. The yolov3-custom_final.weights file just contains the following 3 lines
version https://git-lfs.github.com/spec/v1
oid sha256:294e8acd929267bf458019d6aee18559d9605c1f7081e8ddbca99cba37897f93
size 246326928
I'm try using the test_train_split.py to create the train data and test data.
But, it doesn't work.
So, i'm trying to modify.It's still doesn't work...
It can't go into the for loop.
As like this:
''' Usage :
python test_train_split.py -d ~/mask-detection/annotations/
'''
import glob, os
import argparse
ap = argparse.ArgumentParser()
ap.add_argument("-d", "--dir", required=True, help="Directory of dataset")
args = vars(ap.parse_args())
img_dir = str(args["dir"])
print(args["dir"])
percentage_test = 10;
#file_train = open(r'../train_test/train.txt', 'a')
#file_test = open(r'../train_test/test.txt', 'a')
counter = 1
index_test = round(100 / percentage_test)
for pathAndFilename in glob.iglob(os.path.join(img_dir, "*.jpg")):
title, ext = os.path.splitext(os.path.basename(pathAndFilename))
print("for")
if int(counter) == int(index_test):
print("test")
counter = 1
file_test = open(r'~/train_test/train.txt', 'a')
file_test.write(img_dir + "/" + title + '.jpg' + "\n")
file_test.close()
else:
print("train")
file_train = open(r'~/train_test/test.txt', 'a')
file_train.write(img_dir + "/" + title + '.jpg' + "\n")
file_train.close()
counter = counter + 1
Please help me, thank you!
I opened your config file and it does not show 2 classes. it shows 80 classes. And you say directly use this to test however, your config file is in the training mode. Plus, the custom weights file is not even a weights file.
While trying to run the following:
python3 custom_detector.py --image "/home/nvr/rushad7/mask-detection/images/example_01.png" --config "/home/nvr/rushad7/mask-detection/cfg/yolov3-custom.cfg" --weights "/home/nvr/rushad7/mask-detection/weights/yolov3-custom_final.weights" --names "/home/nvr/rushad7/mask-detection/class_names/voc.names"
I get the following error:
Traceback (most recent call last):
File "custom_detector.py", line 18, in <module>
net = cv2.dnn.readNetFromDarknet(args.config, args.weights)
cv2.error: OpenCV(4.3.0-openvino) ../opencv/modules/dnn/src/darknet/darknet_io.cpp:847: error: (-213:The function/feature is not implemented) Transpose the weights (except for convolutional) is not implemented in function 'ReadDarknetFromWeightsStream'
I opened the weights file and it seems to have a git lfs download link and oid...
How do I download the real weights file?
UPDATE:
git lfs fetch
fetch: Fetching reference refs/heads/master
batch response: This repository is over its data quota. Account responsible for LFS bandwidth should purchase more data packs to restore access.
error: failed to fetch some objects from 'https://github.com/rushad7/mask-detection.git/info/lfs'
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.