Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion darwin/dataset/remote_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
Union,
)

from rich.console import Console

from darwin.dataset.download_manager import download_all_images_from_annotations
from darwin.dataset.identifier import DatasetIdentifier
from darwin.dataset.release import Release
Expand All @@ -41,7 +43,6 @@
from darwin.item import DatasetItem
from darwin.item_sorter import ItemSorter
from darwin.utils import parse_darwin_json, split_video_annotation, urljoin
from rich.console import Console

if TYPE_CHECKING:
from darwin.client import Client
Expand Down Expand Up @@ -258,6 +259,8 @@ def pull(
except PermissionError:
print(f"Could not remove dataset in {annotations_dir}. Permission denied.")
annotations_dir.mkdir(parents=True, exist_ok=False)
stems: dict = {}

# Move the annotations into the right folder and rename them to have the image
# original filename as contained in the json
for annotation_path in tmp_dir.glob("*.json"):
Expand All @@ -266,6 +269,12 @@ def pull(
continue

filename = Path(annotation.filename).stem
if filename in stems:
stems[filename] += 1
filename = f"{filename}_{stems[filename]}"
else:
stems[filename] = 1

destination_name = annotations_dir / f"{filename}{annotation_path.suffix}"
shutil.move(str(annotation_path), str(destination_name))

Expand Down