This commit is contained in:
Michael 2024-01-17 19:46:35 +01:00
parent 695592b7b6
commit 294fb339ed
No known key found for this signature in database
GPG Key ID: 066ED7D431960C9B
3 changed files with 3 additions and 3 deletions

View File

@ -19,7 +19,7 @@ def translate(to_translate, lang):
for index, label_info in to_translate.items():
label = label_info.get("label")
to_translate[index]["label"] = config.get(label).data
return to_translate, None
return to_translate, []
except Exception as e:
error_message = f"Error translating labels: {e}"
print(error_message)

View File

@ -95,7 +95,7 @@ def upload_file():
'isCat': False if not predictions else True,
**({'predictions': predictions} if predictions is not None else {})
}
if error_messages is not None and predictions is None:
if len(error_messages) > 1:
results['errors'].append(error_messages)
# Send response with 200 (Success)

View File

@ -25,7 +25,7 @@ def validate(request):
# Case 3 -> if some of the images has wrong extension
for img in images:
if imghdr.what(img) not in allowed_extensions:
if not img.filename.lower().endswith(('.png', '.jpg', '.jpeg')):
raise ValueError(f"Given file '{img.filename}' has no allowed extension. "
f"Allowed extensions: {allowed_extensions}.")
except Exception as e: