modify the event pickle file

This commit is contained in:
18262620154
2024-07-28 19:21:27 +08:00
parent f14faa323e
commit 0ccfd0151f
152 changed files with 57 additions and 27 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -76,7 +76,7 @@ def attempt_load(weights, device=None, inplace=True, fuse=True):
model = Ensemble()
for w in weights if isinstance(weights, list) else [weights]:
ckpt = torch.load(attempt_download(w), map_location=device) # load
ckpt = torch.load(attempt_download(w), map_location=device, weights_only=False) # load
ckpt = (ckpt.get('ema') or ckpt['model']).to(device).float() # FP32 model
# Model compatibility updates

View File

@ -114,6 +114,7 @@ def pipeline(
"backCamera": {},
"one2n": [] #
}
yrtDict = {}
procpath = Path(eventpath).joinpath('process.data')
@ -159,10 +160,22 @@ def pipeline(
'''================= 3. Yolo + Resnet + Tracker ================='''
optdict["source"] = vpath
optdict["save_dir"] = savepath_pipeline_imgs
optdict["is_save_img"] = False
optdict["is_save_video"] = True
yrtOut = yolo_resnet_tracker(**optdict)
CameraEvent["yoloResnetTracker"] = yrtOut
yrtOut_save = []
for frdict in yrtOut:
fr_dict = {}
for k, v in frdict.items():
if k != "imgs":
fr_dict[k]=v
yrtOut_save.append(fr_dict)
CameraEvent["yoloResnetTracker"] = yrtOut_save
# CameraEvent["yoloResnetTracker"] = yrtOut
'''================= 4. tracking ================='''
'''(1) 生成用于 tracking 模块的 boxes、feats'''
@ -190,6 +203,8 @@ def pipeline(
CameraEvent["tracking"] = vts
ShoppingDict["backCamera"] = CameraEvent
yrtDict["backyrt"] = yrtOut
'''(2) tracking, 前摄'''
if CameraEvent["cameraType"] == "front":
vts = doFrontTracks(trackerboxes, trackefeats)
@ -199,6 +214,8 @@ def pipeline(
CameraEvent["tracking"] = vts
ShoppingDict["frontCamera"] = CameraEvent
yrtDict["frontyrt"] = yrtOut
'''========================== 保存模块 ================================='''
'''(1) 保存 ShoppingDict 事件'''
with open(str(pf_path), 'wb') as f:
@ -208,10 +225,14 @@ def pipeline(
for CamerType, vts in event_tracks:
if len(vts.tracks)==0: continue
if CamerType == 'front':
yolos = ShoppingDict["frontCamera"]["yoloResnetTracker"]
# yolos = ShoppingDict["frontCamera"]["yoloResnetTracker"]
yolos = yrtDict["frontyrt"]
ctype = 1
if CamerType == 'back':
yolos = ShoppingDict["backCamera"]["yoloResnetTracker"]
# yolos = ShoppingDict["backCamera"]["yoloResnetTracker"]
yolos = yrtDict["backyrt"]
ctype = 0
imgdict, featdict, simidict = {}, {}, {}
@ -269,10 +290,10 @@ def main():
函数pipeline(),遍历事件文件夹,选择类型 image 或 video,
'''
parmDict = {}
evtdir = r"D:\works\后台回传数据"
evtdir = r"../dataset/backend_20250310"
parmDict["SourceType"] = "video" # video, image
parmDict["savepath"] = r"D:\works\results"
parmDict["weights"] = r'D:\DetectTracking\ckpts\best_cls10_0906.pt'
parmDict["savepath"] = r"../dataset/run"
parmDict["weights"] = r'./ckpts/best_cls10_0906.pt'
evtdir = Path(evtdir)
k, errEvents = 0, []
@ -280,14 +301,14 @@ def main():
if item.is_dir():
# item = evtdir/Path("20250303-103058-074_6914973604223_6914973604223")
parmDict["eventpath"] = item
# pipeline(**parmDict)
try:
pipeline(**parmDict)
except Exception as e:
errEvents.append(str(item))
# k+=1
# if k==1:
# break
pipeline(**parmDict)
# try:
# pipeline(**parmDict)
# except Exception as e:
# errEvents.append(str(item))
k+=1
if k==1:
break
errfile = os.path.join(parmDict["savepath"], f'error_events.txt')
with open(errfile, 'w', encoding='utf-8') as f:

View File

@ -311,6 +311,9 @@ def yolo_resnet_tracker(
h = int(vid_cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
else: # stream
fps, w, h = 25, im0.shape[1], im0.shape[0]
## for image rotating in dataloader.LoadImages.__next__()
w, h = im0.shape[1], im0.shape[0]
vdieo_path = str(Path(vdieo_path).with_suffix('.mp4')) # force *.mp4 suffix on results videos
vid_writer[i] = cv2.VideoWriter(vdieo_path, cv2.VideoWriter_fourcc(*'mp4v'), fps, (w, h))
vid_writer[i].write(im0)
@ -594,6 +597,9 @@ def run(
h = int(vid_cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
else: # stream
fps, w, h = 30, im0.shape[1], im0.shape[0]
## for image rotating in dataloader.LoadImages.__next__()
w, h = im0.shape[1], im0.shape[0]
save_path = str(Path(save_path).with_suffix('.mp4')) # force *.mp4 suffix on results videos
vid_writer[i] = cv2.VideoWriter(save_path, cv2.VideoWriter_fourcc(*'mp4v'), fps, (w, h))
vid_writer[i].write(im0)

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -132,11 +132,11 @@ class backTrack(Track):
num_outcart = cv2.countNonZero(isoutcart)
num_cartboarder = cv2.countNonZero(iscartboarder)
incart_iou = num_incart/num_temp
outcart_iou = num_outcart/num_temp
cartboarder_iou = num_cartboarder/num_temp
maxbox_iou = maxarea/num_temp
minbox_iou = minarea/num_temp
incart_iou = num_incart/(num_temp+1e-6)
outcart_iou = num_outcart/(num_temp+1e-6)
cartboarder_iou = num_cartboarder/(num_temp+1e-6)
maxbox_iou = maxarea/(num_temp+1e-6)
minbox_iou = minarea/(num_temp+1e-6)
self.feature_ious = (incart_iou, outcart_iou, cartboarder_iou, maxbox_iou, minbox_iou)
self.incartrates = incartrates

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More