Welcome to Schema.org
This is the Schema.org project repository. It contains all the schemas, examples and software used to publish schema.org. For the site itself, please see Schema.org instead.
Note: Much of the supporting software is imported from a sub module: 'sdopythonapp'
Issues and proposals are managed here by collaborators around the project, especially participants of the W3C Schema.org Community Group. If you are interested to participate please join the group at the W3C, introduce yourself and find or file issues here that engage your interest. If you are new to Git and GitHub, there's a useful introduction to GitHub in the W3C Wiki.
There are also continuous integration tests to check incoming pull requests.
Issue #1 in GitHub is an entry point for release planning. It should provide an overview of upcoming work, in terms of broad themes, specific issues and release milestones. Issue #1 will link to per-release entry points, or else navigate issues via label or milestone within GitHub.
Every change to the site comes via discussions here. Substantive changes are recorded in our release notes. A preview of the draft new release notes can be found as part of the test site for our next release. Every month or so, after final review by the Schema.org Steering Group and wider community, we make a formal release.
Regarding CC and opensource licenses for documents and software, see our FAQ entry.
We are always interested in practical suggestions for improvements to schema.org, and our collection of schemas has been growing gradually since our launch in 2011. We try to prioritize simple fixes and improvements to our existing schemas, examples and documentation over the addition of new vocabulary, and we are most likely to add new schemas when there is evidence that some (preferably large-scale) consuming application will make use of the data. Consuming applications need not be search engines; software tools (e.g., opensource, markup-enriched approaches to Web analytics, browser add-ons or cloud tools) are all rich areas for exploration and collaboration. The important thing is that there should be some reasonable expectation of data consumers making good use of the changes. It is not sufficient to justify additions on the basis that search engines generally try to use Schema.org-based structured data. Smaller changes, and backwards-compatible changes, are easier to incorporate.
Note: Schema.org does not attempt to capture the full detail of Web content; it is necessarily a simplification of a more complex reality. This means that there will be many cases where adding more detail to Schema.org will look possible. However, in the interests of keeping Schema.org simple and usable for publishers and webmasters, we will often choose not to add such detail.
Schema.org uses Web standards such as JSON-LD, Microdata and RDFa to allow for independent extension (for example, see GS1's vocabulary).
We are also highly unlikely to take on large scale reorganizations of Schema.org's terminology, if they are motivated solely by considerations of elegance, "proper modeling", ontological purity or conceptual unification. Although the project founders and team are familiar with - and respectful of - the traditions behind such concerns, the scale, scope and nature of Schema.org has required us to trade elegance and global consistency for a somewhat scruffier notion of incremental evolution and a pragmatic tolerance for a style that would be out of place in a formal ontology. Proposals for unifying, cross-domain logic-based knowledge structures may be better received e.g. in the Ontolog community.
We sometimes introduce types without dedicated property associations, simply for markup usability reasons. In a formal ontology, this is often considered poor modeling. However, logically equivalent structures can result in many more errors from publishers/webmasters unfamiliar with the underlying formal concepts behind JSON-LD or RDF/S.
Schema.org is not a closed system, and other initiatives (e.g., Wikidata or GS1) have defined many other terms that can be mixed in alongside those we define at schema.org. We also make efforts to align our designs to relevant external standards and initiatives, even when it reduces the global elegance of Schema.org considered alone. For example, in a bibliographic or cultural heritage context, we may be influenced by initiatives like MARC, BibFrame, and FRBR, while for e-commerce we collaborated with Good Relations and GS1. Schema.org's news-related terms were heavily influenced by incorporating IPTC's rNews design, alongside collaborations with fact checkers, the Trust Project, and others. Our TV and Music related vocabularies are heavily influenced by working with the BBC and the European Broadcasting Union, alongside the Music ontology and MusicBrainz; our schemas reflect these prior designs. We prefer to collaborate in this way, improving Schema.org incrementally and working to polish, integrate and blend such designs rather than produce our own pure model in isolation. The result may lack global elegance but brings our work into alignment with related efforts worldwide.
We always welcome issues that track usability and readability issues, but encourage a focus on concrete situations (e.g., how to describe repeating events) rather than global philosophical concerns (e.g., whether a Reservation or Action is "really" an Event). We prioritize local coherence (having sensible ways to describe many common situations) over global elegance (having a global theory in which everything has a sensible place). This doesn't mean we never have cleanups, but they are balanced against (and often outweighed by) other considerations.
When we add terms, often into the "Pending" area, we strongly encourage feedback that takes a global perspective: how does a new term relate to others, how could it be used alongside pre-existing patterns, etc. The changes we make during this integration phase reflect such considerations, but are usually expressed through modest rewording, examples, or adjustment to the documentation of type/property links, rather than through major restructuring.
See more on "How we work"
For most collaborators, all you need to know about the software is how to run it. The objective of the software is to create a static copy of the Schema.org site, including potential local changes, to inspect and run behind a simple web server on a local system for testing. In the same way that a production release is deployed to a cloud server, your local version could then be deployed to a virtual machine using gcloud to enable collaboration with others.
Full instructions are available in SOFTWARE_README.md explaining how to create the initial local copy to work with, then evolve to test out any changes. Essentially you will need to have a Linux-like (inc Mac) environment loaded with Python version 3.6 or above. You can then make test builds of schema.org running on your own machine accessible as http://localhost:8080/ or else post them on appspot.com for collaboration. See the Appengine documentation for details of the relevant gcloud commands.
More detailed information about the software and its use is available in SOFTWARE_README.md. See also notes in the wiki: https://github.com/schemaorg/schemaorg/wiki/Contributing
All schemas and examples are in data/ in utf-8 encoded files.
The main schemas file is data/schema.ttl (utf-8).
While developing schemas, using data/sdo-somethinghere-schema.ttl can be useful.
The format is based on W3C RDFS in RDF/Turtle format.
The examples are stored in data/examples.txt (utf-8) and other .txt files.
As with schemas, data/examples.txt will also be read. It can be useful to develop using separate files.
When vocabulary is finally integrated into the main repository, schema data will be merged into schema.org. However, examples will stay in separate files, as this works better with git's file comparison machinery.
The data/releases/ hierarchy is reserved for release snapshots (see https://schema.org/version/).
The ext// hierarchy is reserved for extensions (see https://schema.org/docs/extension.html).
We no longer use github branches for work-in-progress. The main/ branch is our latest candidate. It is not guaranteed to be in a conceptually consistent state, but should stabilize prior to circulation of a release candidate for review.
This documentation concerns the software codebase rather than schema.org itself. However, do note that labels, comments, and documentation should use US English (in the code and schemas), if a choice between English variants is needed. Please aim for international English wherever possible.
See also: https://twitter.com/schemaorg_dev
Example:
`
Apache-2.0 license
Table of Contents
Darknet Object Detection Framework and YOLO
Papers
General Information
Darknet Version
MSCOCO Pre-trained Weights
Building
Google Colab
Linux CMake Method
Windows CMake Method
Using Darknet
CLI
Training
Other Tools and Links
Roadmap
Short-term goals
Mid-term goals
Long-term goals
Darknet Object Detection Framework and YOLO
darknet and hank.ai logos
Darknet is an open source neural network framework written in C, C++, and CUDA.
YOLO (You Only Look Once) is a state-of-the-art, real-time, object detection system, which runs in the Darknet framework.
Read how Hank.ai is helping the Darknet/YOLO community
Announcing Darknet V3 "Jazz"
See the Darknet/YOLO web site
Please read through the Darknet/YOLO FAQ
Join the Darknet/YOLO discord server
Papers
Paper YOLOv7
Paper Scaled-YOLOv4
Paper YOLOv4
Paper YOLOv3
General Information
The Darknet/YOLO framework continues to be both faster and more accurate than other frameworks and versions of YOLO.
This framework is both completely free and open source. You can incorporate Darknet/YOLO into existing projects and products -- including commercial ones -- without a license or paying a fee.
Darknet V3 ("Jazz") released in October 2024 can accurately run the LEGO dataset videos at up to 1000 FPS when using a NVIDIA RTX 3090 GPU, meaning each video frame is read, resized, and processed by Darknet/YOLO in 1 millisecond or less.
Please join the Darknet/YOLO Discord server if you need help or you want to discuss Darknet/YOLO: https://discord.gg/zSq8rtW
The CPU version of Darknet/YOLO can run on simple devices such as Raspberry Pi, cloud & colab servers, desktops, laptops, and high-end training rigs. The GPU version of Darknet/YOLO requires a CUDA-capable GPU from NVIDIA.
Darknet/YOLO is known to work on Linux, Windows, and Mac. See the building instructions below.
Darknet Version
The original Darknet tool written by Joseph Redmon in 2013-2017 did not have a version number. We consider this version 0.x.
The next popular Darknet repo maintained by Alexey Bochkovskiy between 2017-2021 also did not have a version number. We consider this version 1.x.
The Darknet repo sponsored by Hank.ai and maintained by Stéphane Charette starting in 2023 was the first one with a version command. From 2023 until late 2024, it returned version 2.x "OAK".
The goal was to try and break as little of the existing functionality while getting familiar with the codebase.
Re-wrote the build steps so we have 1 unified way to build using CMake on both Windows and Linux.
Converted the codebase to use the C++ compiler.
Enhanced chart.png while training.
Bug fixes and performance-related optimizations, mostly related to cutting down the time it takes to train a network.
The last branch of this codebase is version 2.1 in the v2 branch.
The next phase of development started in mid-2024 and was released in October 2024. The version command now returns 3.x "JAZZ".
You can always do a checkout of the previous v2 branch if you need to run one of these commands. Let us know so we can investigate adding back any missing commands.
Removed many old and unmaintained commands.
Many performance optimizations, both when training and during inference.
Legacy C API was modified; applications that use the original Darknet API will need minor modifications: https://darknetcv.ai/api/api.html
New Darknet V3 C and C++ API: https://darknetcv.ai/api/api.html
New apps and sample code in src-examples: https://darknetcv.ai/api/files.html
MSCOCO Pre-trained Weights
Several popular versions of YOLO were pre-trained for convenience on the MSCOCO dataset. This dataset has 80 classes, which can be seen in the text file cfg/coco.names.
There are several other simpler datasets and pre-trained weights available for testing Darknet/YOLO, such as LEGO Gears and Rolodex. See the Darknet/YOLO FAQ for details.
The MSCOCO pre-trained weights can be downloaded from several different locations, and are also available for download from this repo:
YOLOv2, November 2016
YOLOv2-tiny
YOLOv2-full
YOLOv3, May 2018
YOLOv3-tiny
YOLOv3-full
YOLOv4, May 2020
YOLOv4-tiny
YOLOv4-full
YOLOv7, August 2022
YOLOv7-tiny
YOLOv7-full
The MSCOCO pre-trained weights are provided for demo-purpose only. The corresponding .cfg and .names files for MSCOCO are in the cfg directory. Example commands:
wget --no-clobber https://github.com/hank-ai/darknet/releases/download/v2.0/yolov4-tiny.weights darknet02displayannotatedimages coco.names yolov4-tiny.cfg yolov4-tiny.weights image1.jpg darknet03display_videos coco.names yolov4-tiny.cfg yolov4-tiny.weights video1.avi DarkHelp coco.names yolov4-tiny.cfg yolov4-tiny.weights image1.jpg DarkHelp coco.names yolov4-tiny.cfg yolov4-tiny.weights video1.avi
Note that people are expected to train their own networks. MSCOCO is normally used to confirm that everything is working correctly.
Building
The various build methods available in the past (pre-2023) have been merged together into a single unified solution. Darknet requires C++17 or newer, OpenCV, and uses CMake to generate the necessary project files.
You do not need to know C++ to build, install, nor run Darknet/YOLO, the same way you don't need to be a mechanic to drive a car.
Google Colab
Linux
Windows
Beware if you are following old tutorials with more complicated build steps, or build steps that don't match what is in this readme. The new build steps as described below started in August 2023.
Software developers are encouraged to visit https://darknetcv.ai/ to get information on the internals of the Darknet/YOLO object detection framework.
Google Colab
The Google Colab instructions are the same as the Linux instructions. Several Jupyter notebooks are available showing how to do certain tasks, such as training a new network.
See the notebooks in the colab subdirectory, and/or follow the Linux instructions below.
Linux CMake Method
Darknet build tutorial for Linux
Optional: If you have a modern NVIDIA GPU, you can install either CUDA or CUDA+cuDNN at this point. If installed, Darknet will use your GPU to speed up image (and video) processing.
You must delete the CMakeCache.txt file from your Darknet build directory to force CMake to re-find all of the necessary files.
Remember to re-build Darknet.
Darknet can run without it, but if you want to train a custom network then either CUDA or CUDA+cuDNN is required.
Visit https://developer.nvidia.com/cuda-downloads to download and install CUDA.
Visit https://developer.nvidia.com/rdp/cudnn-download or https://docs.nvidia.com/deeplearning/cudnn/install-guide/index.html#cudnn-package-manager-installation-overview to download and install cuDNN.
Once you install CUDA make sure you can run nvcc and nvidia-smi. You may have to modify your PATH variable.
If you install CUDA or CUDA+cuDNN at a later time, or you upgrade to a newer version of the NVIDIA software:
These instructions assume (but do not require!) a system running Ubuntu 22.04. Adapt as necessary if you're using a different distribution.
sudo apt-get install build-essential git libopencv-dev cmake mkdir ~/srccd ~/src git clone https://github.com/hank-ai/darknetcd darknet mkdir buildcd build cmake -DCMAKEBUILDTYPE=Release .. make -j4 package sudo dpkg -i darknet-VERSION.deb
If you are using an older version of CMake then you'll need to upgrade CMake before you can run the cmake command above. Upgrading CMake on Ubuntu can be done with the following commands:
sudo apt-get purge cmake sudo snap install cmake --classic
If using bash as your command shell you'll want to re-start your shell at this point. If using fish, it should immediately pick up the new path.
Advanced users:
If you want to build a RPM installation file instead of a DEB file, see the relevant lines in CM_package.cmake. Prior to running make -j4 package you'll need to edit these two lines:
SET (CPACKGENERATOR "DEB")# SET (CPACKGENERATOR "RPM")
For distros such as Centos and OpenSUSE, you'll need to switch those two lines in CM_package.cmake to be:
SET (CPACKGENERATOR "DEB")SET (CPACKGENERATOR "RPM")
To install the installation package once it has finished building, use the usual package manager for your distribution. For example, on Debian-based systems such as Ubuntu:
sudo dpkg -i darknet-2.0.1-Linux.deb
Installing the .deb package will copy the following files:
/usr/bin/darknet is the usual Darknet executable. Run darknet version from the CLI to confirm it is installed correctly.
/usr/include/darknet.h is the Darknet API for C, C++, and Python developers.
/usr/include/darknet_version.h contains version information for developers.
/usr/lib/libdarknet.so is the library to link against for C, C++, and Python developers.
/opt/darknet/cfg/... is where all the .cfg templates are stored.
You are now done! Darknet has been built and installed into /usr/bin/. Run this to test: darknet version.
If you don't have /usr/bin/darknet then this means you did not install it, you only built it! Make sure you install the .deb or .rpm file as described above.
Windows CMake Method
These instructions assume a brand new installation of Windows 11 22H2.
Open a normal cmd.exe command prompt window and run the following commands:
winget install Git.Git winget install Kitware.CMake winget install nsis.nsis winget install Microsoft.VisualStudio.2022.Community
At this point we need to modify the Visual Studio installation to include support for C++ applications:
click on the "Windows Start" menu and run "Visual Studio Installer"
click on Modify
select Desktop Development With C++
click on Modify in the bottom-right corner, and then click on YesOnce everything is downloaded and installed, click on the "Windows Start" menu again and select Developer Command Prompt for VS 2022. Do not use PowerShell for these steps, you will run into problems!
Advanced users:
Instead of running the Developer Command Prompt, you can use a normal command prompt or ssh into the device and manually run "Program FilesMicrosoft Visual Studio2022CommunityCommon7ToolsVsDevCmd.bat".
Once you have the Developer Command Prompt running as described above (not PowerShell!) run the following commands to install Microsoft VCPKG, which will then be used to build OpenCV:
cd c:mkdir c:srccd c:src git clone https://github.com/microsoft/vcpkgcd vcpkg bootstrap-vcpkg.bat .vcpkg.exe integrate install .vcpkg.exe integrate powershell.vcpkg.exe install opencv[contrib,dnn,freetype,jpeg,openmp,png,webp,world]:x64-windows
Be patient at this last step as it can take a long time to run. It needs to download and build many things.
Advanced users:
Note there are many other optional modules you may want to add when building OpenCV. Run .vcpkg.exe search opencv to see the full list.
Optional: If you have a modern NVIDIA GPU, you can install either CUDA or CUDA+cuDNN at this point. If installed, Darknet will use your GPU to speed up image (and video) processing.
You must delete the CMakeCache.txt file from your Darknet build directory to force CMake to re-find all of the necessary files.
Remember to re-build Darknet.
Darknet can run without it, but if you want to train a custom network then either CUDA or CUDA+cuDNN is required.
Visit https://developer.nvidia.com/cuda-downloads to download and install CUDA.
Visit https://developer.nvidia.com/rdp/cudnn-download or https://docs.nvidia.com/deeplearning/cudnn/install-guide/index.html#download-windows to download and install cuDNN.
Once you install CUDA make sure you can run nvcc.exe and nvidia-smi.exe. You may have to modify your PATH variable.
Once you download cuDNN, unzip and copy the bin, include, and lib directories into C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/[version]/. You may need to overwrite some files.
If you install CUDA or CUDA+cuDNN at a later time, or you upgrade to a newer version of the NVIDIA software:
CUDA must be installed after Visual Studio. If you upgrade Visual Studio, remember to re-install CUDA.
Once all of the previous steps have finished successfully, you need to clone Darknet and build it. During this step we also need to tell CMake where vcpkg is located so it can find OpenCV and other dependencies:
cd c:src git clone https://github.com/hank-ai/darknet.gitcd darknetmkdir buildcd build cmake -DCMAKEBUILDTYPE=Release -DCMAKETOOLCHAINFILE=C:/src/vcpkg/scripts/buildsystems/vcpkg.cmake .. msbuild.exe /property:Platform=x64;Configuration=Release /target:Build -maxCpuCount -verbosity:normal -detailedSummary darknet.sln msbuild.exe /property:Platform=x64;Configuration=Release PACKAGE.vcxproj
If you get an error about some missing CUDA or cuDNN DLLs such as cublas64_12.dll, then manually copy the CUDA .dll files into the same output directory as Darknet.exe. For example:
copy "C:Program FilesNVIDIA GPU Computing ToolkitCUDAv12.2bin*.dll" src-cliRelease
(That is an example! Check to make sure what version you are running, and run the command that is appropriate for what you have installed.)
Once the files have been copied, re-run the last msbuild.exe command to generate the NSIS installation package:
msbuild.exe /property:Platform=x64;Configuration=Release PACKAGE.vcxproj
Advanced users:
Note that the output of the cmake command is a normal Visual Studio solution file, Darknet.sln. If you are a software developer who regularly uses the Visual Studio GUI instead of msbuild.exe to build projects, you can ignore the command-line and load the Darknet project in Visual Studio.
You should now have this file you can run: C:srcDarknetbuildsrc-cliReleasedarknet.exe. Run this to test: C:srcDarknetbuildsrc-cliReleasedarknet.exe version.
To correctly install Darknet, the libraries, the include files, and the necessary DLLs, run the NSIS installation wizard that was built in the last step. See the file darknet-VERSION.exe in the build directory. For example:
darknet-2.0.31-win64.exe
Installing the NSIS installation package will:
Create a directory called Darknet, such as C:Program FilesDarknet.
Install the CLI application, darknet.exe and other sample apps.
Install the required 3rd-party .dll files, such as those from OpenCV.
Install the neccesary Darknet .dll, .lib and .h files to use darknet.dll from another application.
Install the template .cfg files.
You are now done! Once the installation wizard has finished, Darknet will have been installed into C:Program FilesDarknet. Run this to test: C:Program FilesDarknetbindarknet.exe version.
If you don't have C:/Program Files/darknet/bin/darknet.exe then this means you did not install it, you only built it! Make sure you go through each panel of the NSIS installation wizard in the previous step.
Using Darknet
CLI
The following is not the full list of all commands supported by Darknet.
In addition to the Darknet CLI, also note the DarkHelp project CLI which provides an alternative CLI to Darknet/YOLO. The DarkHelp CLI also has several advanced features that are not available directly in Darknet. You can use both the Darknet CLI and the DarkHelp CLI together, they are not mutually exclusive.
For most of the commands shown below, you'll need the .weights file with the corresponding .names and .cfg files. You can either train your own network (highly recommended!) or download a neural network that someone has already trained and made available for free on the internet. Examples of pre-trained datasets include:
LEGO Gears (finding ojects in an image)
Rolodex (finding text in an image)
MSCOCO (standard 80-class object detection)
Commands to run include:
List some possible commands and options to run:
darknet help
Check the version:
darknet version
Predict using an image:
V2: darknet detector test cars.data cars.cfg cars_best.weights image1.jpg
V3: darknet02displayannotatedimages cars.cfg image1.jpg
DarkHelp: DarkHelp cars.cfg cars.cfg cars_best.weights image1.jpg
Output coordinates:
V2: darknet detector test animals.data animals.cfg animalsbest.weights -extoutput dog.jpg
V3: darknet01inference_images animals dog.jpg
DarkHelp: DarkHelp --json animals.cfg animals.names animals_best.weights dog.jpg
Working with videos:
V2: darknet detector demo animals.data animals.cfg animalsbest.weights -extoutput test.mp4
V3: darknet03display_videos animals.cfg test.mp4
DarkHelp: DarkHelp animals.cfg animals.names animals_best.weights test.mp4
Reading from a webcam:
V2: darknet detector demo animals.data animals.cfg animals_best.weights -c 0
V3: darknet08display_webcam animals
Save results to a video:
V2: darknet detector demo animals.data animals.cfg animalsbest.weights test.mp4 -outfilename res.avi
V3: darknet05processvideosmultithreaded animals.cfg animals.names animals_best.weights test.mp4
DarkHelp: DarkHelp animals.cfg animals.names animals_best.weights test.mp4
JSON:
V2: darknet detector demo animals.data animals.cfg animalsbest.weights test50.mp4 -jsonport 8070 -mjpegport 8090 -extoutput
V3: darknet06imagestojson animals image1.jpg
DarkHelp: DarkHelp --json animals.names animals.cfg animals_best.weights image1.jpg
Running on a specific GPU:
V2: darknet detector demo animals.data animals.cfg animals_best.weights -i 1 test.mp4
To check the accuracy of the neural network:
darknet detector map driving.data driving.cfg driving_best.weights ... Id Name AvgPrecision TP FN FP TN Accuracy ErrorRate Precision Recall Specificity FalsePosRate -- ---- ------------ ------ ------ ------ ------ -------- --------- --------- ------ ----------- ------------ 0 vehicle 91.2495 32648 3903 5826 65129 0.9095 0.0905 0.8486 0.8932 0.9179 0.0821 1 motorcycle 80.4499 2936 513 569 5393 0.8850 0.1150 0.8377 0.8513 0.9046 0.0954 2 bicycle 89.0912 570 124 104 3548 0.9475 0.0525 0.8457 0.8213 0.9715 0.0285 3 person 76.7937 7072 1727 2574 27523 0.8894 0.1106 0.7332 0.8037 0.9145 0.0855 4 many vehicles 64.3089 1068 509 733 11288 0.9087 0.0913 0.5930 0.6772 0.9390 0.0610 5 green light 86.8118 1969 239 510 4116 0.8904 0.1096 0.7943 0.8918 0.8898 0.1102 6 yellow light 82.0390 126 38 30 1239 0.9525 0.0475 0.8077 0.7683 0.9764 0.0236 7 red light 94.1033 3449 217 451 4643 0.9237 0.0763 0.8844 0.9408 0.9115 0.0885
To check accuracy mAP@IoU=75:
darknet detector map animals.data animals.cfg animalsbest.weights -iouthresh 0.75
Recalculating anchors is best done in DarkMark, since it will run 100 consecutive times and select the best anchors from all the ones that were calculated. But if you want to run the old version in Darknet:
darknet detector calcanchors animals.data -numof_clusters 6 -width 320 -height 256
Train a new network:
darknet detector -map -dont_show train animals.data animals.cfg (also see the training section below)
Training
Quick links to relevant sections of the Darknet/YOLO FAQ:
How should I setup my files and directories?
Which configuration file should I use?
What command should I use when training my own network?
The simplest way to annotate and train is with the use of DarkMark to create all of the necessary Darknet files. This is definitely the recommended way to train a new neural network.
If you'd rather manually setup the various files to train a custom network:
Create a new folder where the files will be stored. For this example, a neural network will be created to detect animals, so the following directory is created: ~/nn/animals/.
Copy one of the Darknet configuration files you'd like to use as a template. For example, see cfg/yolov4-tiny.cfg. Place this in the folder you created. For this example, we now have ~/nn/animals/animals.cfg.
Create a animals.names text file in the same folder where you placed the configuration file. For this example, we now have ~/nn/animals/animals.names.
Edit the animals.names file with your text editor. List the classes you want to use. You need to have exactly 1 entry per line, with no blank lines and no comments. For this example, the .names file will contain exactly 4 lines:
dog cat bird horse
Create a animals.data text file in the same folder. For this example, the .data file will contain:
classes = 4 train = /home/username/nn/animals/animalstrain.txt valid = /home/username/nn/animals/animalsvalid.txt names = /home/username/nn/animals/animals.names backup = /home/username/nn/animals
Create a folder where you'll store your images and annotations. For example, this could be ~/nn/animals/dataset. Each image will need a coresponding .txt file which describes the annotations for that image. The format of the .txt annotation files is very specific. You cannot create these files by hand since each annotation needs to contain the exact coordinates for the annotation. See DarkMark or other similar software to annotate your images. The YOLO annotation format is described in the Darknet/YOLO FAQ.
Create the "train" and "valid" text files named in the .data file. These two text files need to individually list all of the images which Darknet must use to train and for validation when calculating the mAP%. Exactly one image per line. The path and filenames may be relative or absolute.
Modify your .cfg file with a text editor.
Make sure that batch=64.
Note the subdivisions. Depending on the network dimensions and the amount of memory available on your GPU, you may need to increase the subdivisions. The best value to use is 1 so start with that. See the Darknet/YOLO FAQ if 1 doesn't work for you.
Note maxbatches=.... A good value to use when starting out is 2000 x the number of classes. For this example, we have 4 animals, so 4 * 2000 = 8000. Meaning we'll use maxbatches=8000.
Note steps=.... This should be set to 80% and 90% of maxbatches. For this example we'd use steps=6400,7200 since maxbatches was set to 8000.
Note width=... and height=.... These are the network dimensions. The Darknet/YOLO FAQ explains how to calculate the best size to use.
Search for all instances of the line classes=... and modify it with the number of classes in your .names file. For this example, we'd use classes=4.
Search for all instances of the line filters=... in the [convolutional] section prior to each [yolo] section. The value to use is (numberofclasses + 5) 3. Meaning for this example, (4 + 5) 3 = 27. So we'd use filters=27 on the appropriate lines.
Start training! Run the following commands:
cd ~/nn/animals/ darknet detector -map -dont_show train animals.data animals.cfg
Be patient. The best weights will be saved as animals_best.weights. And the progress of training can be observed by viewing the