cv2.addWeighted(seg_image, config.ALPHA, frame, 1 - config.ALPHA, 0, frame) vis_text(frame, "fps: {}".format(fps.fps_local()), (10, 30)) # boxes (ymin, xmin, ymax, xmax) if config.BBOX: map_labeled = measure.label(seg_map, connectivity=1) for region in measure.regionprops(map_labeled): if region.area > config.MINAREA: box = region.bbox p1 = (box[1], box[0]) p2 = (box[3], box[2]) cv2.rectangle(frame, p1, p2, (77, 255, 9), 2) vis_text( frame, config.LABEL_NAMES[seg_map[tuple( region.coords[0])]], (p1[0], p1[1] - 10)) cv2.imshow(config.DL_MODEL_NAME, frame) if cv2.waitKey(1) & 0xFF == ord('q'): break fps.update() fps.stop() vs.stop() if __name__ == '__main__': config = Config() model = Model('dl', config.DL_MODEL_NAME, config.DL_MODEL_PATH).prepare_dl_model() segmentation(model, config)
models = np.squeeze(models) models.sort() print("> start testing following sequention of models: \n{}".format(models)) for mod in models: print("> testing model: {}".format(mod)) # conditionals optimized=False single_class=False # Test Model if 'hands' in mod or 'person' in mod: single_class=True if 'deeplab' in mod: config = create_test_config(mod,'DL',optimized,single_class) print("TEST") model = Model('dl', config.DL_MODEL_NAME, config.DL_MODEL_PATH).prepare_dl_model() segmentation(model,config) else: config = create_test_config(mod,'OD',optimized,single_class) model = Model('od', config.OD_MODEL_NAME, config.OD_MODEL_PATH, config.LABEL_PATH, config.NUM_CLASSES, config.SPLIT_MODEL, config.SSD_SHAPE).prepare_od_model() detection(model,config) # Check if there is an optimized graph model_dir = os.path.join(os.getcwd(),'models',mod) for root, dirs, files in os.walk(model_dir): for file in files: if 'optimized' in file: optimized=True print '> found: optimized graph'
def main(): config = Config() model = Model('od', config.OD_MODEL_NAME, config.OD_MODEL_PATH, config.LABEL_PATH, config.NUM_CLASSES, config.SPLIT_MODEL, config.SSD_SHAPE).prepare_od_model() detection(model, config)