Ejemplo n.º 1
0
class TestCVATAPI(TestCase):
    def setUp(self) -> None:
        self.api = CVATAPI(os.environ["CVAT_HOST"])

    def test_login(self):
        result = self.api.login(os.environ["CVAT_USER"],
                                os.environ["CVAT_PASSWORD"]).json()
        print(f"Log in result: {result}")

    def test_create_task(self):
        self.test_login()
        result = self.api.create_task("test", 5000, [
            Label("glass beads",
                  [Attribute("cropped", "checkbox", ["yes", "no"], "no")])
        ])

        print(f"create task result: {result.json()}")

    def test_get_shared_files(self):
        self.test_login()
        result = self.api.get_server_files()
        print(result.json())

    def test_export(self):
        self.test_login()
        result = self.api.export_data(11)
        print(result.json)
Ejemplo n.º 2
0
if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    cvat_args(parser)
    parser.add_argument("--config")
    parser.add_argument("--job_id", type=int, action="append")
    parser.add_argument("--val_job_id", type=int, action="append")
    parser.add_argument("--output")
    parser.add_argument("--resume", action="store_true")
    parser.add_argument("--restart", action="store_true")
    parser.add_argument("--force_test", action="store_true")
    parser.add_argument("--epoch")
    args = parser.parse_args()

    api = CVATAPI(args.cvat_host)
    api.login(args.cvat_username, args.cvat_password)

    train_tasks = []

    # training tasks
    for job_id in args.job_id:
        data, task_id = get_data_set(job_id)

        coco_json = f"datasets/train_cvat_{task_id}.coco.json"
        with open(coco_json, "w") as f:
            json.dump(data, f)
        train_task = f"cvat/train_{task_id}"
        register_coco_instances(train_task, {}, coco_json, args.cvat_base)
        train_tasks.append(train_task)
    override_cfg = ["DATASETS.TRAIN", tuple(train_tasks)]