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() model = Ensemble()
for w in weights if isinstance(weights, list) else [weights]: 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 ckpt = (ckpt.get('ema') or ckpt['model']).to(device).float() # FP32 model
# Model compatibility updates # Model compatibility updates

View File

@ -114,6 +114,7 @@ def pipeline(
"backCamera": {}, "backCamera": {},
"one2n": [] # "one2n": [] #
} }
yrtDict = {}
procpath = Path(eventpath).joinpath('process.data') procpath = Path(eventpath).joinpath('process.data')
@ -158,11 +159,23 @@ def pipeline(
'''================= 3. Yolo + Resnet + Tracker =================''' '''================= 3. Yolo + Resnet + Tracker ================='''
optdict["source"] = vpath optdict["source"] = vpath
optdict["save_dir"] = savepath_pipeline_imgs optdict["save_dir"] = savepath_pipeline_imgs
optdict["is_save_img"] = False
optdict["is_save_video"] = True
yrtOut = yolo_resnet_tracker(**optdict) 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 =================''' '''================= 4. tracking ================='''
'''(1) 生成用于 tracking 模块的 boxes、feats''' '''(1) 生成用于 tracking 模块的 boxes、feats'''
@ -189,6 +202,8 @@ def pipeline(
CameraEvent["tracking"] = vts CameraEvent["tracking"] = vts
ShoppingDict["backCamera"] = CameraEvent ShoppingDict["backCamera"] = CameraEvent
yrtDict["backyrt"] = yrtOut
'''(2) tracking, 前摄''' '''(2) tracking, 前摄'''
if CameraEvent["cameraType"] == "front": if CameraEvent["cameraType"] == "front":
@ -198,6 +213,8 @@ def pipeline(
CameraEvent["tracking"] = vts CameraEvent["tracking"] = vts
ShoppingDict["frontCamera"] = CameraEvent ShoppingDict["frontCamera"] = CameraEvent
yrtDict["frontyrt"] = yrtOut
'''========================== 保存模块 =================================''' '''========================== 保存模块 ================================='''
'''(1) 保存 ShoppingDict 事件''' '''(1) 保存 ShoppingDict 事件'''
@ -208,10 +225,14 @@ def pipeline(
for CamerType, vts in event_tracks: for CamerType, vts in event_tracks:
if len(vts.tracks)==0: continue if len(vts.tracks)==0: continue
if CamerType == 'front': if CamerType == 'front':
yolos = ShoppingDict["frontCamera"]["yoloResnetTracker"] # yolos = ShoppingDict["frontCamera"]["yoloResnetTracker"]
yolos = yrtDict["frontyrt"]
ctype = 1 ctype = 1
if CamerType == 'back': if CamerType == 'back':
yolos = ShoppingDict["backCamera"]["yoloResnetTracker"] # yolos = ShoppingDict["backCamera"]["yoloResnetTracker"]
yolos = yrtDict["backyrt"]
ctype = 0 ctype = 0
imgdict, featdict, simidict = {}, {}, {} imgdict, featdict, simidict = {}, {}, {}
@ -269,10 +290,10 @@ def main():
函数pipeline(),遍历事件文件夹,选择类型 image 或 video, 函数pipeline(),遍历事件文件夹,选择类型 image 或 video,
''' '''
parmDict = {} parmDict = {}
evtdir = r"D:\works\后台回传数据" evtdir = r"../dataset/backend_20250310"
parmDict["SourceType"] = "video" # video, image parmDict["SourceType"] = "video" # video, image
parmDict["savepath"] = r"D:\works\results" parmDict["savepath"] = r"../dataset/run"
parmDict["weights"] = r'D:\DetectTracking\ckpts\best_cls10_0906.pt' parmDict["weights"] = r'./ckpts/best_cls10_0906.pt'
evtdir = Path(evtdir) evtdir = Path(evtdir)
k, errEvents = 0, [] k, errEvents = 0, []
@ -280,14 +301,14 @@ def main():
if item.is_dir(): if item.is_dir():
# item = evtdir/Path("20250303-103058-074_6914973604223_6914973604223") # item = evtdir/Path("20250303-103058-074_6914973604223_6914973604223")
parmDict["eventpath"] = item parmDict["eventpath"] = item
# pipeline(**parmDict) pipeline(**parmDict)
try: # try:
pipeline(**parmDict) # pipeline(**parmDict)
except Exception as e: # except Exception as e:
errEvents.append(str(item)) # errEvents.append(str(item))
# k+=1 k+=1
# if k==1: if k==1:
# break break
errfile = os.path.join(parmDict["savepath"], f'error_events.txt') errfile = os.path.join(parmDict["savepath"], f'error_events.txt')
with open(errfile, 'w', encoding='utf-8') as f: 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)) h = int(vid_cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
else: # stream else: # stream
fps, w, h = 25, im0.shape[1], im0.shape[0] 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 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] = cv2.VideoWriter(vdieo_path, cv2.VideoWriter_fourcc(*'mp4v'), fps, (w, h))
vid_writer[i].write(im0) vid_writer[i].write(im0)
@ -594,6 +597,9 @@ def run(
h = int(vid_cap.get(cv2.CAP_PROP_FRAME_HEIGHT)) h = int(vid_cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
else: # stream else: # stream
fps, w, h = 30, im0.shape[1], im0.shape[0] 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 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] = cv2.VideoWriter(save_path, cv2.VideoWriter_fourcc(*'mp4v'), fps, (w, h))
vid_writer[i].write(im0) 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_outcart = cv2.countNonZero(isoutcart)
num_cartboarder = cv2.countNonZero(iscartboarder) num_cartboarder = cv2.countNonZero(iscartboarder)
incart_iou = num_incart/num_temp incart_iou = num_incart/(num_temp+1e-6)
outcart_iou = num_outcart/num_temp outcart_iou = num_outcart/(num_temp+1e-6)
cartboarder_iou = num_cartboarder/num_temp cartboarder_iou = num_cartboarder/(num_temp+1e-6)
maxbox_iou = maxarea/num_temp maxbox_iou = maxarea/(num_temp+1e-6)
minbox_iou = minarea/num_temp minbox_iou = minarea/(num_temp+1e-6)
self.feature_ious = (incart_iou, outcart_iou, cartboarder_iou, maxbox_iou, minbox_iou) self.feature_ious = (incart_iou, outcart_iou, cartboarder_iou, maxbox_iou, minbox_iou)
self.incartrates = incartrates 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