YOLOv5 – Explanation of the project directory structure

Time:2023-10-27

preamble

The previous section briefly describes the network structure and innovations of YOLOv5 (the drive-through:[YOLO Series] YOLOv5 Super Detailed Explanation (Network Detailed Explanation)) In the next step we will go into a deeper study of YOLOv5, starting with the source code interpretation. Because I am a pure white, just started to download the source code when really a face, so the first from the most basicProject Catalog StructureStart ~ because the relevant interpretation is not a lot, so some of them are based on the author of the English documents given by me to translate their own, if there is something wrong, welcome to correct ah! This is just a simple introduction to each file is to do what, generally understand the project, the specific code will be slowly updated later, you are welcome to pay attention to my column, and I learn together ah! Source code download address:mirrors / ultralytics / yolov5 · GitCode

YOLOv5 - Explanation of the project directory structure[Writing a paper is a must.]How to write your first paper from scratch for deep learning purists? Read this for clarity! YOLOv5 - Explanation of the project directory structure I YOLOv5 source code detailed series: YOLOv5 source code line by line ultra-detailed comments and interpretation (1) – the project directory structure analysis YOLOv5 source code line by line ultra-detailed comments and interpretation (2) – reasoning part detect.py YOLOv5 source code line by line ultra-detailed comments and interpretation (3) – training part of the train.py YOLOv5 source code line by line ultra-detailed comments and interpretation (4) – validation section val (test).py YOLOv5 source code line by line ultra-detailed comments and interpretation (5) – configuration file yolov5s.yaml YOLOv5 source code line by line ultra-detailed comments and interpretation (6) – network structure (1) yolo.py YOLOv5 source code line by line ultra-detailed comments and interpretation (7) – network structure (2) common.py
YOLOv5 - Explanation of the project directory structure🌟My YOLOv5 introductory practice series: YOLOv5 introductory practice (1) – hand to take you to the environment configuration setup YOLOv5 introductory practice (2) – hands-on teaching you to use labelimg labeling dataset YOLOv5 Getting Started Practice (3) – Hands on with dividing your own dataset YOLOv5 Getting Started Practice (4) – Hands on Training Your Own Dataset YOLOv5 introductory practice (5) – from scratch, hands-on training your own target detection model (pyqt5 interface included)
YOLOv5 - Explanation of the project directory structure🌟I YOLOv5 improved series: YOLOv5 Improvement Series (0) – Evaluation and Analysis of Important Performance Indicators and Training Results YOLOv5 Improvement Series (1) – Adding SE Attention Mechanisms YOLOv5 Improvement Series (2) – Adding the CBAM Attention Mechanism YOLOv5 Improvement Series (3) – Adding CA Attention Mechanisms YOLOv5 Improvement Series (4) – Adding the ECA Attention Mechanism YOLOv5 Improvement Series (5) – Replacement of Backbone Network MobileNetV3 YOLOv5 Improvement Series (6) – Replacement of ShuffleNetV2 for Backbone Networks YOLOv5 Improvement Series (7) – Adding the SimAM Attention Mechanism YOLOv5 Improvement Series (8) – Add SOCA Attention Mechanism YOLOv5 Improvement Series (9) – EfficientNetv2 for Replacing Backbone Networks YOLOv5 Improvement Series (10) – Replacement of Backbone Networks GhostNet YOLOv5 Improvement Series (11) – Adding Loss Functions of EIoU, AlphaIoU, SIoU, WIoU YOLOv5 Improvement Series (13)–Replacement of activation functions of SiLU, ReLU, ELU, Hardswish, Mish, Softplus, AconC series, etc. YOLOv5 Improvement Series (14)–Replacement of DIoU-NMS, CIoU-NMS, EIoU-NMS, GIoU-NMS, SIoU-NMS, Soft-NMS of NMS (Non-Maximum Suppression) YOLOv5 Improvement Series (15) – Add Small Target Detection Layer YOLOv5 Improvement Series (16) – Adding EMA Attention Mechanism (ICASSP2023 | Measured Rising Points) YOLOv5 Improvement Series (17) – Replacement of MPDIoU of IoU (ELSEVIER 2023|Beyond WIoU, EIoU, etc.|Measurement of rising points) YOLOv5 Improvement Series (18) – Replacement of Neck’s AFPN (New Progressive Feature Pyramid | Beyond PAFPN | Measured Rising Points) YOLOv5 Improvement Series (19) – Swin TransformerV1 for Replacement of Backbone Networks (ViT Model with Smaller Number of Parameters) YOLOv5 Improvement Series (20) – Add BiFormer Attention Mechanism (CVPR2023|Small Goal Up Points Artifact) YOLOv5 Improvement Series (21) – Replacement of RepViT for Backbone Networks (Tsinghua ICCV 2023|Latest Open Source Mobile ViT) YOLOv5 Improvement Series (22) – MobileViTv1 (a lightweight, general-purpose mobile device ViT) to replace the backbone network YOLOv5 Improvement Series (23) – MobileViTv2 (Efficient Separable Self-Attention Mechanism for Mobile Visual Transformer) for Replacing Backbone Networks YOLOv5 Improvement Series (24) – MobileViTv3 for Replacement of Backbone Network (Further Upgrade of Lightweight Network for Mobile) Continuously updated.

catalogs

preamble

I. Project catalog structure

1.1 .github folder

 1.2 datasets

1.3 data folder

1.4 models folder

 1.5 runs folder

 1.6 utils folder

 1.7 Other first-level catalog documents

YOLOv5 - Explanation of the project directory structure

I. Project catalog structure

YOLOv5 - Explanation of the project directory structure

After downloading the source code and configuring the environment, you can see the overall directory of YOLOv5 as shown above. Let’s analyze them one by one

1.1 .github folder

YOLOv5 - Explanation of the project directory structure

 githubIt’s for storing some “configurations” on github, which is not important and we can leave it alone.

1.2 datasets

YOLOv5 - Explanation of the project directory structure

The source code we just downloaded does not contain this folder.datasetsIt is used to store your own dataset, which is divided into two parts: images and labels.Also under each folder, it should be divided into TRAIN, VAL.The .cache file is a cache file, which loads the data into memory, so that the next call is fast. You can name it, for example, my flame dataset is called “fire_yolo_format”.

1.3 data folder

 YOLOv5 - Explanation of the project directory structure

data folderIt is mainly to store someConfiguration file for hyperparameters(e.g., a .yaml file) is used to configure the paths to the training and test sets and the validation set, which also includes the number of target assays and the names of the assays; and theSome of the official images provided for testingYOLOv5 has about 30 hyperparameters for various training settings. Better initial guesses produce better final results, so it is important to initialize these values correctly before evolution. If it isIf you train your own dataset, then you need to modify the yaml file in it. But be warned.It is not recommended to put your own dataset under this path, it is recommended to put the dataset under the same level directory of the YOLOv5 project. Detailed explanation:
  • hyps folder   # Store hyperparameter configuration files in yaml format.
    • hyps.scratch-high.yaml  # High data enhancement for large models i.e. v3, v3-spp, v5l, v5x
    • hyps.scratch-low.yaml  # Low data enhancement for smaller models i.e. v5n, v5s
    • hyps.scratch-med.yaml  # in Data Enhancement for medium sized models. i.e. v5m
  • images  # There are two official test images stored #
  • scripts  # Store dataset and weights download shell scripts
    • download_weights.sh  # Download the weights file, including the P5 and P6 versions in five sizes, and the classifier version
    • get_coco.sh   Download coco dataset
    • get_coco128.sh  # Download coco128 (only 128)
  • Argoverse.yaml  # Each .yaml file that follows corresponds to data in one of the standard dataset formats
  • coco.yaml   # COCO dataset profiles
  • coco128.yaml   # COCO128 dataset profile
  • voc.yaml   # VOC dataset profiles

1.4 models folder

YOLOv5 - Explanation of the project directory structure

modelsisModel folder. It contains mainly configuration files and functions for building the network, and it contains four different versions of the project, which ares、m、l、x. The size of these versions is obvious from the name.Their detection speed is from fast to slow, but their accuracy is from low to high.If you train your own dataset, you need to modify the corresponding yaml file here to train your own model. Detailed explanation:
  • hub  # Store yolov5 target detection network model configuration files for all versions of yolov5.
    • anchors.yaml  # Default anchors for COCO data
    • yolov3-spp.yaml  # yolov3 with spp
    • yolov3-tiny.yaml  # lite yolov3
    • yolov3.yaml  # yolov3
    • yolov5-bifpn.yaml  # yolov5l with binary fpn
    • yolov5-fpn.yaml  # yolov5 with fpn
    • yolov5-p2.yaml  # (P2, P3, P4, P5) are all output with the same width and depth as the large version, which corresponds to the ability to detect smaller objects than the large version.
    • yolov5-p34.yaml  # Outputs only (P3, P4) with the same width and depth as the small version, which corresponds to a more focused detection of small and medium-sized objects than the small version
    • yolov5-p6.yaml  # (P3, P4, P5, P6) are all output with the same width and depth as the large version, which corresponds to the ability to detect larger objects than the large version.
    • yolov5-p7.yaml  # (P3, P4, P5, P6, P7) are all output with the same width and depth as the large version, which equates to detecting larger objects than the large version.
    • yolov5-panet.yaml  # yolov5l with PANet #
    • yolov5n6.yaml  # (P3, P4, P5, P6) are all output, width and depth are the same as the nano version, which is equivalent to detecting larger objects than the nano version, anchor is predefined
    • yolov5s6.yaml  # (P3, P4, P5, P6) are all output, width and depth are the same as the small version, which is equivalent to detecting larger objects than the small version, anchor is predefined
    • yolov5m6.yaml   # (P3, P4, P5, P6) are all output, width and depth are the same as the middle version, which is equivalent to detecting larger objects than the middle version, anchor is predefined
    • yolov5l6.yaml   # (P3, P4, P5, P6) are output, the width and depth are the same as the large version, which is equivalent to detecting larger objects than the large version, the anchor has been predefined, presumably a product of the author’s experiments
    • yolov5x6.yaml   # (P3, P4, P5, P6) are all output, width and depth are the same as the Xlarge version, which is equivalent to being able to detect larger objects than the Xlarge version, anchor is predefined
    • yolov5s-ghost.yaml   # backbone’s convolution replaced with yolov5s in GhostNet form, anchor predefined
    • yolov5s-transformer.yaml  # backbone final C3 convolution added Transformer module for yolov5s, anchor predefined
  • _int_.py   # Empty
  • common.py   # Put some of the network structure of the definition of the general module, including autopad, Conv, DWConv, TransformerLayer and so on
  • experimental.py   # Code of an experimental nature, including MixConv2d, cross-layer weights Sum, etc.
  • tf.py  # tensorflow version of yolov5 code
  • yolo.py  # yolo specific modules, including BaseModel, DetectionModel, ClassificationModel, parse_model, etc.
  • yolov5l.yaml   # yolov5l network model profile, large version, depth 1.0, width 1.0
  • yolov5m.yaml   # yolov5m network model profile, middle version, depth 0.67, width 0.75
  • yolov5n.yaml   # yolov5n network model profile, nano version, depth 0.33, width 0.25
  • yolov5s.yaml   # yolov5s network model profile, small version, depth 0.33, width 0.50
  • yolov5x.yaml   # yolov5x network model profile, Xlarge version, depth 1.33, width 1.25

1.5 runs folder

YOLOv5 - Explanation of the project directory structure

runsIt’s some output files when we run it. An exp folder is generated for each run.

YOLOv5 - Explanation of the project directory structure

Detailed explanation:
  • detect   # Test the model, output the image and label the image with objects and probabilities
  • train    # Train the model, output content, model (best, latest) weights, confusion matrix, F1 curves, hyperparameter files, P curves, R curves, PR curves, result files (loss values, P, R), and so onexpn
    • expn# nth experimental data
    • confusion_matrix.png   # Confusion matrix
    • P_curve.png   # Accuracy vs. confidence plot line
    • R_curve.png  # Plot line of accuracy vs. confidence level
    • PR_curve.png  # Plot lines of precision vs. recall
    • F1_curve.png   # Relationship between F1 scores and confidence (x-axis)
    • labels_correlogram.jpg  # Predicted tag aspect and position distribution
    •  results.png   # Various loss and metrics (p, r, mAP, etc., see utils/metrics for details) curves
    • results.csv  # Raw result data corresponding to the png above
    • hyp.yaml  # Hyperparameter log files
    • opt.yaml  # Model option log files
    • train_batchx.jpg  # Training set image x (labeled)
    • val_batchx_labels.jpg  # Validation set image x (with labeling)
    • val_batchx_pred.jpg  # Validation set image x (with predictive labeling)
    • weights  # Weights
    • best.pt  # Best historical weights
    • last.pt   # Weight of last test point
    • labels.jpg  # 4 graphs, 4 graphs, (1, 1) denotes the amount of data in each category
(1, 2) bounding_box for real labeling (2, 1) Coordinates of the center point of the real labeling (2, 2) Real labeled matrix width and height

1.6 utils folder

   YOLOv5 - Explanation of the project directory structure

 utilsTools folder. Stores the functions of the tools class, which includes the loss function, the metrics function, the plots function, and so on. Detailed explanation:
  • aws   # Resume interrupted training, and aws platform usage related tools
  • flask_rest_api  # flask-related tools
  • google_app_engine   # Tools related to Google App Engine
  • loggers    # Log Printing
  • _init_.py    # notebook initialization, checking system software and hardware
  • activations.py  # Activation function
  • augmentations  # Store various image enhancement techniques
  • autoanchor.py    # Auto-generated anchor frames
  • autobatch.py   # Automatic generation of batch sizes
  • benchmarks.py   # Perform performance evaluation of the model (in terms of inference speed and memory footprint)
  • callbacks.py   # Callback functions, mainly for loggers
  • datasets  # dateset and dateloader definition code
  • downloads.py   # Google Cloud Drive Content Download
  • general.py   # Project-wide generic code, related utility function implementation
  • loss.py   # Store the various loss functions
  • metrics.py   # Model validation metrics, including ap, confusion matrix, etc.
  • plots.py   # Plotting related functions such as plotting loss, ac curves, and also storing a bbox as an image separately
  • torch_utils.py   # Auxiliary Functions

1.7 Other first-level catalog documents

YOLOv5 - Explanation of the project directory structure

Detailed explanation:
  • .dockerignore   # docker’s ignore file
  • .gitattributes   To be used for the purpose of transferring .ipynbSuffixed files cull GitHub language statistics
  • .gitignore   # docker’s ignore file
  • CONTRIBUTING.md  # markdown formatting instructions document
  • detect.py   # Target detection prediction scripts
  • export.py  # Model export
  • hubconf.py  # pytorch hub related
  • LICENSE    # Certificates
  • README.md    # markdown formatting instructions document
  • requirements.txt # The dependencies can be downloaded via the pip install requirement
  • setup.cfg  # Project package files
  • train.py   # Target detection training scripts
  • tutorial.ipynb  # Target Detection Hands-On Tutorial
  • val.py  # Target detection validation scripts
  • yolov5s.pt   # coco dataset model pre-training weights that are automatically downloaded from the web when running code

Recommended Today

uniapp and applet set tabBar and show and hide tabBar

(1) Set the tabBar: uni.setTabberItem({}); wx.setTabberItem({}); indexnumberisWhich item of the tabBar, counting from the left, is indexed from 0.textstringnoButton text on tabiconPathstringnoImage PathselectedIconPathstringnoImage path when selectedpagePathstringnoPage absolute pathvisiblebooleannotab Whether to display uni.setTabBarItem({ index: 0, text: ‘text’, iconPath: ‘/path/to/iconPath’, selectedIconPath: ‘/path/to/selectedIconPath’, pagePath: ‘pages/home/home’ }) wx.setTabBarItem({ index: 0, text: ‘text’, iconPath: ‘/path/to/iconPath’, selectedIconPath: ‘/path/to/selectedIconPath’, pagePath: ‘pages/home/home’ }) […]