MCPcopy Create free account

hub / github.com/HuKai97/yolov5-5.x-annotations / functions

Functions311 in github.com/HuKai97/yolov5-5.x-annotations

↓ 35 callersMethodinfo
用在上面的__init__函数上 调用torch_utils.py下model_info函数打印模型信息
models/yolo.py:400
↓ 20 callersMethod__init__
CSP Bottleneck with 3 convolutions :params c1: 整个BottleneckCSP的输入channel :params c2: 整个BottleneckCSP的输出channel :param
models/common.py:136
↓ 19 callersFunctioncolorstr
用到下面的check_git_status、check_requirements等函数 train.py、val.py、detect.py等文件中 把输出的开头和结尾加上颜色 命令行输出显示会更加好看 如: colorstr('blue', 'hello world') Col
utils/general.py:136
↓ 18 callersMethodplot
:params normalize: 是否将混淆矩阵归一化 默认True :params save_dir: runs/train/expn 混淆矩阵保存地址 :params names: 数据集的所有类别名 :return None
utils/metrics.py:259
↓ 16 callersFunctiontime_synchronized
这个函数被广泛的用于整个项目的各个文件中,只要涉及获取当前时间的操作,就需要调用这个函数 精确计算当前时间 并返回当前时间 https://blog.csdn.net/qq_23981335/article/details/105709273 pytorch-accurat
utils/torch_utils.py:147
↓ 15 callersMethodtolist
(self)
models/common.py:605
↓ 14 callersMethodlog
(self, log_dict)
utils/wandb_logging/wandb_utils.py:309
↓ 9 callersMethodsave
(self, save_dir='runs/hub/exp')
models/common.py:582
↓ 9 callersFunctionxyxy2xywh
用在detect.py和test.py中 操作最后, 将预测信息从xyxy格式转为xywh格式 再保存 Convert nx4 boxes from [x1, y1, x2, y2] to [x, y, w, h] where x1y1=top-left, x2y2=bottom-rig
utils/general.py:596
↓ 8 callersFunctioncheck_file
用在train.py、detect.py、test.py等文件中检查本地有没有这个文件 检查相关文件路径能否找到文件 并返回文件名 Search/download file (if necessary) and return path
utils/general.py:330
↓ 7 callersFunctionincrement_path
这是个用处特别广泛的函数 train.py、detect.py、test.py等都会用到 递增路径 如 run/train/exp --> runs/train/exp{sep}0, runs/exp{sep}1 etc. :params path: window path ru
utils/general.py:894
↓ 7 callersFunctionxywh2xyxy
用在test.py中 操作之前 转为xyxy才可以进行操作 注意: x的正方向为右面 y的正方向为下面 Convert nx4 boxes from [x, y, w, h] to [x1, y1, x2, y2] where x1y1=top-left, x2y2=bottom
utils/general.py:609
↓ 6 callersFunctioncheck_requirements
用在train.py、val.py、detect.py等文件 用于检查已经安装的包是否满足requirements对应txt文件的要求 Check installed dependencies meet requirements (pass *.txt file or list of
utils/general.py:239
↓ 6 callersFunctionfitness
通过指标加权的形式返回适应度(最终mAP) 在train.py中使用 Model fitness as a weighted combination of metrics 判断模型好坏的指标不是mAP@0.5也不是mAP@0.5:0.95 而是[P, R, mAP@0.5, mAP
utils/metrics.py:13
↓ 6 callersFunctionletterbox
用在LoadImagesAndLabels模块的__getitem__函数 只在val时才会使用 将图片缩放调整到指定大小 Resize and pad image while meeting stride-multiple constraints https://gith
utils/datasets.py:1108
↓ 5 callersMethod__init__
(self, c1, k=3)
models/activations.py:85
↓ 5 callersMethod__init__
(self, n, weight=False)
models/experimental.py:162
↓ 5 callersMethoddisplay
(self, pprint=False, show=False, save=False, crop=False, render=False, save_dir=Path(''))
models/common.py:548
↓ 5 callersFunctionimg2label_paths
用在LoadImagesAndLabels模块的__init__函数中 根据imgs图片的路径找到对应labels的路径 Define label paths as a function of image paths :params img_paths: {list: 50}
utils/datasets.py:600
↓ 5 callersFunctionremove_prefix
(from_string, prefix=WANDB_ARTIFACT_PREFIX)
utils/wandb_logging/wandb_utils.py:27
↓ 5 callersFunctionscale_coords
用在detect.py和test.py中 将预测坐标从feature map映射回原图 将坐标coords(x1y1x2y2)从img1_shape缩放到img0_shape尺寸 Rescale coords (xyxy) from img1_shape to img0_shape
utils/general.py:566
↓ 5 callersFunctionselect_device
广泛用于train.py、val.py、detect.py等文件中 用于选择模型训练的设备 并输出日志信息 :params device: 输入的设备 device = 'cpu' or '0' or '0,1,2,3' :params batch_size: 一个批次的图
utils/torch_utils.py:88
↓ 5 callersFunctionset_logging
广泛使用在train.py、val.py、detect.py等文件的main函数的第一步 对日志的设置(format、level)等进行初始化
utils/general.py:73
↓ 4 callersFunctionattempt_load
用在val.py、detect.py、train.py等文件中 一般用在测试、验证阶段 加载模型权重文件并构建模型(可以构造普通模型或者集成模型) Loads an ensemble of models weights=[a,b,c] or a single model weigh
models/experimental.py:103
↓ 4 callersFunctioncheck_dataset
用在train.py和detect.py中 检查本地有没有数据集 检查数据集 如果本地没有则从torch库中下载并解压数据集 :params data: 是一个解析过的data_dict len=7 例如: ['path'='../datase
utils/general.py:361
↓ 4 callersFunctioncheck_img_size
这个函数主要用于train.py中和detect.py中 用来检查图片的长宽是否符合规定 检查img_size是否能被s整除,这里默认s为32 返回大于等于img_size且是s的最小倍数 Verify img_size is a multiple of stride s
utils/general.py:298
↓ 4 callersFunctionfile_size
没用到 返回本地文件的大小(MB) :params file: 要查询的文件地址
utils/general.py:128
↓ 4 callersFunctionis_parallel
在ModelEMA类中调用 用于判断模型是否支持并行 Returns True if model is of type DP or DDP
utils/torch_utils.py:428
↓ 4 callersFunctionload_image
用在LoadImagesAndLabels模块的__getitem__函数和load_mosaic模块中 从self或者从对应图片路径中载入对应index的图片 并将原图中hw中较大者扩展到self.img_size, 较小者同比例扩展 loads 1 image from data
utils/datasets.py:691
↓ 4 callersFunctionmake_divisible
用在下面的make_divisible函数中 yolo.py的parse_model函数和commom.py的AutoShape函数中 取大于等于x且是divisor的最小倍数 Returns x evenly divisible by divisor
utils/general.py:290
↓ 4 callersFunctionmetric
用在check_anchors函数中 compute metric 根据数据集的所有图片的wh和当前所有anchors k计算 bpr(best possible recall) 和 aat(anchors above threshold) :params k: a
utils/autoanchor.py:55
↓ 4 callersFunctionnon_max_suppression
Runs Non-Maximum Suppression (NMS) on inference results Params: prediction: [batch, num_anchors(3个yolo预测层), (x+y+w+h+1+num_classes)]
utils/general.py:660
↓ 3 callersMethod__init__
(self, loss_fcn, gamma=1.5, alpha=0.25)
utils/loss.py:53
↓ 3 callersFunctionanchor_fitness
用于kmean_anchors函数 适应度计算 优胜劣汰 用于遗传算法中衡量突变是否有效的标注 如果有效就进行选择操作 没效就继续下一轮的突变 :params k: [9, 2] k-means生成的9个anchors wh: [N, 2]: 数据集的所有gt
utils/autoanchor.py:153
↓ 3 callersFunctionbox_iou
用于计算混淆矩阵 https://github.com/pytorch/vision/blob/master/torchvision/ops/boxes.py :params box1: (Tensor[N, 4]) [N, x1y1x2y2] :params box2:
utils/metrics.py:345
↓ 3 callersFunctionclip_coords
用在下面的xyxy2xywhn、save_one_boxd等函数中 将boxes的坐标(x1y1x2y2 左上角右下角)限定在图像的尺寸(img_shape hw)内 Clip bounding x1y1x2y2 bounding boxes to image shape (heig
utils/general.py:549
↓ 3 callersFunctioncreate_dataloader
在train.py中被调用,用于生成Trainloader, dataset,testloader 自定义dataloader函数: 调用LoadImagesAndLabels获取数据集(包括数据增强) + 调用分布式采样器DistributedSampler +
utils/datasets.py:71
↓ 3 callersFunctionmodel_info
用于yolo.py文件的Model类的info函数 输出模型的所有信息 包括: 所有层数量, 模型总参数量, 需要求梯度的总参数量, img_size大小的model的浮点计算量GFLOPs :params model: 模型 :params verbose: 是否输出每一层
utils/torch_utils.py:223
↓ 3 callersFunctionplot_mc_curve
用于ap_per_class函数 Metric-Confidence curve 可用于绘制 F1-Confidence/P-Confidence/R-Confidence曲线 :params px: [0, 1, 1000] 横坐标 0-1 1000个点 conf [1000]
utils/metrics.py:409
↓ 3 callersFunctionplot_one_box
一般会用在detect.py中在nms之后变量每一个预测框,再将每个预测框画在原图上 使用opencv在原图im上画一个bounding box :params x: 预测得到的bounding box [x1 y1 x2 y2] :params im: 原图 要将boun
utils/plots.py:53
↓ 3 callersFunctionprint_results
用于kmean_anchors函数中打印k-means计算相关信息 计算bpr、aat=>打印信息: 阈值+bpr+aat anchor个数+图片大小+metric_all+best_mean+past_mean+Kmeans聚类出来的anchor框(四舍五入) :
utils/autoanchor.py:163
↓ 3 callersFunctionrandom_perspective
这个函数会用于load_mosaic中用在mosaic操作之后 随机透视变换 对mosaic整合后的图片进行随机旋转、缩放、平移、裁剪,透视变换,并resize为输入大小img_size :params img: mosaic整合后的图片img4 [2*img_size, 2*im
utils/datasets.py:931
↓ 3 callersFunctionrun
:params data: 数据集配置文件地址 包含数据集的路径、类别个数、类名、下载地址等信息 train.py时传入data_dict :params weights: 模型的权重文件地址 运行train.py=None 运行test.py=默认weights/yolov5s.
val.py:33
↓ 3 callersFunctiontorch_distributed_zero_first
用在train.py 用于处理模型进行分布式训练时同步问题 基于torch.distributed.barrier()函数的上下文管理器,为了完成数据的正常同步操作(yolov5中拥有大量的多线程并行操作) Decorator to make all processes in
utils/torch_utils.py:30
↓ 3 callersMethodupdate
(self, model)
utils/torch_utils.py:478
↓ 3 callersFunctionxywhn2xyxy
用在datasets.py的 LoadImagesAndLabels类的__getitem__函数、load_mosaic、load_mosaic9等函数中 将xywh(normalized) -> x1y1x2y2 (x, y): 中间点 wh: 宽高 (x1, y1): 左上点
utils/general.py:623
↓ 2 callersFunctionDWConv
Depthwise convolution 深度可分离卷积 :params c1: 输入的channel值 :params c2: 输出的channel值 :params k: 卷积的kernel_size :params s: 卷积的stride
models/common.py:189
↓ 2 callersMethod__init__
:params cfg:模型配置文件 :params ch: input img channels 一般是3 RGB文件 :params nc: number of classes 数据集的类别个数 :anchors: 一般是None
models/yolo.py:246
↓ 2 callersFunctionall_logging_disabled
source - https://gist.github.com/simon-weber/7853144 A context manager that will prevent any logging messages triggered during the body from bein
utils/wandb_logging/wandb_utils.py:337
↓ 2 callersFunctionattempt_download
train.py 实现从几个云平台(github/googleleaps云服务器)下载文件(预训练模型) :params file: 如果是文件路径 且这个路径不存在文件就尝试下载文件 果是url地址 就直接下载文件
utils/google_utils.py:60
↓ 2 callersFunctionautopad
为same卷积或same池化作自动扩充(0填充) Pad to 'same' :params k: 卷积核的kernel_size :return p: 自动计算的需要pad值(0填充)
models/common.py:23
↓ 2 callersMethodbackward
(ctx, grad_output)
models/activations.py:71
↓ 2 callersFunctionbox_area
(box)
utils/metrics.py:352
↓ 2 callersMethodcache_labels
用在__init__函数中 cache数据集label 加载label信息生成cache文件 Cache dataset labels, check images and read shapes :params path: cache文件保存地址
utils/datasets.py:318
↓ 2 callersFunctioncheck_anchor_order
用在check_anchors最后 确定anchors和stride的顺序是一致的 Check anchor order against stride order for YOLOv5 Detect() module m, and correct if necessary :para
utils/autoanchor.py:13
↓ 2 callersMethodcheck_and_upload_dataset
(self, opt)
utils/wandb_logging/wandb_utils.py:138
↓ 2 callersFunctioncheck_online
在下面的check_git_status、check_requirements等函数中使用 检查当前主机网络连接是否可用
utils/general.py:167
↓ 2 callersFunctioncopy_attr
在ModelEMA函数和yolo.py中Model类的autoshape函数中调用 复制b的属性(这个属性必须在include中而不在exclude中)给a :params a: 对象a(待赋值) :params b: 对象b(赋值) :params include:
utils/torch_utils.py:433
↓ 2 callersMethodcreate_dataset_table
(self, dataset, class_to_id, name='dataset')
utils/wandb_logging/wandb_utils.py:255
↓ 2 callersFunctionde_parallel
用在train.py中, 用于加载和保存模型(参数) 判断单卡还是多卡(能否并行) 多卡返回model.module 单卡返回model
utils/torch_utils.py:417
↓ 2 callersMethoddownload_dataset_artifact
(self, path, alias)
utils/wandb_logging/wandb_utils.py:183
↓ 2 callersFunctiondownload_one
Download 1 file :params url: 文件下载地址 Path(url).name=文件名 :params dir: 文件保存的目录
utils/general.py:429
↓ 2 callersFunctionemojis
在下面的check_git_status、check_requirements等函数中使用 返回Windows系统可以安全、完整显示的字符串 Return platform-dependent emoji-safe version of string
utils/general.py:181
↓ 2 callersMethodforward_once
:params x: 输入图像 :params profile: True 可以做一些性能评估 :params feature_vis: True 可以做一些特征可视化 :return train: 一个tensor list 存放三
models/yolo.py:339
↓ 2 callersMethodfuse
用在detect.py、val.py fuse model Conv2d() + BatchNorm2d() layers 调用torch_utils.py中的fuse_conv_and_bn函数和common.py中Conv模块的fuseforward函数
models/yolo.py:449
↓ 2 callersFunctionget_hash
(paths)
utils/datasets.py:48
↓ 2 callersMethodget_relu_coefs
(self, x)
models/activations.py:155
↓ 2 callersFunctionget_run_info
(run_path)
utils/wandb_logging/wandb_utils.py:38
↓ 2 callersFunctionis_docker
在后面的check_git_status和check_imshow等函数中被调用 查询当前环境是否是docker环境 Is environment a Docker container?
utils/general.py:105
↓ 2 callersFunctionload_mosaic
用在LoadImagesAndLabels模块的__getitem__函数 进行mosaic数据增强 将四张图片拼接在一张马赛克图像中 loads images in a 4-mosaic :param index: 需要获取的图像索引 :return: img4: mos
utils/datasets.py:748
↓ 2 callersFunctionmain
(opt)
train.py:711
↓ 2 callersMethodmap_val_table_path
(self)
utils/wandb_logging/wandb_utils.py:249
↓ 2 callersMethodnew_video
(self, path)
utils/datasets.py:1335
↓ 2 callersFunctionparse_opt
weights: 权重文件 cfg: 模型配置文件 包括nc、depth_multiple、width_multiple、anchors、backbone、head等 data: 数据集配置文件 包括path、train、val、test、nc、names、download
train.py:626
↓ 2 callersFunctionsafe_download
下载 url/url2 路径对应的网页文件 Attempts to download file from url or url2, checks and removes incomplete downloads < min_bytes :params file: 要下载的文
utils/google_utils.py:27
↓ 2 callersFunctionsave_one_box
用在detect.py文件中 由opt的save-crop参数控制执不执行 将预测到的目标从原图中扣出来 剪切好 并保存 会在runs/detect/expn下生成crops文件,将剪切的图片保存在里面 Save image crop as {file} with crop siz
utils/general.py:929
↓ 2 callersFunctionstrip_optimizer
用在train.py模型训练完后 将optimizer、training_results、updates...从保存的模型文件f中删除 Strip optimizer from 'f' to finalize training, optionally save as 's'
utils/general.py:785
↓ 2 callersFunctiontrain
:params hyp: data/hyps/hyp.scratch.yaml hyp dictionary :params opt: main中opt参数 :params device: 当前设备
train.py:61
↓ 2 callersFunctionxyn2xy
用在datasets.py的load_mosaic和load_mosaic9函数 xy(normalized) -> xy Convert normalized segments into pixel segments, shape (n,2)
utils/general.py:650
↓ 1 callersMethod__init__
(self, path, img_size=640, stride=32)
utils/datasets.py:1252
↓ 1 callersMethod__iter__
迭代器
utils/datasets.py:1287
↓ 1 callersMethod_descale_pred
用在上面的__init__函数上 将推理结果恢复到原图图片尺寸 Test Time Augmentation(TTA)中用到 de-scale predictions following augmented inference (inverse operation)
models/yolo.py:406
↓ 1 callersMethod_initialize_biases
用在上面的__init__函数上 initialize biases into Detect(), cf is class frequency https://arxiv.org/abs/1708.02002 section 3.3
models/yolo.py:387
↓ 1 callersMethod_make_grid
构造网格
models/yolo.py:238
↓ 1 callersFunctionap_per_class
用于val.py中计算每个类的mAP 计算每一个类的AP指标(average precision)还可以 绘制P-R曲线 mAP基本概念: https://www.bilibili.com/video/BV1ez4y1X7g2 Source: https://github.c
utils/metrics.py:24
↓ 1 callersFunctionapply_classifier
用在detect.py文件的nms后继续对feature map送入model2 进行二次分类 几乎不会用它 定义了一个二级分类器来处理yolo的输出 当前实现本质上是一个参考起点,您可以使用它自行实现此项 比如你有照片与汽车与车牌, 你第一次剪切车牌, 并将其发送到第二阶段分
utils/general.py:848
↓ 1 callersFunctionaugment_hsv
用在LoadImagesAndLabels模块的__getitem__函数 hsv色域增强 处理图像hsv,不对label进行任何处理 :param img: 待处理图片 BGR [736, 736] :param hgain: h通道色域参数 用于生成新的h通道
utils/datasets.py:722
↓ 1 callersFunctionbbox_ioa
用在cutout中 计算box1和box2相交面积与box2面积的比例 Returns the intersection over box2 area given box1, box2. box1 is 4, box2 is nx4. boxes are x1y1x2
utils/datasets.py:1177
↓ 1 callersFunctionbbox_iou
在ComputeLoss的__call__函数中调用计算回归损失 :params box1: 预测框 :params box2: 预测框 :return box1和box2的IoU/GIoU/DIoU/CIoU
utils/metrics.py:297
↓ 1 callersFunctionbox_candidates
用在random_perspective中 对透视变换后的图片label进行筛选 去除被裁剪过小的框(面积小于裁剪前的area_thr) 还有长和宽必须大于wh_thr个像素,且长宽比范围在(1/ar_thr, ar_thr)之间的限制 Compute candidate boxes
utils/datasets.py:1063
↓ 1 callersMethodbuild_targets
Build targets for compute_loss() :params p: 预测框 由模型构建中的三个检测头Detector返回的三个yolo层的输出 tensor格式 list列表 存放三个tensor 对应的是三
utils/loss.py:271
↓ 1 callersFunctionbutter_lowpass
(cutoff, fs, order)
utils/plots.py:554
↓ 1 callersFunctioncheck_anchors
用于train.py中 通过bpr确定是否需要改变anchors 需要就调用k-means重新计算anchors Check anchor fit to data, recompute if necessary :params dataset: 自定义数据集LoadImage
utils/autoanchor.py:32
↓ 1 callersFunctioncheck_git_status
用在train.py的main函数的一开始 检查当前代码版本是否是最新的 如果不是最新的 会提示使用git pull命令进行升级
utils/general.py:189
↓ 1 callersFunctioncheck_imshow
用在detect.py中 使用webcam的时候调用 检查当前环境是否可以使用opencv.imshow显示图片 主要有两点限制: Docker环境 + Google Colab环境
utils/general.py:309
↓ 1 callersFunctioncheck_python
用在下面的函数check_requirements中 检查当前的版本号是否满足最小版本号minimum Check current python version vs. required python version
utils/general.py:223
↓ 1 callersFunctioncheck_wandb_resume
(opt)
utils/wandb_logging/wandb_utils.py:47
↓ 1 callersFunctionclean_str
在datasets.py中的LoadStreams类中被调用 字符串s里在pattern中字符替换为下划线_ 注意pattern中[]不能省 Cleans a string by replacing special characters with underscore _
utils/general.py:468
↓ 1 callersFunctioncoco80_to_coco91_class
用在test.py中 从80类映射到91类的coco索引 取得对应的class id 将80个类的coco索引换成91类的coco索引 :return x: 为80类的每一类在91类中的位置
utils/general.py:533
↓ 1 callersFunctioncompute_ap
用于ap_per_class函数中 计算某个类别在某个iou阈值下的mAP Compute the average precision, given the recall and precision curves :params recall: (list) [1635] 在
utils/metrics.py:129
next →1–100 of 311, ranked by callers