Skip to content

Commit

Permalink
Support of context images for 2D tasks (Missed commits) (cvat-ai#3213)
Browse files Browse the repository at this point in the history
* Fixed bug with not filtering file itself in some 3D cases

* Added else branch to avoid dublication context images in some cases
  • Loading branch information
Boris Sekachev committed May 19, 2021
1 parent 6f52ef3 commit e0f10d7
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions utils/dataset_manifest/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,23 @@ def _detect_related_images_3D(image_paths, root_path):
# Update some data applicable for a subset of paths (within the current dirname)
latest_dirname = dirname
related_images_exist = os.path.isdir(related_images_dirname)
dirname_files = list(filter(lambda x: x != image_path, _list_and_join(dirname)))
dirname_files = list(_list_and_join(dirname))
velodyne_context_images_dirs = [directory for directory
in _list_and_join(os.path.normpath(os.path.join(dirname, '..', '..')))
if os.path.isdir(os.path.join(directory, 'data')) and re.search(r'image_\d.*', directory, re.IGNORECASE)
]

if os.path.basename(dirname) == name:
filtered_dirname_files = list(filter(lambda x: x != image_path, dirname_files))
if len(filtered_dirname_files) and os.path.basename(dirname) == name:
# default format (option 2)
related_images[rel_image_path].extend(_prepare_context_list(dirname_files, root_path))

filtered_dirname_files = list(filter(lambda x: os.path.splitext(os.path.basename(x))[0] == name, dirname_files))
if len(filtered_dirname_files):
# default format (option 1)
related_images[rel_image_path].extend(_prepare_context_list(filtered_dirname_files, root_path))
else:
filtered_dirname_files = list(
filter(lambda x: os.path.splitext(os.path.basename(x))[0] == name, filtered_dirname_files)
)
if len(filtered_dirname_files):
# default format (option 1)
related_images[rel_image_path].extend(_prepare_context_list(filtered_dirname_files, root_path))

if related_images_exist:
related_images_dirname = os.path.join(
Expand Down

0 comments on commit e0f10d7

Please sign in to comment.