mirror of
https://github.com/sml2h3/ocr_api_server.git
synced 2025-05-03 18:22:11 +08:00
Merge 29145a689e
into a40a6b96d7
This commit is contained in:
commit
bfbab3821c
@ -14,4 +14,4 @@ RUN pip install --no-cache-dir -r requirements.txt
|
||||
EXPOSE 8000
|
||||
|
||||
# 运行应用
|
||||
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||
CMD ["python", "app/main.py"]
|
||||
|
@ -15,7 +15,11 @@ async def decode_image(image: Union[UploadFile, StarletteUploadFile, str, None])
|
||||
raise HTTPException(status_code=400, detail="No image provided")
|
||||
|
||||
if isinstance(image, (UploadFile, StarletteUploadFile)):
|
||||
return await image.read()
|
||||
content = await image.read()
|
||||
if not content:
|
||||
raise HTTPException(status_code=400, detail="Uploaded file is empty")
|
||||
return content
|
||||
|
||||
elif isinstance(image, str):
|
||||
try:
|
||||
# 检查是否是 base64 编码的图片
|
||||
@ -57,7 +61,7 @@ async def slide_match_endpoint(
|
||||
simple_target: bool = Form(False)
|
||||
):
|
||||
try:
|
||||
if (background is None and target is None) or (background_file.size == 0 and target_file.size == 0):
|
||||
if (target_file is None and target is None) or (background_file is None and background is None):
|
||||
return APIResponse(code=400, message="Both target and background must be provided")
|
||||
|
||||
target_bytes = await decode_image(target_file or target)
|
||||
|
Loading…
Reference in New Issue
Block a user