From 720c149e286038e961f49d83c56b24fc6dc30bba Mon Sep 17 00:00:00 2001 From: Simon Edwardsson Date: Thu, 30 Jul 2020 16:22:54 +0100 Subject: [PATCH] support for uploading as-video --- darwin/cli.py | 4 ++-- darwin/cli_functions.py | 9 +++++++-- darwin/dataset/remote_dataset.py | 4 ++++ darwin/dataset/upload_manager.py | 5 ++++- darwin/options.py | 4 ++++ setup.py | 2 +- 6 files changed, 22 insertions(+), 6 deletions(-) diff --git a/darwin/cli.py b/darwin/cli.py index cb1374f84..353f4cd36 100644 --- a/darwin/cli.py +++ b/darwin/cli.py @@ -43,7 +43,7 @@ def run(args, parser): f.list_teams() # Version elif args.command == "version": - print("0.5.9") + print("0.5.10") elif args.command == "convert": f.convert(args.format, args.files, args.output_dir) @@ -62,7 +62,7 @@ def run(args, parser): elif args.action == "url": f.url(args.dataset) elif args.action == "push": - f.upload_data(args.dataset, args.files, args.exclude, args.fps, args.path) + f.upload_data(args.dataset, args.files, args.exclude, args.fps, args.path, args.as_video) # Remove a project (remotely) elif args.action == "remove": f.remove_remote_dataset(args.dataset) diff --git a/darwin/cli_functions.py b/darwin/cli_functions.py index 5d8aa103c..3afdb331b 100644 --- a/darwin/cli_functions.py +++ b/darwin/cli_functions.py @@ -419,7 +419,12 @@ def dataset_list_releases(dataset_slug: str): def upload_data( - dataset_slug: str, files: Optional[List[str]], files_to_exclude: Optional[List[str]], fps: int, path: Optional[str] + dataset_slug: str, + files: Optional[List[str]], + files_to_exclude: Optional[List[str]], + fps: int, + path: Optional[str], + as_video: Optional[bool], ): """Uploads the files provided as parameter to the remote dataset selected @@ -444,7 +449,7 @@ def upload_data( client = _load_client() try: dataset = client.get_remote_dataset(dataset_identifier=dataset_slug) - dataset.push(files_to_exclude=files_to_exclude, fps=fps, files_to_upload=files, path=path) + dataset.push(files_to_exclude=files_to_exclude, fps=fps, as_video=as_video, files_to_upload=files, path=path) except NotFound as e: _error(f"No dataset with name '{e.name}'") except ValueError: diff --git a/darwin/dataset/remote_dataset.py b/darwin/dataset/remote_dataset.py index e563a3b1b..297a90d15 100644 --- a/darwin/dataset/remote_dataset.py +++ b/darwin/dataset/remote_dataset.py @@ -69,6 +69,7 @@ def push( blocking: bool = True, multi_threaded: bool = True, fps: int = 1, + as_video: bool = False, files_to_exclude: Optional[List[str]] = None, resume: bool = False, path: Optional[str] = None, @@ -88,6 +89,8 @@ def push( List of files to exclude from the file scan (which is done only if files is None) fps : int Number of file per seconds to upload + as_video: bool + Annotate as video. resume : bool Flag for signalling the resuming of a push path: str @@ -137,6 +140,7 @@ def push( dataset_id=str(self.dataset_id), filenames=files_to_upload, fps=fps, + as_video=as_video, team=self.team, path=path, ) diff --git a/darwin/dataset/upload_manager.py b/darwin/dataset/upload_manager.py index 3216a12b3..d004683b2 100644 --- a/darwin/dataset/upload_manager.py +++ b/darwin/dataset/upload_manager.py @@ -24,6 +24,7 @@ def add_files_to_dataset( filenames: List[Path], team: str, fps: Optional[int] = 1, + as_video: Optional[bool] = False, path: Optional[str] = None, ): """Helper function: upload images to an existing remote dataset @@ -52,7 +53,9 @@ def add_files_to_dataset( images, videos = _split_on_file_type(filenames_chunk) payload = { "image_filenames": [image.name for image in images], - "videos": [{"fps": fps, "original_filename": video.name} for video in videos], + "videos": [ + {"fps": fps, "annotate_as_video": as_video, "original_filename": video.name} for video in videos + ], } if path: payload["path"] = path diff --git a/darwin/options.py b/darwin/options.py index 169d14ce2..999710a2a 100644 --- a/darwin/options.py +++ b/darwin/options.py @@ -78,6 +78,10 @@ def __init__(self): parser_push.add_argument( "-f", "--fps", type=int, default="1", help="Frames per second for video split (recommended: 1)." ) + parser_push.add_argument( + "--as-video", action="store_true", help="Annotate a video as a video and not independent frames" + ) + parser_push.add_argument("--path", type=str, default=None, help="Folder to upload the files into.") # Remove diff --git a/setup.py b/setup.py index da17034b9..0fd100896 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="darwin-py", - version="0.5.9", + version="0.5.10", author="V7", author_email="info@v7labs.com", description="Library and command line interface for darwin.v7labs.com",