Skip to content

Commit ae1c11e

Browse files
authored
Pifpaf Accuracy+Model export+Pypi setup (#354)
(I)Pifpaf Accuracy debug: (1)pixel shuffle reimplemented (2)input data normalized by mean and std (3)resnet backbone corrected (4)output scale activation corrected (II)Model exportion support (1)Tflite exportion supported (III)Pypi setup support (1)pip install hyperpose python interface supported
1 parent ebc5f1c commit ae1c11e

File tree

10 files changed

+186
-55
lines changed

10 files changed

+186
-55
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,14 @@ libstdtensor-prefix
3838
libstdtracer-prefix
3939
Makefile
4040
test.py
41+
temp.py
4142
save_dir
43+
test_dir
44+
README.rst
45+
dist
46+
build
47+
*.egg*
48+
*whl*
4249
Testing
4350
third_party
4451
venv

export_tflite.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import pathlib
2+
import tensorflow as tf
3+
from functools import partial
4+
from hyperpose import Config,Model,Dataset
5+
6+
#load model weights from hyperpose
7+
Config.set_model_name("new_pifpaf")
8+
Config.set_model_type(Config.MODEL.Pifpaf)
9+
Config.set_dataset_type(Config.DATA.MSCOCO)
10+
config=Config.get_config()
11+
model=Model.get_model(config)
12+
model.load_weights(f"{config.model.model_dir}/newest_model.npz")
13+
model.eval()
14+
#construct representative dataset used for quantization(here using the first 100 validate images)
15+
scale_image_func=partial(Model.common.scale_image,hin=model.hin,win=model.win,scale_rate=0.95)
16+
def decode_image(image_file,image_id):
17+
image = tf.io.read_file(image_file)
18+
image = tf.image.decode_jpeg(image, channels=3) # get RGB with 0~1
19+
image = tf.image.convert_image_dtype(image, dtype=tf.float32)
20+
scaled_image,pad = tf.py_function(scale_image_func,[image],[tf.float32,tf.float32])
21+
return scaled_image
22+
dataset=Dataset.get_dataset(config)
23+
val_dataset=dataset.get_eval_dataset()
24+
rep_dataset=val_dataset.enumerate()
25+
rep_dataset=rep_dataset.filter(lambda i,image_data : i<=100)
26+
rep_dataset=rep_dataset.map(lambda i,image_data: image_data)
27+
rep_dataset=rep_dataset.map(decode_image).batch(1)
28+
print(f"test rep_dataset:{rep_dataset}")
29+
#covert to tf-lite using int8-only quantization
30+
input_signature=tf.TensorSpec(shape=(None,3,None,None))
31+
converter=tf.lite.TFLiteConverter.from_concrete_functions([model.infer.get_concrete_function(x=input_signature)])
32+
converter.optimizations=[tf.lite.Optimize.DEFAULT]
33+
converter.representative_dataset=rep_dataset
34+
converter.target_spec.supported_ops=[tf.lite.OpsSet.TFLITE_BUILTINS_INT8]
35+
converter.inference_input_type = tf.uint8
36+
converter.inference_output_type = tf.uint8
37+
tflite_model_quant = converter.convert()
38+
print("model quantized using uint8 quantization!")
39+
#save the converted quantization model
40+
save_path=f"./save_dir/{config.model.model_name}.tflite"
41+
tf.io.write_file(save_path,tflite_model_quant)
42+
#print(f"export tflite file finished! output file: {save_path}")
43+
44+
45+
46+

hyperpose/Model/backbones.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -508,15 +508,15 @@ def __init__(self,in_channels=64,n_filter=64,strides=(1,1),data_format="channels
508508
self.downsample=LayerList([
509509
Conv2d(n_filter=4*self.n_filter,in_channels=self.in_channels,filter_size=(1,1),strides=self.strides,b_init=None,\
510510
data_format=self.data_format,name=f"{name}_ds_conv1"),
511-
BatchNorm2d(decay=self.decay,epsilon=self.eps,is_train=True,num_features=4*self.n_filter,data_format=self.data_format,name=f"{name}_ds_bn1")
511+
BatchNorm2d(decay=self.decay,epsilon=self.eps,is_train=True,num_features=4*self.n_filter,act=None,data_format=self.data_format,name=f"{name}_ds_bn1")
512512
])
513513
self.main_block=LayerList([
514514
Conv2d(n_filter=self.n_filter,in_channels=self.in_channels,filter_size=(1,1),strides=(1,1),b_init=None,data_format=self.data_format,name=f"{name}_conv1"),
515-
BatchNorm2d(decay=self.decay,epsilon=self.eps,is_train=True,num_features=self.n_filter,act=None,data_format=self.data_format,name=f"{name}_bn1"),
515+
BatchNorm2d(decay=self.decay,epsilon=self.eps,is_train=True,num_features=self.n_filter,act=tf.nn.relu,data_format=self.data_format,name=f"{name}_bn1"),
516516
Conv2d(n_filter=self.n_filter,in_channels=self.n_filter,filter_size=(3,3),strides=self.strides,b_init=None,data_format=self.data_format,name=f"{name}_conv2"),
517-
BatchNorm2d(decay=self.decay,epsilon=self.eps,is_train=True,num_features=self.n_filter,act=None,data_format=self.data_format,name=f"{name}_bn2"),
517+
BatchNorm2d(decay=self.decay,epsilon=self.eps,is_train=True,num_features=self.n_filter,act=tf.nn.relu,data_format=self.data_format,name=f"{name}_bn2"),
518518
Conv2d(n_filter=4*self.n_filter,in_channels=self.n_filter,filter_size=(1,1),strides=(1,1),b_init=None,data_format=self.data_format,name=f"{name}_conv3"),
519-
BatchNorm2d(decay=self.decay,epsilon=self.eps,is_train=True,num_features=4*self.n_filter,act=tf.nn.relu,data_format=self.data_format,name=f"{name}_bn3")
519+
BatchNorm2d(decay=self.decay,epsilon=self.eps,is_train=True,num_features=4*self.n_filter,act=None,data_format=self.data_format,name=f"{name}_bn3")
520520
])
521521

522522
def forward(self,x):

hyperpose/Model/common.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,15 @@ def pad_image_shape(img,shape,pad_value=0.0):
275275
padded_image[pad[0]:img_h+pad[0],pad[2]:img_w+pad[2],:]=img
276276
return padded_image,pad
277277

278+
def scale_image(image,hin,win,scale_rate=0.95):
279+
#scale a image into the size of scale_rate*hin and scale_rate*win
280+
#used for model inferecne
281+
image_h,image_w,_=image.shape
282+
scale_h,scale_w=int(scale_rate*image_h),int(scale_rate*image_w)
283+
scale_image=cv2.resize(image,(scale_w,scale_h),interpolation=cv2.INTER_CUBIC)
284+
padded_image,pad=pad_image_shape(scale_image,shape=(hin,win),pad_value=0.0)
285+
return padded_image,pad
286+
278287
def get_optim(optim_type):
279288
if(optim_type==OPTIM.Adam):
280289
print("using optimizer Adam!")

hyperpose/Model/pifpaf/eval.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,20 @@ def visualize(img,img_id,processed_img,pd_pif_maps,pd_paf_maps,humans,stride=8,s
9595
plt.savefig(os.path.join(save_dir,f"{img_id}_visualize.png"))
9696
plt.close()
9797

98-
def _map_fn(image_file,image_id,hin,win):
98+
def normalize(image):
99+
#normalize
100+
mean=np.array([0.485, 0.456, 0.406])[np.newaxis,np.newaxis,:]
101+
std=np.array([0.229, 0.224, 0.225])[np.newaxis,np.newaxis,:]
102+
image=(image-mean)/std
103+
return image
104+
105+
def _map_fn(image_file,image_id):
99106
#load data
100107
image = tf.io.read_file(image_file)
101108
image = tf.image.decode_jpeg(image, channels=3) # get RGB with 0~1
102109
image = tf.image.convert_image_dtype(image, dtype=tf.float32)
110+
#normalize
111+
image=tf.py_function(normalize,[image],tf.float32)
103112
return image,image_id
104113

105114
def evaluate(model,dataset,config,vis_num=30,total_eval_num=10000,enable_multiscale_search=False):
@@ -131,7 +140,7 @@ def evaluate(model,dataset,config,vis_num=30,total_eval_num=10000,enable_multisc
131140
None
132141
'''
133142
print(f"enable multiscale_search:{enable_multiscale_search}")
134-
model.load_weights(os.path.join(config.model.model_dir,"newest_model.npz"))
143+
model.load_weights(os.path.join(config.model.model_dir,"newest_model.npz"),format="npz_dict")
135144
model.eval()
136145
pd_anns=[]
137146
vis_dir=config.eval.vis_dir
@@ -141,7 +150,7 @@ def evaluate(model,dataset,config,vis_num=30,total_eval_num=10000,enable_multisc
141150

142151
eval_dataset=dataset.get_eval_dataset()
143152
dataset_size=dataset.get_eval_datasize()
144-
paramed_map_fn=partial(_map_fn,hin=model.hin,win=model.win)
153+
paramed_map_fn=_map_fn
145154
eval_dataset=eval_dataset.map(paramed_map_fn,num_parallel_calls=max(multiprocessing.cpu_count()//2,1))
146155
for eval_num,(img,img_id) in enumerate(eval_dataset):
147156
img_id=img_id.numpy()
@@ -199,7 +208,7 @@ def test(model,dataset,config,vis_num=30,total_test_num=10000,enable_multiscale_
199208
None
200209
'''
201210
print(f"enable multiscale_search:{enable_multiscale_search}")
202-
model.load_weights(os.path.join(config.model.model_dir,"newest_model.npz"))
211+
model.load_weights(os.path.join(config.model.model_dir,"newest_model.npz"),format="npz_dict")
203212
model.eval()
204213
pd_anns=[]
205214
vis_dir=config.test.vis_dir
@@ -209,7 +218,7 @@ def test(model,dataset,config,vis_num=30,total_test_num=10000,enable_multiscale_
209218

210219
test_dataset=dataset.get_test_dataset()
211220
dataset_size=dataset.get_test_datasize()
212-
paramed_map_fn=partial(_map_fn,hin=model.hin,win=model.win)
221+
paramed_map_fn=_map_fn
213222
test_dataset=test_dataset.map(paramed_map_fn,num_parallel_calls=max(multiprocessing.cpu_count()//2,1))
214223
for test_num,(img,img_id) in enumerate(test_dataset):
215224
img_id=img_id.numpy()

hyperpose/Model/pifpaf/model.py

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from tensorlayer.models import Model
66
from tensorlayer.layers import BatchNorm2d, Conv2d, DepthwiseConv2d, LayerList, MaxPool2d
77
from .define import CocoColor
8+
from .utils import pixel_shuffle,get_meshgrid
89
from ..backbones import Resnet50_backbone
910

1011

@@ -40,30 +41,27 @@ def __init__(self,parts,limbs,colors=CocoColor,n_pos=17,n_limbs=19,hin=368,win=3
4041
self.backbone=backbone(data_format=data_format,scale_size=self.scale_size)
4142
self.hout=int(hin/self.stride)
4243
self.wout=int(win/self.stride)
43-
#generate mesh grid
44-
x_range=np.linspace(start=0,stop=self.wout-1,num=self.wout)
45-
y_range=np.linspace(start=0,stop=self.hout-1,num=self.hout)
46-
mesh_x,mesh_y=np.meshgrid(x_range,y_range)
47-
self.mesh_grid=np.stack([mesh_x,mesh_y])
4844
#construct head
4945
self.pif_head=self.PifHead(input_features=self.backbone.out_channels,n_pos=self.n_pos,n_limbs=self.n_limbs,\
50-
quad_size=self.quad_size,hout=self.hout,wout=self.wout,stride=self.stride,mesh_grid=self.mesh_grid,data_format=self.data_format)
46+
quad_size=self.quad_size,hout=self.hout,wout=self.wout,stride=self.stride,data_format=self.data_format)
5147
self.paf_head=self.PafHead(input_features=self.backbone.out_channels,n_pos=self.n_pos,n_limbs=self.n_limbs,\
52-
quad_size=self.quad_size,hout=self.hout,wout=self.wout,stride=self.stride,mesh_grid=self.mesh_grid,data_format=self.data_format)
48+
quad_size=self.quad_size,hout=self.hout,wout=self.wout,stride=self.stride,data_format=self.data_format)
5349

54-
@tf.function(experimental_relax_shapes=True)
55-
def forward(self,x,is_train=False):
56-
x=self.backbone.forward(x)
57-
pif_maps=self.pif_head.forward(x,is_train=is_train)
58-
paf_maps=self.paf_head.forward(x,is_train=is_train)
50+
# @tf.function(experimental_relax_shapes=True)
51+
def forward(self,x,is_train=False,ret_backbone=False):
52+
backbone_x=self.backbone.forward(x)
53+
pif_maps=self.pif_head.forward(backbone_x,is_train=is_train)
54+
paf_maps=self.paf_head.forward(backbone_x,is_train=is_train)
55+
if(ret_backbone):
56+
return pif_maps,paf_maps,backbone_x
5957
return pif_maps,paf_maps
6058

61-
@tf.function(experimental_relax_shapes=True)
59+
# @tf.function(experimental_relax_shapes=True)
6260
def infer(self,x):
63-
pif_maps,paf_maps=self.forward(x,is_train=False)
61+
pif_maps,paf_maps,backbone_x=self.forward(x,is_train=False,ret_backbone=True)
6462
pif_conf,pif_vec,_,pif_scale=pif_maps
6563
paf_conf,paf_src_vec,paf_dst_vec,_,_,paf_src_scale,paf_dst_scale=paf_maps
66-
return pif_conf,pif_vec,pif_scale,paf_conf,paf_src_vec,paf_dst_vec,paf_src_scale,paf_dst_scale
64+
return pif_conf,pif_vec,pif_scale,paf_conf,paf_src_vec,paf_dst_vec,paf_src_scale,paf_dst_scale,backbone_x
6765

6866
def soft_clamp(self,x,max_value=5.0):
6967
above_mask=tf.where(x>=max_value,1.0,0.0)
@@ -157,7 +155,7 @@ def cal_loss(self,pd_pif_maps,pd_paf_maps,gt_pif_maps,gt_paf_maps):
157155
return loss_pif_maps,loss_paf_maps,total_loss
158156

159157
class PifHead(Model):
160-
def __init__(self,input_features=2048,n_pos=19,n_limbs=19,quad_size=2,hout=8,wout=8,stride=8,mesh_grid=None,data_format="channels_first"):
158+
def __init__(self,input_features=2048,n_pos=19,n_limbs=19,quad_size=2,hout=8,wout=8,stride=8,data_format="channels_first"):
161159
super().__init__()
162160
self.input_features=input_features
163161
self.n_pos=n_pos
@@ -167,29 +165,32 @@ def __init__(self,input_features=2048,n_pos=19,n_limbs=19,quad_size=2,hout=8,wou
167165
self.stride=stride
168166
self.quad_size=quad_size
169167
self.out_features=self.n_pos*5*(self.quad_size**2)
170-
self.mesh_grid=mesh_grid
171168
self.data_format=data_format
172169
self.tf_data_format="NCHW" if self.data_format=="channels_first" else "NHWC"
173170
self.main_block=Conv2d(n_filter=self.out_features,in_channels=self.input_features,filter_size=(1,1),data_format=self.data_format)
174171

175172
def forward(self,x,is_train=False):
176173
x=self.main_block.forward(x)
177-
x=tf.nn.depth_to_space(x,block_size=self.quad_size,data_format=self.tf_data_format)
178-
x=tf.reshape(x,[-1,self.n_pos,5,self.hout,self.wout])
174+
x=pixel_shuffle(x,scale=2)
175+
low_cut=int((self.quad_size-1)//2)
176+
high_cut=int(tf.math.ceil((self.quad_size-1)/2.0))
177+
hout,wout=x.shape[2],x.shape[3]
178+
x=tf.reshape(x,[-1,self.n_pos,5,hout,wout])
179179
pif_conf=x[:,:,0,:,:]
180180
pif_vec=x[:,:,1:3,:,:]
181181
pif_logb=x[:,:,3,:,:]
182-
pif_scale=tf.exp(x[:,:,4,:,:])
182+
pif_scale=x[:,:,4,:,:]
183183
#restore vec_maps in inference
184184
if(is_train==False):
185+
mesh_grid=get_meshgrid(mesh_h=hout,mesh_w=wout)+np.array([1.5,1.5])[:,np.newaxis,np.newaxis]
185186
infer_pif_conf=tf.nn.sigmoid(pif_conf)
186-
infer_pif_vec=(pif_vec[:,:]+self.mesh_grid)*self.stride
187+
infer_pif_vec=(pif_vec[:,:]+mesh_grid)*self.stride
187188
infer_pif_scale=tf.math.softplus(pif_scale)*self.stride
188189
return infer_pif_conf,infer_pif_vec,pif_logb,infer_pif_scale
189190
return pif_conf,pif_vec,pif_logb,pif_scale
190191

191192
class PafHead(Model):
192-
def __init__(self,input_features=2048,n_pos=19,n_limbs=19,quad_size=2,hout=46,wout=46,stride=8,mesh_grid=None,data_format="channels_first"):
193+
def __init__(self,input_features=2048,n_pos=19,n_limbs=19,quad_size=2,hout=46,wout=46,stride=8,data_format="channels_first"):
193194
super().__init__()
194195
self.input_features=input_features
195196
self.n_pos=n_pos
@@ -199,27 +200,30 @@ def __init__(self,input_features=2048,n_pos=19,n_limbs=19,quad_size=2,hout=46,wo
199200
self.wout=wout
200201
self.stride=stride
201202
self.out_features=self.n_limbs*9*(self.quad_size**2)
202-
self.mesh_grid=mesh_grid
203203
self.data_format=data_format
204204
self.tf_data_format="NCHW" if self.data_format=="channels_first" else "NHWC"
205205
self.main_block=Conv2d(n_filter=self.out_features,in_channels=self.input_features,filter_size=(1,1),data_format=self.data_format)
206206

207207
def forward(self,x,is_train=False):
208208
x=self.main_block.forward(x)
209-
x=tf.nn.depth_to_space(x,block_size=self.quad_size,data_format=self.tf_data_format)
210-
x=tf.reshape(x,[-1,self.n_limbs,9,self.hout,self.wout])
209+
x=pixel_shuffle(x,scale=2)
210+
low_cut=int((self.quad_size-1)//2)
211+
high_cut=int(tf.math.ceil((self.quad_size-1)/2.0))
212+
hout,wout=x.shape[2],x.shape[3]
213+
x=tf.reshape(x,[-1,self.n_limbs,9,hout,wout])
211214
paf_conf=x[:,:,0,:,:]
212215
paf_src_vec=x[:,:,1:3,:,:]
213216
paf_dst_vec=x[:,:,3:5,:,:]
214217
paf_src_logb=x[:,:,5,:,:]
215218
paf_dst_logb=x[:,:,6,:,:]
216-
paf_src_scale=tf.exp(x[:,:,7,:,:])
217-
paf_dst_scale=tf.exp(x[:,:,8,:,:])
219+
paf_src_scale=x[:,:,7,:,:]
220+
paf_dst_scale=x[:,:,8,:,:]
218221
#restore vec_maps in inference
219222
if(is_train==False):
223+
mesh_grid=get_meshgrid(mesh_h=hout,mesh_w=wout)+np.array([1.5,1.5])[:,np.newaxis,np.newaxis]
220224
infer_paf_conf=tf.nn.sigmoid(paf_conf)
221-
infer_paf_src_vec=(paf_src_vec[:,:]+self.mesh_grid)*self.stride
222-
infer_paf_dst_vec=(paf_dst_vec[:,:]+self.mesh_grid)*self.stride
225+
infer_paf_src_vec=(paf_src_vec[:,:]+mesh_grid)*self.stride
226+
infer_paf_dst_vec=(paf_dst_vec[:,:]+mesh_grid)*self.stride
223227
infer_paf_src_scale=tf.math.softplus(paf_src_scale)*self.stride
224228
infer_paf_dst_scale=tf.math.softplus(paf_dst_scale)*self.stride
225229
return infer_paf_conf,infer_paf_src_vec,infer_paf_dst_vec,paf_src_logb,paf_dst_logb,infer_paf_src_scale,infer_paf_dst_scale

hyperpose/Model/pifpaf/processor.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
from operator import pos
23
import os
34
import cv2
45
import json
@@ -31,8 +32,8 @@ def process(self,annos,mask_valid):
3132
return pif_maps,paf_maps
3233

3334
class PostProcessor:
34-
def __init__(self,parts,limbs,hin,win,hout,wout,colors=None,thresh_pif=0.1,thresh_paf=0.1,thresh_ref_pif=0.1,thresh_ref_paf=0.1,\
35-
part_num_thresh=4,score_thresh=0.1,reduction=2,min_scale=4,greedy_match=True,reverse_match=True,data_format="channels_first",debug=False):
35+
def __init__(self,parts,limbs,hin,win,hout,wout,colors=None,thresh_pif=0.3,thresh_paf=0.1,thresh_ref_pif=0.3,thresh_ref_paf=0.1,\
36+
thresh_gen_ref_pif=0.1,part_num_thresh=4,score_thresh=0.1,reduction=2,min_scale=4,greedy_match=True,reverse_match=True,data_format="channels_first",debug=False):
3637
self.parts=parts
3738
self.limbs=limbs
3839
self.colors=colors if (colors!=None) else (len(self.parts)*[[0,255,0]])
@@ -47,6 +48,7 @@ def __init__(self,parts,limbs,hin,win,hout,wout,colors=None,thresh_pif=0.1,thres
4748
self.thresh_paf=thresh_paf
4849
self.thresh_ref_pif=thresh_ref_pif
4950
self.thresh_ref_paf=thresh_ref_paf
51+
self.thresh_gen_ref_pif=thresh_gen_ref_pif
5052
self.part_num_thresh=part_num_thresh
5153
self.score_thresh=score_thresh
5254
self.reduction=reduction
@@ -71,7 +73,7 @@ def process(self,pif_maps,paf_maps):
7173
pif_conf,pif_vec,_,pif_scale=pif_maps
7274
paf_conf,paf_src_vec,paf_dst_vec,_,_,paf_src_scale,paf_dst_scale=paf_maps
7375
#get pif_hr_conf
74-
pif_hr_conf=get_hr_conf(pif_conf,pif_vec,pif_scale,stride=self.stride,thresh=self.thresh_pif,debug=False)
76+
pif_hr_conf=get_hr_conf(pif_conf,pif_vec,pif_scale,stride=self.stride,thresh=self.thresh_gen_ref_pif,debug=False)
7577
self.debug_print(f"test hr_conf")
7678
for pos_idx in range(0,self.n_pos):
7779
self.debug_print(f"test hr_conf idx:{pos_idx} max_conf:{np.max(pif_conf[pos_idx])} max_hr_conf:{np.max(pif_hr_conf[pos_idx])}")
@@ -88,7 +90,7 @@ def process(self,pif_maps,paf_maps):
8890
mask_ref_conf=ref_cs>self.thresh_ref_pif
8991
for ref_c,x,y,scale in zip(ref_cs[mask_ref_conf],xs[mask_ref_conf],ys[mask_ref_conf],scales[mask_ref_conf]):
9092
seeds.append((ref_c,pos_idx,x,y,scale))
91-
self.debug_print(f"seed gen pos_idx:{pos_idx} ref_c:{ref_c} x:{x} y:{y} scale:{scale}")
93+
#print(f"seed gen pos_idx:{pos_idx} ref_c:{ref_c} x:{x} y:{y} scale:{scale}")
9294
self.debug_print(f"test before sort len_seeds:{len(seeds)}")
9395
seeds=sorted(seeds,reverse=True)
9496
self.debug_print(f"test after sort len_seeds:{len(seeds)}")
@@ -124,6 +126,7 @@ def process(self,pif_maps,paf_maps):
124126
self.debug_print(f"test fw_list_gen: limb_idx:{limb_idx} max_score:{np.max(score)} max_cifhr_f:{np.max(cifhr_f)} max_score_f:{np.max(score_f)} mask_num_f:{np.sum(mask_f)}")
125127
self.debug_print("")
126128
#greedy assemble
129+
#TODO: further check!
127130
occupied=np.zeros(shape=(self.n_pos,int(pif_hr_conf.shape[1]/self.reduction),int(pif_hr_conf.shape[2]/self.reduction)))
128131
annotations=[]
129132
self.debug_print(f"test seeds_num:{len(seeds)}")
@@ -302,7 +305,7 @@ def get_connection(self,ann,src_idx,dst_idx,forward_list,backward_list,connectio
302305
def grow(self,ann,forward_list,backward_list,reverse_match=True):
303306
frontier = []
304307
in_frontier = set()
305-
#add the point to assemble frontierby_source
308+
#add the point to assemble frontier by_source
306309
def add_frontier(ann,src_idx):
307310
#traverse all the part that the current part connect to
308311
for dst_idx,(_,_) in self.by_source[src_idx].items():

0 commit comments

Comments
 (0)