【网盘系统3.0版本】百度云盘手动cookie获取,添加到扫码系统管理平台。

一.获取cookie步骤
1.谷歌浏览器选择开发者模式。
2.选择网路,过滤接口main
3.选择request head,cookie列表里面可查看

在这里插入图片描述
二.添加到管理平台。
1.登录管理平台,输入账户和密码
2.选择账户设置,添加cookie。
在这里插入图片描述

4.复制卡密链接,分享给用户,用户通过卡密链接就可以扫码登录啦。

在这里插入图片描述

3.0新增:
新增:多账户体系,部署一台服务器支持多用户使用,可以设置每个用户过期时间、用户权限。

在这里插入图片描述
在这里插入图片描述

### GIoU 的计算公式 GIoU (Generalized Intersection over Union) 是一种扩展的 IoU 损失函数,解决了传统 IoU 在边界框无重叠情况下的不足。其核心思想是在 IoU 基础上引入了一个额外项,用于衡量预测框和真实框之间的相对位置关系。 #### 定义与公式 设 \( B \) 和 \( B^{gt} \) 分别表示预测框和真实框,\( C \) 表示能够覆盖 \( B \) 和 \( B^{gt} \) 的最小闭合区域(即包围盒)。则: \[ \text{IoU}(B, B^{gt}) = \frac{\text{Area}(B \cap B^{gt})}{\text{Area}(B \cup B^{gt})} \] 而 GIoU 的定义为: \[ \text{GIoU}(B, B^{gt}) = \text{IoU}(B, B^{gt}) - \frac{\text{Area}(C \setminus (B \cup B^{gt}))}{\text{Area}(C)} \] 其中: - \( \text{Area}(B \cap B^{gt}) \) 表示预测框和真实框交集面积。 - \( \text{Area}(B \cup B^{gt}) \) 表示预测框和真实框并集面积。 - \( \text{Area}(C) \) 表示最小闭包矩形 \( C \) 的总面积。 - \( \text{Area}(C \setminus (B \cup B^{gt})) \) 表示最小闭包矩形减去预测框和真实框并集部分的剩余面积。 通过这一公式,即使预测框和真实框完全不相交,也可以得到一个有意义的损失值[^1]。 --- ### 通用 IoU 损失函数定义 传统的 IoU 损失函数可以被定义为: \[ L_{\text{IoU}}(B, B^{gt}) = 1 - \text{IoU}(B, B^{gt}) \] 然而,这种形式在预测框和真实框完全没有重叠的情况下会失效,因为此时 \( \text{IoU}(B, B^{gt}) = 0 \),导致梯度消失问题。 相比之下,GIoU 提供了一种更鲁棒的方式处理这种情况,使得即使没有重叠也能提供有效的梯度方向[^2]。 --- ### Python 实现代码 以下是基于上述公式的 GIoU 计算实现: ```python import torch def giou_loss(pred_boxes, target_boxes): """ Calculate the Generalized IoU loss between predicted and target bounding boxes. Args: pred_boxes: Tensor of shape (N, 4), where N is the number of boxes, each box represented as [x1, y1, x2, y2]. target_boxes: Tensor of shape (N, 4). Returns: A scalar tensor representing the mean GIoU loss across all boxes. """ # Compute intersection coordinates xA = torch.max(pred_boxes[:, 0], target_boxes[:, 0]) yA = torch.max(pred_boxes[:, 1], target_boxes[:, 1]) xB = torch.min(pred_boxes[:, 2], target_boxes[:, 2]) yB = torch.min(pred_boxes[:, 3], target_boxes[:, 3]) # Compute area of intersection rectangle I inter_area = torch.clamp(xB - xA + 1, min=0.0) * torch.clamp(yB - yA + 1, min=0.0) # Compute areas of prediction and ground truth rectangles pred_area = (pred_boxes[:, 2] - pred_boxes[:, 0] + 1) * \ (pred_boxes[:, 3] - pred_boxes[:, 1] + 1) target_area = (target_boxes[:, 2] - target_boxes[:, 0] + 1) * \ (target_boxes[:, 3] - target_boxes[:, 1] + 1) # Compute union area U union_area = pred_area + target_area - inter_area # Compute IOU iou = inter_area / union_area # Compute smallest enclosing box C c_xA = torch.min(pred_boxes[:, 0], target_boxes[:, 0]) c_yA = torch.min(pred_boxes[:, 1], target_boxes[:, 1]) c_xB = torch.max(pred_boxes[:, 2], target_boxes[:, 2]) c_yB = torch.max(pred_boxes[:, 3], target_boxes[:, 3]) # Area of enclosing box C enclose_area = (c_xB - c_xA + 1) * (c_yB - c_yA + 1) # Compute GIoU giou = iou - ((enclose_area - union_area) / enclose_area) # Return GIoU loss return 1 - giou.mean() ``` 此代码实现了 GIoU 损失的计算过程,并支持批量输入的张量操作。 --- ### 总结 GIoU 改进了传统 IoU 损失函数存在的缺陷,特别是在预测框和真实框无重叠的情况下的表现更为优越。它不仅保留了 IoU 对于重叠区域的有效评估能力,还通过引入外部闭包区域进一步增强了模型的学习效果。 ---
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值