Skip to content

Commit

Permalink
edits with Chee
Browse files Browse the repository at this point in the history
  • Loading branch information
boris-kz committed Feb 7, 2025
1 parent ac46d45 commit c94433b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
26 changes: 24 additions & 2 deletions frame_2D_alg/agg_recursion.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ def agg_H_seq(focus): # sequential level-updating pipeline
cluster_C_(edge) # recursive, within edge?
G_ = [Lev + lev for Lev, lev in zip_longest(G_, edge.node_, fillvalue=[])] # concat levels
Nnest = max(Nnest, edge.nnest)
if Nnest==2: # no added levs
return frame
frame.nnest = Nnest
frame.node_ = [frame.node_[0], *G_] # replace edge_ with new node levels
agg_H = []
Expand All @@ -337,16 +339,36 @@ def agg_H_seq(focus): # sequential level-updating pipeline
while agg_H:
lev_G = agg_H.pop(); _n,n = hG.Et[2], lev_G[2]
L = comp_N(hG,lev_G, rn = _n/n if _n>n else n/_n)
if Val_(L.Et, _Et=L.Et) > 0: # dLev = filter update value?
if Val_(L.Et, _Et=L.Et) > 0: # dLev = filter update value? or specific to Dm_attr?
# pass attr matches instead of hG:
lev_G.aves = weigh_m_(hG)
# centroid M += m/attr (mags are not commensurable), mC=min: +ve
# cost attrs mC is always -ve, no independent normalization?
# project/d: shift to higher or lower m?
lev_G.aves = [*hG.Et, hG.box, len(hG.node_[-1])] # min,max coord filters = box, L=len node_
# min,max coord filters = box, L=len node_
hG = lev_G # replace higher lev
else: break
frame.node_ = agg_H
return frame

def weigh_m_(m_, _M, ave=1e-7): # adjust weights on attr matches, also add cost attrs

L = len(m_)
while True:
w_ = [] # weight = inverted abs rational deviation from mean
for m in m_:
w_ += [m/_M if _M > m else _M/m] # min m = 1e-7
rw = 1 / (sum(w_) / L)
w_ = [w * rw for w in w_] # normalize to average weight = 1
# should be W: abs w update, M is stable anyway?
M = sum((m if m else 1e-7) * w for m, w in zip(m_, w_)) / L
if abs(M - _M) > ave:
_M = M
else:
break

return w_, M

if __name__ == "__main__":
# image_file = './images/raccoon_eye.jpeg'
image_file = './images/toucan.jpg'
Expand Down
7 changes: 5 additions & 2 deletions frame_2D_alg/frame_blobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class Caves(object): # hyper-parameters, init a guess, adjusted by feedback
def __init__(ave):
ave.m = 5
ave.d = 10 # ave change to Ave_min from the root intra_blob?
ave.md = [ave.ma, ave.d] # for aves[fd]
ave.L = 4
ave.rn = 1000 # max scope disparity
ave.max_dist = 2
Expand All @@ -74,6 +73,7 @@ def __init__(ave):
ave.inv = 20
ave.mG = 10
ave.mM = 2
ave.mD = 2
ave.mMa = .1
ave.mA = .2
ave.mL = 2
Expand Down Expand Up @@ -109,6 +109,7 @@ def __init__(ave):
"ave_cs_d": 1,
"mG": 1,
"mM": 1,
"mD": 1,
"mMa": 1,
"mA": 1,
"mL": 1,
Expand All @@ -133,7 +134,9 @@ def sum_aves(ave):

def __getattribute__(ave,name):
coefs = object.__getattribute__(ave, "coefs")
if name == "md":
if name == "coefs":
return object.__getattribute__(ave, name)
elif name == "md":
return [ave.m * coefs["m"], ave.d * coefs["d"]] # get updated md
else:
return object.__getattribute__(ave, name) * coefs[name] # always return ave * coef
Expand Down

0 comments on commit c94433b

Please sign in to comment.