def empty_img_anno(): dbm = DBMan(config.LOSTConfig()) img_anno = model.ImageAnno(img_path='path/to/img1.jpg') fs = add_local_fs(dbm, 'local_fs_for_empty_img_anno') img_anno.fs_id = fs.idx dbm.add(img_anno) dbm.commit() yield img_anno dbm.delete(img_anno) dbm.commit() delete_local_fs(dbm, fs)
def empty_img_anno(): dbm = DBMan(config.LOSTConfig()) test_user = testils.get_user(dbm) tree = testils.get_voc_label_tree(dbm) label_leaf_id = tree.get_child_vec(tree.root.idx)[0] img_anno = model.ImageAnno(img_path='path/to/img1.jpg') dbm.add(img_anno) dbm.commit() yield img_anno dbm.delete(img_anno) dbm.commit()
def local_fs(): dbm = DBMan(config.LOSTConfig()) test_user = testils.get_user(dbm) fs = model.FileSystem(group_id=test_user.groups[0].idx, connection=json.dumps(dict()), root_path='', fs_type='file', timestamp=datetime.datetime.now(), name='test_request_annos_fs') dbm.add(fs) dbm.commit() yield fs
def send_life_sign(): logger = get_task_logger(__name__) lostconfig = LOSTConfig() dbm = DBMan(lostconfig) worker = dbm.get_worker(lostconfig.worker_name) if worker is None: register_worker(dbm, lostconfig) logger.info('Registered worker: {}'.format(lostconfig.worker_name)) else: worker.timestamp = datetime.utcnow() dbm.add(worker) dbm.commit() logger.info('Sent lifesign: {}'.format(worker.worker_name)) dbm.close_session()
def simple_bbox_anno(): dbm = DBMan(config.LOSTConfig()) twod_anno = model.TwoDAnno(data=json.dumps({ 'x': REF_BBOX[0], 'y': REF_BBOX[1], 'w': REF_BBOX[2], 'h': REF_BBOX[3] }), dtype=dtype.TwoDAnno.BBOX) dbm.add(twod_anno) dbm.commit() yield twod_anno dbm.delete(twod_anno) dbm.commit()
def init_worker_on_startup(): lostconfig = LOSTConfig() dbm = DBMan(lostconfig) worker = dbm.get_worker(lostconfig.worker_name) if worker is None: register_worker(dbm, lostconfig) print('Registered worker: {}'.format(lostconfig.worker_name)) else: worker.timestamp = datetime.utcnow() worker.resources = '[]' worker.in_progress = '{}' dbm.add(worker) dbm.commit() print('Reset worker on startup: {}'.format(worker.worker_name)) dbm.close_session()
def full_bbox_anno(): dbm = DBMan(config.LOSTConfig()) test_user = testils.get_user(dbm) tree = testils.get_voc_label_tree(dbm) label_leaf_id = tree.get_child_vec(tree.root.idx)[0] twod_anno = model.TwoDAnno(data=json.dumps({ 'x': REF_BBOX[0], 'y': REF_BBOX[1], 'w': REF_BBOX[2], 'h': REF_BBOX[3] }), dtype=dtype.TwoDAnno.BBOX) lbl = model.Label(label_leaf_id=label_leaf_id) twod_anno.labels.append(lbl) twod_anno.annotator = test_user dbm.add(twod_anno) dbm.commit() yield twod_anno dbm.delete(twod_anno) dbm.commit()
def full_img_anno(): dbm = DBMan(config.LOSTConfig()) test_user = testils.get_user(dbm) tree = testils.get_voc_label_tree(dbm) label_vec = tree.get_child_vec(tree.root.idx) twod_anno = model.TwoDAnno(data=json.dumps({ 'x': REF_BBOX[0], 'y': REF_BBOX[1], 'w': REF_BBOX[2], 'h': REF_BBOX[3] }), dtype=dtype.TwoDAnno.BBOX) lbl = model.Label(label_leaf_id=label_vec[0]) dbm.add(lbl) twod_anno.labels.append(lbl) twod_anno.annotator = test_user twod_anno2 = model.TwoDAnno(data=json.dumps({ 'x': REF_POINT[0], 'y': REF_POINT[1] }), dtype=dtype.TwoDAnno.POINT) lbl = model.Label(label_leaf_id=label_vec[1]) dbm.add(lbl) twod_anno2.labels.append(lbl) twod_anno2.annotator = test_user line = model.TwoDAnno() lbl = model.Label(label_leaf_id=label_vec[4]) line.labels.append(lbl) dbm.add(lbl) line.annotator = test_user line.line = REF_LINE img_anno = model.ImageAnno(img_path='path/to/img1.jpg') fs = add_local_fs(dbm, 'local_fs_for_full_img_anno') img_anno.fs_id = fs.idx lbl = model.Label(label_leaf_id=label_vec[3]) dbm.add(lbl) img_anno.labels.append(lbl) dbm.commit() img_anno.twod_annos.append(twod_anno) img_anno.twod_annos.append(twod_anno2) img_anno.twod_annos.append(line) # dbm.add(img_anno.labels) dbm.add(img_anno) # dbm.add(twod_anno) dbm.commit() yield img_anno # dbm.delete(twod_anno.labels) dbm.delete(twod_anno) # dbm.delete(twod_anno2.labels) dbm.delete(twod_anno2) # dbm.delete(img_anno.labels) dbm.delete(img_anno) dbm.commit() delete_local_fs(dbm, fs)