CoolFace
Apppublic

kalpkanungo/SceneGraphNet

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
spatial_rules.py21 linesDownload Raw Back to src
1def get_relation(subj_box, obj_box):2    sx, sy, sw, sh = subj_box3    ox, oy, ow, oh = obj_box4 5    # centers6    scx, scy = sx + sw / 2, sy + sh / 27    ocx, ocy = ox + ow / 2, oy + oh / 28 9    # vertical relation10    if scy < ocy - 20:11        return "above"12    elif scy > ocy + 20:13        return "below"14 15    # horizontal relation16    if scx < ocx - 20:17        return "left_of"18    elif scx > ocx + 20:19        return "right_of"20 21    return "near"