|
|
|
@ -604,15 +604,10 @@ async def process_image(image_url: str, current_user: dict = Depends(get_current
|
|
|
|
|
:return: 流式输出结果
|
|
|
|
|
"""
|
|
|
|
|
try:
|
|
|
|
|
if await is_text_dominant(client, image_url):
|
|
|
|
|
logger.info("检测到图片主要是文字内容,开始识别文字:")
|
|
|
|
|
return StreamingResponse(recognize_text(client, app.state.mysql_pool, current_user['person_id'], image_url),
|
|
|
|
|
media_type="text/plain")
|
|
|
|
|
else:
|
|
|
|
|
print("检测到图片主要是物体/场景,开始识别内容:")
|
|
|
|
|
return StreamingResponse(
|
|
|
|
|
recognize_content(client, app.state.mysql_pool, current_user['person_id'], image_url),
|
|
|
|
|
media_type="text/plain")
|
|
|
|
|
print("检测到图片主要是物体/场景,开始识别内容:")
|
|
|
|
|
return StreamingResponse(
|
|
|
|
|
recognize_content(client, app.state.mysql_pool, current_user['person_id'], image_url),
|
|
|
|
|
media_type="text/plain")
|
|
|
|
|
except Exception as e:
|
|
|
|
|
raise HTTPException(status_code=500, detail=str(e))
|
|
|
|
|
|
|
|
|
|