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

推荐订阅源

量子位
Google DeepMind News
Google DeepMind News
爱范儿
爱范儿
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
NISL@THU
NISL@THU
T
Threat Research - Cisco Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
L
Lohrmann on Cybersecurity
V
Visual Studio Blog
Cyberwarzone
Cyberwarzone
D
Docker
The Hacker News
The Hacker News
C
CERT Recently Published Vulnerability Notes
Vercel News
Vercel News
Project Zero
Project Zero
S
Schneier on Security
aimingoo的专栏
aimingoo的专栏
I
Intezer
腾讯CDC
M
MIT News - Artificial intelligence
Hugging Face - Blog
Hugging Face - Blog
P
Palo Alto Networks Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
AWS News Blog
AWS News Blog
GbyAI
GbyAI
MongoDB | Blog
MongoDB | Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
V
Vulnerabilities – Threatpost
G
Google Developers Blog
N
Netflix TechBlog - Medium
The Cloudflare Blog
Microsoft Security Blog
Microsoft Security Blog
Y
Y Combinator Blog
A
Arctic Wolf
S
Securelist
酷 壳 – CoolShell
酷 壳 – CoolShell
Cisco Talos Blog
Cisco Talos Blog
Recent Announcements
Recent Announcements
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LINUX DO - 热门话题
T
Threatpost
Latest news
Latest news
Blog — PlanetScale
Blog — PlanetScale
Security Latest
Security Latest
Engineering at Meta
Engineering at Meta
大猫的无限游戏
大猫的无限游戏
H
Help Net Security
The GitHub Blog
The GitHub Blog
T
Tor Project blog
P
Proofpoint News Feed

博客园 - 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