修复部分参数校验

This commit is contained in:
sml2h3 2024-07-30 15:52:29 +08:00
parent 901103a7e3
commit f9e3624eff

View File

@ -38,7 +38,7 @@ async def ocr_endpoint(
png_fix: bool = Form(False)
):
try:
if file is None and image is None:
if file.size == 0 and image is None:
return APIResponse(code=400, message="Either file or image must be provided")
image_bytes = await decode_image(file or image)
@ -57,7 +57,7 @@ async def slide_match_endpoint(
simple_target: bool = Form(False)
):
try:
if (target_file is None and target is None) or (background_file is None and background is None):
if (background is None and target is None) or (background_file.size == 0 and target_file.size == 0):
return APIResponse(code=400, message="Both target and background must be provided")
target_bytes = await decode_image(target_file or target)
@ -74,7 +74,7 @@ async def detection_endpoint(
image: Optional[str] = Form(None)
):
try:
if file is None and image is None:
if file.size == 0 and image is None:
return APIResponse(code=400, message="Either file or image must be provided")
image_bytes = await decode_image(file or image)