update for bakeup

This commit is contained in:
王庆刚
2024-08-06 20:00:29 +08:00
parent 27d57b21d4
commit 5109400a57
19 changed files with 497 additions and 352 deletions

View File

@ -30,6 +30,8 @@ def find_samebox_in_array(arr, target):
return i
return -1
import warnings
def extract_data(datapath):
bboxes, ffeats = [], []
@ -47,6 +49,17 @@ def extract_data(datapath):
if line.find("CameraId")>=0:
if len(boxes): bboxes.append(np.array(boxes))
if len(feats): ffeats.append(np.array(feats))
# with warnings.catch_warnings(record=True) as w:
# if len(boxes): bboxes.append(np.array(boxes))
# if len(feats): ffeats.append(np.array(feats))
# if w:
# print(f"捕获到 {len(w)} 个警告:")
# for warning in w:
# print(f"警告类型: {warning.category}")
# print(f"警告消息: {warning.message}")
# print(f"警告发生的地方: {warning.filename}:{warning.lineno}")
if len(tboxes):
trackerboxes = np.concatenate((trackerboxes, np.array(tboxes)))
if len(tfeats):
@ -56,16 +69,20 @@ def extract_data(datapath):
if line.find("box:") >= 0 and line.find("output_box:") < 0:
box = line[line.find("box:") + 4:].strip()
# if len(box)==6:
boxes.append(str_to_float_arr(box))
if line.find("feat:") >= 0:
feat = line[line.find("feat:") + 5:].strip()
# if len(feat)==256:
feats.append(str_to_float_arr(feat))
if line.find("output_box:") >= 0:
box = str_to_float_arr(line[line.find("output_box:") + 11:].strip())
tboxes.append(box) # 去掉'output_box:'并去除可能的空白字符
index = find_samebox_in_array(boxes, box)
assert(len(boxes)==len(feats)), f"{datapath}, {datapath}, len(boxes)!=len(feats)"
if index >= 0:
# feat_f = str_to_float_arr(input_feats[index])
feat_f = feats[index]
@ -120,7 +137,7 @@ def extract_data(datapath):
tracking_feat_dict[f"track_{tid}"]= {"feats": {}}
tracking_feat_dict[f"track_{tid}"]["feats"].update({f"{fid}_{bid}": tracker_feat_dict[f"frame_{fid}"]["feats"][bid]})
except Exception as e:
print(f'Path: {datapath}, Error: {e}')
print(f'Path: {datapath}, tracking_feat_dict can not be structured correcttly, Error: {e}')
return bboxes, ffeats, trackerboxes, tracker_feat_dict, trackingboxes, tracking_feat_dict
@ -142,6 +159,8 @@ def read_tracking_output(filepath):
boxes.append(data)
if data.size == 256:
feats.append(data)
assert(len(feats)==len(boxes)), f"{filepath}, len(feats)!=len(boxes)"
return np.array(boxes), np.array(feats)
@ -166,16 +185,9 @@ def read_deletedBarcode_file(filePth):
dict, barcode_list, similarity_list = {}, [], []
continue
# print(line)
try:
label = line.split(':')[0]
value = line.split(':')[1]
except Exception as e:
print(f'Error: {e}')
if line.find(':')<0: continue
label = line.split(':')[0]
value = line.split(':')[1]
if label == 'SeqDir':
dict['SeqDir'] = value