MCPcopy Create free account

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

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

↓ 1 callersFunctioncreate_dataset_artifact
(opt)
utils/wandb_logging/log_dataset.py:10
↓ 1 callersFunctioncreate_folder
用在flatten_recursive函数中 但flatten_recursive函数没用到 所以这个函数也没用到 创建文件夹 Create folder
utils/datasets.py:1524
↓ 1 callersFunctioncutout
用在LoadImagesAndLabels模块中的__getitem__函数进行cutout增强 v5源码作者默认是没用用这个的 感兴趣的可以测试一下 cutout数据增强, 给图片随机添加随机大小的方块噪声 目的是提高泛化能力和鲁棒性 实现:随机选择一个固定大小的正方形区域,然
utils/datasets.py:1165
↓ 1 callersFunctiondate_modified
用在select_device 返回path文件人类可读的修改日期 return human-readable file modification date, i.e. '2021-3-26' :params path: 文件名 默认当前文件
utils/torch_utils.py:80
↓ 1 callersMethoddownload_model_artifact
(self, opt)
utils/wandb_logging/wandb_utils.py:192
↓ 1 callersMethodend_epoch
(self, best_result=False)
utils/wandb_logging/wandb_utils.py:314
↓ 1 callersFunctionexif_size
(img)
utils/datasets.py:55
↓ 1 callersFunctionfeature_visualization
用在yolo.py的Model类中的forward_once函数中 自行选择任意层进行可视化该层feature map 可视化feature map(模型任意层都可以用) :params x: Features map [bs, channels, height, width]
utils/plots.py:562
↓ 1 callersMethodfinish_run
(self)
utils/wandb_logging/wandb_utils.py:328
↓ 1 callersMethodforward
(self, x, augment=False, profile=False)
models/yolo.py:311
↓ 1 callersMethodforward_augment
TTA Test Time Augmentation
models/yolo.py:321
↓ 1 callersFunctionfuse_conv_and_bn
在yolo.py中Model类的fuse函数中调用 融合卷积层和BN层(测试推理使用) Fuse convolution and batchnorm layers 方法: 卷积层还是正常定义, 但是卷积层的参数w,b要改变 通过只改变卷积参数, 达到CONV+BN的效果
utils/torch_utils.py:325
↓ 1 callersFunctionget_latest_run
用在train.py查找最近的pt文件进行断点续训 用于返回该项目中最近的模型 'last.pt'对应的路径 :params search_dir: 要搜索的文件的根目录 默认是 '.' 表示搜索该项目中的文件
utils/general.py:93
↓ 1 callersFunctionget_token
实现从cookie中获取令牌token 在gdrive_download中使用
utils/google_utils.py:166
↓ 1 callersFunctiongit_describe
用在select_device 用于返回path文件可读的git描述 return human-readable git description i.e. v5.0-5-g3e25f1e https://git-scm.com/docs/git-describe path
utils/torch_utils.py:66
↓ 1 callersFunctiongsutil_getsize
用于返回网站链接对应文件的大小 gs://bucket/file size https://cloud.google.com/storage/docs/gsutil/commands/du
utils/google_utils.py:16
↓ 1 callersMethodhex2rgb
(h)
utils/plots.py:48
↓ 1 callersFunctionhist2d
用在plot_evolution 使用numpy画出2d直方图 2d histogram used in labels.png and evolve.png
utils/plots.py:309
↓ 1 callersFunctioninit_seeds
在train函数的一开始调用 用于设置一系列的随机数种子
utils/general.py:82
↓ 1 callersFunctioninit_torch_seeds
用在general.py的init_seeds函数 用于初始化随机种子并确定训练模式 Speed-reproducibility tradeoff https://pytorch.org/docs/stable/notes/randomness.html
utils/torch_utils.py:49
↓ 1 callersFunctioninitialize_weights
在yolo.py的Model类中的init函数被调用 用于初始化模型权重
utils/torch_utils.py:266
↓ 1 callersFunctionintersect_dicts
用于train.py中载入预训练模型时,筛选预训练权重中的键值对 用于筛选字典中的键值对 将db中的键值对复制给da,但是除了exclude中的键值对
utils/torch_utils.py:139
↓ 1 callersFunctionis_colab
用到后面的check_imshow函数中 检查当前环境是否是Google Colab环境 Is environment a Google Colab instance?
utils/general.py:110
↓ 1 callersFunctionkmean_anchors
在check_anchors中调用 使用K-means + 遗传算法 算出更符合当前数据集的anchors Creates kmeans-evolved anchors from training dataset :params path: 数据集的路径/数据集本身
utils/autoanchor.py:113
↓ 1 callersFunctionlabels_to_class_weights
用在train.py中 得到每个类别的权重 标签频率高的类权重低 从训练(gt)标签获得每个类的权重 标签频率高的类权重低 Get class weights (inverse frequency) from training labels :params label
utils/general.py:486
↓ 1 callersFunctionlabels_to_image_weights
用在train.py中 利用上面得到的每个类别的权重得到每一张图片的权重 再对图片进行按权重进行采样 通过每张图片真实gt框的真实标签labels和上一步labels_to_class_weights得到的每个类别的权重进行采样 Produces image weights bas
utils/general.py:515
↓ 1 callersFunctionload_classifier
在detect.py中调用 进行二次分类 用于检测结束后可能需要第二次分类 直接修改torchvision中的预训练模型的分类类别即可 :params name: 分类模型名字 默认resnet101 :params n: 分类模型的分类类别数 需要在加载了预训练模型后将
utils/torch_utils.py:362
↓ 1 callersMethodlog_dataset_artifact
(self, data_file, single_cls, project, overwrite_config=False)
utils/wandb_logging/wandb_utils.py:218
↓ 1 callersMethodlog_model
(self, path, opt, epoch, fitness_score, best_model=False)
utils/wandb_logging/wandb_utils.py:204
↓ 1 callersMethodlog_training_progress
(self, predn, path, names)
utils/wandb_logging/wandb_utils.py:286
↓ 1 callersFunctionmain
(opt)
val.py:517
↓ 1 callersFunctionmain
(opt)
detect.py:339
↓ 1 callersFunctionmain
(opt)
models/export.py:196
↓ 1 callersFunctionmixup
用在LoadImagesAndLabels模块中的__getitem__函数进行mixup增强 mixup数据增强, 按比例融合两张图片 Applies MixUp augmentation 论文: https://arxiv.org/pdf/1710.09412.pdf
utils/datasets.py:1227
↓ 1 callersMethodnms
add or remove NMS module 可以自选是否扩展model 增加模型nms功能 直接调用common.py中的NMS模块 一般是用不到的 前向推理结束直接掉用non_max_suppression函数即可
models/yolo.py:465
↓ 1 callersFunctionone_cycle
用在train.py中的学习率衰减策略模块 one_cycle lr lr先增加, 再减少, 再以更小的斜率减少 论文: https://arxiv.org/pdf/1803.09820.pdf
utils/general.py:478
↓ 1 callersFunctionoutput_to_target
用在test.py中进行绘制前3个batch的预测框predictions 因为只有predictions需要修改格式 target是不需要修改格式的 将经过nms后的output [num_obj,x1y1x2y2+conf+cls] -> [num_obj, batch_id+class
utils/plots.py:145
↓ 1 callersMethodpandas
(self)
models/common.py:595
↓ 1 callersFunctionparse_model
用在上面Model模块中 解析模型文件(字典形式),并搭建网络结构 这个函数其实主要做的就是: 更新当前层的args(参数),计算c2(当前层的输出channel) => 使用当前层的参数搭建当前层 =>
models/yolo.py:34
↓ 1 callersFunctionparse_opt
opt参数详解 data: 数据集配置文件地址 包含数据集的路径、类别个数、类名、下载地址等信息 weights: 模型的权重文件地址 weights/yolov5s.pt batch_size: 前向传播的批次大小 默认32 imgsz: 输入网络的图片分
val.py:465
↓ 1 callersFunctionparse_opt
opt参数解析 weights: 模型的权重地址 默认 weights/best.pt source: 测试数据文件(图片或视频)的保存路径 默认data/images imgsz: 网络输入图片的大小 默认640 conf-thres: object置信度
detect.py:282
↓ 1 callersFunctionparse_opt
weights: 要转换的权重文件pt地址 默认='../weights/best.pt' img-size: 输入模型的图片size=(height, width) 默认=[640, 640] batch-size: batch大小 默认=1 device: 模型
models/export.py:164
↓ 1 callersFunctionplot_evolution
用在train.py的超参进化算法后,输出参超进化的结果 超参进化在每一轮都会产生一系列的进化后的超参(存在yaml_file) 以及每一轮都会算出当前轮次的7个指标(evolve.txt) 这个函数要做的就是把每个超参在所有轮次变化的值和maps以散点图的形式显示出来,并标出最大
utils/plots.py:431
↓ 1 callersFunctionplot_labels
通常用在train.py中 加载数据datasets和labels后 对labels进行可视化 分析labels信息 plot dataset labels 生成labels_correlogram.jpg和labels.jpg 画出数据集的labels相关直方图信息 :par
utils/plots.py:368
↓ 1 callersFunctionplot_lr_scheduler
用在train.py中学习率设置后可视化一下 Plot LR simulating training for full epochs :params optimizer: 优化器 :params scheduler: 策略调整器 :params epochs: x
utils/plots.py:284
↓ 1 callersFunctionplot_pr_curve
用于ap_per_class函数 Precision-recall curve 绘制PR曲线 :params px: [1000] 横坐标 recall 值为0~1直接取1000个数 :params py: list{nc} nc个[1000] 所有类别在IOU=0.5,横
utils/metrics.py:381
↓ 1 callersFunctionplot_results
用在训练结束, 对训练结果进行可视化 画出训练完的 results.txt Plot training 'results*.txt' 最终生成results.png :params start: 读取数据的开始epoch 因为result.txt的数据是一个epoch一行的
utils/plots.py:463
↓ 1 callersFunctionplot_results_overlay
可以用在train.py或者自写一个文件 画出训练完的 results.txt Plot training 'results*.txt' 而且将原先的10个折线图缩减为5个折线图, train和val相对比 Plot training 'results*.txt', overlayi
utils/plots.py:514
↓ 1 callersFunctionplot_study_txt
没用到 Plot study.txt generated by val.py
utils/plots.py:591
↓ 1 callersFunctionprint_mutation
用在train.py的进化超参结束后 打印进化后的超参结果和results到evolve.txt和hyp_evolved.yaml中 Print mutation results to evolve.txt (for use with train.py --evolve) :
utils/general.py:809
↓ 1 callersMethodprocess_batch
:params detections: [N, 6] = [pred_obj_num, x1y1x2y2+object_conf+cls] = [300, 6] 一个batch中一张图的预测信息 其中x1y1x2y2是映射到
utils/metrics.py:192
↓ 1 callersFunctionprocess_wandb_config_ddp_mode
(opt)
utils/wandb_logging/wandb_utils.py:61
↓ 1 callersFunctionprofile
输出某个网络结构(操作ops)的一些信息: 总参数 浮点计算量 前向传播时间 反向传播时间 输入变量的shape 输出变量的shape :params x: 输入tensor x :params ops: 操作ops(某个网络结构) :params n: 执行多少轮
utils/torch_utils.py:164
↓ 1 callersFunctionprune
可以用于test.py和detect.py中进行模型剪枝 对模型model进行剪枝操作 以增加模型的稀疏性 使用prune工具将参数稀疏化 https://github.com/ultralytics/yolov5/issues/304 :params model: 模型
utils/torch_utils.py:305
↓ 1 callersFunctionresample_segments
用在datasets.py文件中的random_perspective函数中 对segment重新采样,比如说segment坐标只有100个,通过interp函数将其采样为n个(默认1000) :params segments: [N, x1x2...] :params n:
utils/general.py:958
↓ 1 callersFunctionround_labels
(labels)
utils/datasets.py:1625
↓ 1 callersFunctionrun
(weights='weights/yolov5s.pt', # 权重文件地址 默认 weights/best.pt source='data/images', # 测试数据文件(图片
detect.py:30
↓ 1 callersFunctionrun
weights: 要转换的权重文件pt地址 默认='../weights/best.pt' img-size: 输入模型的图片size=(height, width) 默认=[640, 640] batch-size: batch大小 默认=1 device: 模型
models/export.py:28
↓ 1 callersFunctionscale_img
用于yolo.py文件中Model类的forward_augment函数中 实现对图片的缩放操作 :params img: 原图 :params ratio: 缩放比例 默认=1.0 原图 :params same_shape: 缩放之后尺寸是否是要求的大小(必须是g
utils/torch_utils.py:387
↓ 1 callersFunctionsegment2box
用在datasets.py文件中的random_perspective函数中 将一个多边形标签(不是矩形标签 到底是几边形未知)转化为一个矩形标签 方法: 对多边形所有的点x1y1 x2y2... 获取其中的(x_min,y_min)和(x_max,y_max) 作为矩形labe
utils/general.py:975
↓ 1 callersFunctionsegments2boxes
用在datasets.py文件中的verify_image_label函数中 将多个多边形标签(不是矩形标签 到底是几边形未知)转化为多个矩形标签 Convert segment labels to box labels, i.e. (cls, xy1, xy2, ...) to
utils/general.py:994
↓ 1 callersMethodsetup_training
(self, opt, data_dict)
utils/wandb_logging/wandb_utils.py:148
↓ 1 callersMethodshow
(self)
models/common.py:579
↓ 1 callersFunctionsmooth_BCE
用在ComputeLoss类中 标签平滑操作 [1, 0] => [0.95, 0.05] https://github.com/ultralytics/yolov3/issues/238#issuecomment-598028441 https://arxiv.org
utils/loss.py:10
↓ 1 callersFunctionsparsity
在prune中调用 用于求模型model的稀疏程度sparsity Return global model sparsity
utils/torch_utils.py:292
↓ 1 callersMethodupdate
(self, i, cap)
utils/datasets.py:1406
↓ 1 callersMethodupdate_attr
(self, model, include=(), exclude=('process_group', 'reducer'))
utils/torch_utils.py:494
↓ 1 callersFunctionxyxy2xywhn
用在datasets.py的 LoadImagesAndLabels类的__getitem__函数中 将 x1y1x2y2 -> xywh(normalized) (x1, y1): 左上点 (x2, y2): 右下点 (x, y): 中间点 wh: 宽高 Convert n
utils/general.py:635
Method__call__
:params p: 预测框 由模型构建中的三个检测头Detector返回的三个yolo层的输出 tensor格式 list列表 存放三个tensor 对应的是三个yolo层的输出 如: [4, 3,
utils/loss.py:171
Method__call__
(self, i, bgr=False)
utils/plots.py:41
Method__enter__
(self)
utils/general.py:60
Method__exit__
(self, exc_type, exc_val, exc_tb)
utils/general.py:67
Method__getitem__
这部分是数据增强函数,一般一次性执行batch_size次。 训练 数据增强: mosaic(random_perspective) + hsv + 上下左右翻转 测试 数据增强: letterbox :return torch.fr
utils/datasets.py:396
Method__init__
(self, alpha=0.05)
utils/loss.py:28
Method__init__
(self, loss_fcn, gamma=1.5, alpha=0.25)
utils/loss.py:91
Method__init__
(self, model, autobalance=False)
utils/loss.py:118
Method__init__
(self, seconds, *, timeout_msg='', suppress_timeout_errors=True)
utils/general.py:51
Method__init__
train.py model: decay: 衰减函数参数 默认0.9999 考虑过去10000次的真实值 updates: ema更新次数
utils/torch_utils.py:460
Method__init__
params nc: 数据集类别个数 params conf: 预测框置信度阈值 Params iou_thres: iou阈值
utils/metrics.py:178
Method__init__
(self, *args, **kwargs)
utils/datasets.py:132
Method__init__
(self, sampler)
utils/datasets.py:151
Method__init__
初始化过程并没有什么实质性的操作,更多是一个定义参数的过程(self参数),以便在__getitem()__中进行数据增强操作,所以这部分代码只需要抓住self中的各个变量的含义就算差不多了 self.img_files: {list: N} 存放着整个数据集图片的
utils/datasets.py:160
Method__init__
(self, sources='streams.txt', img_size=640, stride=32)
utils/datasets.py:1352
Method__init__
(self, pipe='0', img_size=640, stride=32)
utils/datasets.py:1447
Method__init__
(self)
utils/plots.py:32
Method__init__
(self, opt, name, run_id, data_dict, job_type='Training')
utils/wandb_logging/wandb_utils.py:99
Method__init__
(self, ch=256, nc=80, width=1.0, anchors=())
models/yolo.py:137
Method__init__
detection layer 相当于yolov3中的YOLOLayer层 :params nc: number of classes :params anchors: 传入3个feature map上的所有anchor的大小(P3、P4、P5)
models/yolo.py:168
Method__init__
Standard convolution conv+BN+act :params c1: 输入的channel值 :params c2: 输出的channel值 :params k: 卷积的kernel_size :
models/common.py:34
Method__init__
理论:从高分辨率图像中,周期性的抽出像素点重构到低分辨率图像中,即将图像相邻的四个位置进行堆叠, 聚焦wh维度信息到c通道空,提高每个点感受野,并减少原始信息的丢失,该模块的设计主要是减少计算量加快速度。 Focus wh informati
models/common.py:61
Method__init__
Standard bottleneck Conv+Conv+shortcut :params c1: 第一个卷积的输入channel :params c2: 第二个卷积的输出channel :params shortcut: boo
models/common.py:89
Method__init__
CSP Bottleneck https://github.com/WongKinYiu/CrossStagePartialNetworks :params c1: 整个BottleneckCSP的输入channel :params c2: 整个Bo
models/common.py:108
Method__init__
空间金字塔池化 Spatial pyramid pooling layer used in YOLOv3-SPP :params c1: SPP模块的输入channel :params c2: SPP模块的输出channel :par
models/common.py:159
Method__init__
Concatenate a list of tensors along dimension :params dimension: 沿着哪个维度进行concat
models/common.py:177
Method__init__
(self, gain=2)
models/common.py:207
Method__init__
(self, gain=2)
models/common.py:224
Method__init__
(self, c, num_heads)
models/common.py:244
Method__init__
(self, c1, c2, num_heads, num_layers)
models/common.py:269
Method__init__
(self, c1, c2, n=1, shortcut=True, g=1, e=0.5)
models/common.py:299
Method__init__
(self, c1, r=16)
models/common.py:308
← previousnext →101–200 of 311, ranked by callers