From 8a5a8c5fc0c5ebbdc9012c03ff07426d744d5413 Mon Sep 17 00:00:00 2001 From: Nikita Manovich Date: Wed, 25 Sep 2019 11:48:05 +0300 Subject: [PATCH 1/2] Fix HTTP 400 error if together with vision data the user submit non-vision data (e.g. text files) --- cvat/apps/engine/task.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cvat/apps/engine/task.py b/cvat/apps/engine/task.py index 7d1fbd18895..f29a31351fb 100644 --- a/cvat/apps/engine/task.py +++ b/cvat/apps/engine/task.py @@ -166,7 +166,12 @@ def _validate_data(data): def count_files(file_mapping, counter): for rel_path, full_path in file_mapping.items(): mime = get_mime(full_path) - counter[mime].append(rel_path) + if mime in counter: + counter[mime].append(rel_path) + else: + slogger.glob.warn("Skip '{}' file (its mime type doesn't " + "correspond to a video or an image file)".format(full_path)) + counter = { media_type: [] for media_type in MEDIA_TYPES.keys() } From b3133f121d343b1818e78b4d296cc5291e7dc1a4 Mon Sep 17 00:00:00 2001 From: Nikita Manovich Date: Wed, 25 Sep 2019 11:59:31 +0300 Subject: [PATCH 2/2] Ignore SVG images because Pillow doesn't work with them. --- cvat/apps/engine/media_extractors.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cvat/apps/engine/media_extractors.py b/cvat/apps/engine/media_extractors.py index 89a12bab8c5..018671e1b17 100644 --- a/cvat/apps/engine/media_extractors.py +++ b/cvat/apps/engine/media_extractors.py @@ -225,7 +225,9 @@ def _is_video(path): def _is_image(path): mime = mimetypes.guess_type(path) - return mime[0] is not None and mime[0].startswith('image') + # Exclude vector graphic images because Pillow cannot work with them + return mime[0] is not None and mime[0].startswith('image') and \ + not mime[0].startswith('image/svg') def _is_dir(path): return os.path.isdir(path)