Skip to content

Commit

Permalink
support for uploading as-video
Browse files Browse the repository at this point in the history
  • Loading branch information
simedw committed Jul 30, 2020
1 parent 2df7b6a commit 720c149
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 6 deletions.
4 changes: 2 additions & 2 deletions darwin/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
9 changes: 7 additions & 2 deletions darwin/cli_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions darwin/dataset/remote_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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,
)
Expand Down
5 changes: 4 additions & 1 deletion darwin/dataset/upload_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions darwin/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="darwin-py",
version="0.5.9",
version="0.5.10",
author="V7",
author_email="[email protected]",
description="Library and command line interface for darwin.v7labs.com",
Expand Down

0 comments on commit 720c149

Please sign in to comment.