Skip to content

Commit ce9de8a

Browse files
nmanovicChris Lee-Messer
authored and
Chris Lee-Messer
committed
Selecting non images leads to 400 error (cvat-ai#734)
* Fix HTTP 400 error if together with vision data the user submit non-vision data (e.g. text files) * Ignore SVG images because Pillow doesn't work with them.
1 parent 2e2ff55 commit ce9de8a

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

cvat/apps/engine/media_extractors.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,9 @@ def _is_video(path):
225225

226226
def _is_image(path):
227227
mime = mimetypes.guess_type(path)
228-
return mime[0] is not None and mime[0].startswith('image')
228+
# Exclude vector graphic images because Pillow cannot work with them
229+
return mime[0] is not None and mime[0].startswith('image') and \
230+
not mime[0].startswith('image/svg')
229231

230232
def _is_dir(path):
231233
return os.path.isdir(path)

cvat/apps/engine/task.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,12 @@ def _validate_data(data):
166166
def count_files(file_mapping, counter):
167167
for rel_path, full_path in file_mapping.items():
168168
mime = get_mime(full_path)
169-
counter[mime].append(rel_path)
169+
if mime in counter:
170+
counter[mime].append(rel_path)
171+
else:
172+
slogger.glob.warn("Skip '{}' file (its mime type doesn't "
173+
"correspond to a video or an image file)".format(full_path))
174+
170175

171176
counter = { media_type: [] for media_type in MEDIA_TYPES.keys() }
172177

0 commit comments

Comments
 (0)