惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
Schneier on Security
Schneier on Security
H
Help Net Security
PCI Perspectives
PCI Perspectives
博客园 - 司徒正美
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Google Online Security Blog
Google Online Security Blog
V
Visual Studio Blog
Engineering at Meta
Engineering at Meta
Last Week in AI
Last Week in AI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
L
LINUX DO - 最新话题
GbyAI
GbyAI
IT之家
IT之家
TaoSecurity Blog
TaoSecurity Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
J
Java Code Geeks
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
N
News and Events Feed by Topic
Recent Announcements
Recent Announcements
Google DeepMind News
Google DeepMind News
美团技术团队
T
Troy Hunt's Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
Cloudbric
Cloudbric
A
About on SuperTechFans
Recorded Future
Recorded Future
Microsoft Security Blog
Microsoft Security Blog
阮一峰的网络日志
阮一峰的网络日志
H
Hacker News: Front Page
Forbes - Security
Forbes - Security
Webroot Blog
Webroot Blog
D
DataBreaches.Net
L
LangChain Blog
S
Schneier on Security
博客园_首页
S
SegmentFault 最新的问题
Apple Machine Learning Research
Apple Machine Learning Research
N
News | PayPal Newsroom
Hacker News - Newest:
Hacker News - Newest: "LLM"
爱范儿
爱范儿
量子位
T
The Exploit Database - CXSecurity.com
博客园 - 【当耐特】
T
Threatpost
The Hacker News
The Hacker News
N
News and Events Feed by Topic
罗磊的独立博客
Spread Privacy
Spread Privacy
Hacker News: Ask HN
Hacker News: Ask HN

博客园 - Sanny.Liu-CV&&ML

GRPO 是否“真的在学” clip的底层原理---深入源码:手把手剖析OpenAI CLIP的实现结构与细节 Decoder-Only、Encoder-Only 与 Encoder-Decoder linux 进程内存占用查看 用PyTorch从零搭建一个Transformer模型 基于树编辑距离的相似度(TEDS) 图片,二进制,base64互转 OCR相关的笔记 opencv的RGB 颜色表 transformers中的generate函数解读 5 levels of text splitting PyMuPDF工具说明 OCR表格识别 uvicorn,一个无敌的 Python 库! stable diffusion中controlnet详细使用方法总结 lora训练参数设置 Dreambooth, Textual Inversion, LoRA, Hypernetworks ,示意图解释 转载:深度学习:蒸馏Distill MoveNet:超快且准确的姿态检测模型 根据5个人脸特征点,快速计算人脸角度
算一个bbox和一个mask区域的重叠
Sanny.Liu-CV&&ML · 2025-11-27 · via 博客园 - Sanny.Liu-CV&&ML
def get_bbox_in_mask_overlap_ratio(bbox, mask):
    """
    判断边界框是否在二值化的 mask 区域内。(二值化为0和255),重叠区域占bbox的比率

    参数:
        bbox: tuple 或 list,表示边界框 (x_min, y_min, x_max, y_max)
        mask: numpy 数组,二值化的图像,值为 1 表示区域内,值为 0 表示区域外

    返回:
        bool: 如果 bbox 完全在 mask 区域内,返回 True;否则返回 False
    """
    x_min, y_min, x_max, y_max = bbox

    # 检查 bbox 的边界是否超出 mask 的范围
    if x_min < 0 or y_min < 0 or x_max > mask.shape[1] or y_max > mask.shape[0]:
        return False

    # 提取 bbox 区域对应的 mask 子区域
    bbox_mask = mask[int(y_min):int(y_max), int(x_min):int(x_max)]

    ## mask fg val is 1
    # 判断 bbox 区域是否完全在 mask 区域内
    #return np.any(bbox_mask == 255)
    bbox_area = (y_max-y_min)*(x_max-x_min)
    ## 获得由多少个重叠的像素
    bin_num = np.sum(bbox_mask == 255)
    ## 计算重叠区域的占比
    ratio = bin_num/(bbox_area+1)

    print('===================',bin_num, bbox_area, bin_num*1.0/bbox_area)
    return ratio