darknet | Convolutional Neural Networks | Machine Learning library

 by   pjreddie C Version: Current License: Non-SPDX

kandi X-RAY | darknet Summary

kandi X-RAY | darknet Summary

darknet is a C library typically used in Artificial Intelligence, Machine Learning, Deep Learning applications. darknet has no bugs, it has no vulnerabilities and it has medium support. However darknet has a Non-SPDX License. You can download it from GitHub.

Darknet is an open source neural network framework written in C and CUDA. It is fast, easy to install, and supports CPU and GPU computation. Discord invite link for for communication and questions:

            kandi-support Support

              darknet has a medium active ecosystem.
              It has 24296 star(s) with 21425 fork(s). There are 907 watchers for this library.
              It had no major release in the last 6 months.
              There are 1794 open issues and 547 have been closed. On average issues are closed in 358 days. There are 164 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of darknet is current.

            kandi-Quality Quality

              darknet has 0 bugs and 0 code smells.

            kandi-Security Security

              darknet has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              darknet code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              darknet has a Non-SPDX License.
              Non-SPDX licenses can be open source with a non SPDX compliant license, or non open source licenses, and you need to review them closely before use.

            kandi-Reuse Reuse

              darknet releases are not available. You will need to build from source code and install.
              Installation instructions are not available. Examples and code snippets are available.
              It has 275 lines of code, 11 functions and 6 files.
              It has medium code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of darknet
            Get all kandi verified functions for this library.

            darknet Key Features

            No Key Features are available at this moment for darknet.

            darknet Examples and Code Snippets

            Initialize the darknet layers
            pythondot img1Lines of Code : 11dot img1License : Permissive (MIT License)
            copy iconCopy
            def __init__(self, cfgfile):
                    super(Darknet, self).__init__()
                    self.blocks = parse_cfg(cfgfile)
                    self.models = self.create_network(self.blocks) # merge conv, bn,leaky
                    self.loss = self.models[len(self.models)-1]

            Community Discussions


            Exporting Yolov5 bboxes to Pascal format
            Asked 2022-Jan-26 at 14:19

            There have been already some similar style questions asked before (1, 2) However, none have mentioned the new Yolov5 style annotations.

            Is there a simple function that takes in a normalized Yolov5 bounding box like:-



            Answered 2021-Nov-17 at 18:39

            There is no direct way to convert the normalized Yolo format to another format like Pascal VOC, because you need to know the size of the image to do the conversion. (Just like you need to know the size of the image to convert it to the normalized yolo format in the first place.) You will also want to provide some mapping to convert the class numbers to class names.

            I am working on a Python package to simplify these kinds of conversions called PyLabel. I have a sample notebook that will convert Yolo v5 annotations to VOC format here https://github.com/pylabel-project/samples/blob/main/yolo2voc.ipynb. You can open it in Colab using this link.

            The core code will be something like this:

            Source https://stackoverflow.com/questions/69994481


            Determine if certain parts of an RGB image are colored or grayscale using numpy
            Asked 2022-Jan-14 at 06:35

            I am trying to determine if certain parts of an RGB image are colored or grayscale, using python, opencv and numpy libraries. To be more spesific, in an RGB image I determine face locations using neural networks and when that image contains printed photos I would like to find out if the face location in that image is grayscale or colored.

            What I tried so far:



            Answered 2022-Jan-10 at 18:06

            How about finding the max difference in every pixel of the cropped image and then taking the STD of them. With the gray scaled image, that value must be small compared with colored ones.

            Source https://stackoverflow.com/questions/70608915


            How to show few correct bounding boxes instead of all detectiones in YOLOv3
            Asked 2022-Jan-05 at 18:39

            This is my first YOLOv3 project to detect objects with 2 classes. In the resuls I am seeing plenty of detections. Is it possible to show only those boxes which has more than 70% (for example) accuracy or lets say top 3 boxes for each class? Would somebody please help?

            my test is executed as follows: !./darknet detector test data/obj.data cfg/yolov3_custom.cfg ~/yolov3_custom_last.weights /content/5.png



            Answered 2022-Jan-05 at 10:35

            You must set 0.7 threshold value, if you want see only boxes which has more than 70% confidence score.

            like this !./darknet detector test data/obj.data cfg/yolov3_custom.cfg ~/yolov3_custom_last.weights /content/5.png -thresh 0.7

            Source https://stackoverflow.com/questions/70580221


            Darknet Yolov3 - Custom training on pre-trained model
            Asked 2021-Oct-25 at 02:03

            Actually in darknet yolov3 model has coco.names file for labels which include 80 classes. Now if I want to train a custom model with two labels only, where one label is already there in coco.names and another is not there.

            For example I want to train a model to detect for cell phone and dslr camera, so cell phone class already exist in coco.names whereas dslr camera is not there in its labels file.

            So can I train custom model using two classes cell phone and dslr camera and give data of only dslr camera for training and it will predict for both dslr camera and cell phone or shall I train with both data of cell phone and dslr images or is there any other way out.

            I am a bit new to ML, so any help would be great Thanks



            Answered 2021-Oct-25 at 02:03

            So you want to fine tune a pre-trained model. You need to think of classes by just being a set of end nodes of a network, the labels (phone, camera) are just a naming convention for them, and to give us visual guidance.

            These nodes are fully connected (with associated weights) to the previous layer of the network, the total number of these intermediate connections varies depending on the number of end nodes (classes) you have.

            With the fully trained model, you can't just select the nodes you want, and take out the rest, and add a few more. Because the previous layer (and full network) was trained to give estimates/predictions taking into account a certain number of final nodes.

            So basically you need to give a full reset on the last layer (the head), and restart it with the desired number of classes. The idea here, is that you take advantage of the previous training effort on a broader dataset, and fine tune it to your desired data.

            Short answer, you need data for both, and need to change the model to accept 2 classes only.

            To configure that specific model for the new number of classes and data, I believe you can find some guidance and instructions here

            Source https://stackoverflow.com/questions/69699422


            Extra class prediction result shown when testing on AlexeyAB Yolov4 Darknet package on Colab
            Asked 2021-Oct-24 at 22:10

            I have done the model training for Yolov4 objection detection from AlexeyAB Darknet package on Colab. (from https://github.com/AlexeyAB/darknet) Two classes are defined named "scratch" and "blood". Then run the following commands for testing on a single image:

            !./darknet detector test data/obj.data cfg/yolo-obj.cfg backup/yolo-object_last.weights images/meat/test/376.jpg -dont show

            and the result is shown below. It's expected that there are only one scratch and blood shown with probabilities in the result. However, it shows so many scratch and blood predictions (the last few lines of this post)! The number of classes (=2), class names, and shoud have been set properly in obj.data and yolo-obj.cfg. Can anyone advice why and how to resolve it?



            Answered 2021-Oct-24 at 22:10

            This is normal behaviour.

            You are "always" going to get a lot of detections. But you can also see that some of your detections are below the 50% confidence score. Which should be discarded.

            I think the pipeline already performs Non-maximum suppression (NMS) to remove duplicates and overlapping detections (not sure), but you can additionally set up confidence score threshold as well, to show only above 50% with -thresh 0.5

            This will give you final expected results. Still, if you continue to obtain more than you should, well, this is the goal of everyone :)

            It's all about hyperparameter tuning and more data to train our models to give our desired outcome.

            Source https://stackoverflow.com/questions/69688505


            YoloV3 Result Giving Zero confidence in every class
            Asked 2021-Sep-24 at 02:39

            I Am Doing Implementation Of Yolo v3 for multi class object detection

            yolo is algorithm based region proposal and the region proposal with max confidence treated as prediction of yolo for more you can read it about here

            for this particular task i refer to this murtuza tutorial that guided me from scratch

            now as the complex network architecture requires hours of training i prefer to use transfer learning as using pretrained network and weighs(parameters) both of this link you can find here
            Architecture configuration:cfg
            Network Parameters(weights):weights

            i used here yolov3 tiny as i required higher frame rates to process a video but afterall it not giving promising result as the tutorial shows i don't where i am lacking but even changing the network cfg and weight file to the orignal yolov3(320)does not giving true result as i am getting all 5 spatial data as coordinate and confidence [cx,cy,h,w,confidence] but all 80 classes probality is still zero vector[0.0,0.0,0.0---0.0] even changing the video source and choosing another video resulting into zero vector which was in tutorial working fine

            Implementation Code:



            Answered 2021-Sep-24 at 02:39

            You have many problems with your code.

            1. You have to use the h,w that you got from the image and not your default width and height that you use to blob the image for the YoloV3.


            Source https://stackoverflow.com/questions/69244618


            Why am I getting a CUDA Error when calculating mAP in darknet YOLOv2 in Google Colab?
            Asked 2021-Sep-16 at 17:32

            Code that used to work a month or two ago now posts the following error:



            Answered 2021-Sep-16 at 17:32

            It appears that Google Colab has reduced the memory allowed for free notebooks.

            Changing the config file from batch=64 and subdivisions=2 to batch=32 and subdivisions=8 solved this problem for me.

            Source https://stackoverflow.com/questions/69199492


            CUDA error when running Darknet YOLOv4 on Google Colab
            Asked 2021-Sep-16 at 17:27

            I think a recent update with either Colab or Cuda is throwing off the YOLOv4 model. I have previously built this notebook and trained a complete model with it with no problems but now when I run the exact same code, with no changes, I get this problem:



            Answered 2021-Sep-16 at 17:27

            It appears that Google Colab has reduced the memory allowed for free notebooks.

            Try changing the batch size and subdivisions in your config.

            batch=32 and subdivisions=8 solved this problem for me.

            Source https://stackoverflow.com/questions/68630911


            C-type pointer to floats changes after returning from function in python
            Asked 2021-Sep-16 at 16:41

            I'm currently working on a Darknet/YOLO project which detects objects from images received from a live stream using opencv in python. To detect object, the opencv image, which is simply a numpy array with shape (height, width, color_channels) has to be converted into a format that Darknet (written in c) can read (an IMAGE class defined in Darknet with a data attribute of type *float). For this I have written the following code in python:



            Answered 2021-Sep-16 at 16:41

            Storing the data pointer in IMAGE doesn't keep a reference to the image data. Once flattened_image and c_float_p_frame go out of scope the data is freed. Store an extra reference in the image to keep the data from being freed:

            Source https://stackoverflow.com/questions/69204075


            Demo needs OpenCV for webcam images.(opencv is installed and set opencv4=1)
            Asked 2021-Sep-13 at 07:13

            I am trying to do object detection from a video file by using https://github.com/pjreddie/darknet. I've installed libopencv-dev for opencv. I've set opencv4=1 in Makefile.

            And run this code. ./darknet detector demo cfg/coco.data cfg/yolo-tiny-obj.cfg yolov3.weights data/1.mp4 And got error Demo needs OpenCV for webcam images.

            Could anyone help me? Thanks.



            Answered 2021-Sep-13 at 07:13
            1. Try to clean make file and recompile darknet

            Source https://stackoverflow.com/questions/69151313

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network


            No vulnerabilities reported

            Install darknet

            You can download it from GitHub.


            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
          • HTTPS


          • CLI

            gh repo clone pjreddie/darknet

          • sshUrl


          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link