|
@@ -20,7 +20,7 @@ from .....utils.deps import function_requires_deps, is_dep_available
|
|
|
from ....pipelines.components import IndexData
|
|
from ....pipelines.components import IndexData
|
|
|
from ...infra import utils as serving_utils
|
|
from ...infra import utils as serving_utils
|
|
|
from ...infra.config import AppConfig
|
|
from ...infra.config import AppConfig
|
|
|
-from ...infra.models import ResultResponse
|
|
|
|
|
|
|
+from ...infra.models import AIStudioResultResponse
|
|
|
from ...schemas import pp_shituv2 as schema
|
|
from ...schemas import pp_shituv2 as schema
|
|
|
from .._app import create_app, primary_operation
|
|
from .._app import create_app, primary_operation
|
|
|
from ._common import image_recognition as ir_common
|
|
from ._common import image_recognition as ir_common
|
|
@@ -44,7 +44,7 @@ def create_pipeline_app(pipeline: Any, app_config: AppConfig) -> "FastAPI":
|
|
|
)
|
|
)
|
|
|
async def _build_index(
|
|
async def _build_index(
|
|
|
request: schema.BuildIndexRequest,
|
|
request: schema.BuildIndexRequest,
|
|
|
- ) -> ResultResponse[schema.BuildIndexResult]:
|
|
|
|
|
|
|
+ ) -> AIStudioResultResponse[schema.BuildIndexResult]:
|
|
|
pipeline = ctx.pipeline
|
|
pipeline = ctx.pipeline
|
|
|
aiohttp_session = ctx.aiohttp_session
|
|
aiohttp_session = ctx.aiohttp_session
|
|
|
|
|
|
|
@@ -72,7 +72,7 @@ def create_pipeline_app(pipeline: Any, app_config: AppConfig) -> "FastAPI":
|
|
|
index_data_bytes = index_data.to_bytes()
|
|
index_data_bytes = index_data.to_bytes()
|
|
|
await serving_utils.call_async(index_storage.set, index_key, index_data_bytes)
|
|
await serving_utils.call_async(index_storage.set, index_key, index_data_bytes)
|
|
|
|
|
|
|
|
- return ResultResponse[schema.BuildIndexResult](
|
|
|
|
|
|
|
+ return AIStudioResultResponse[schema.BuildIndexResult](
|
|
|
logId=serving_utils.generate_log_id(),
|
|
logId=serving_utils.generate_log_id(),
|
|
|
result=schema.BuildIndexResult(
|
|
result=schema.BuildIndexResult(
|
|
|
indexKey=index_key, imageCount=len(index_data.id_map)
|
|
indexKey=index_key, imageCount=len(index_data.id_map)
|
|
@@ -86,7 +86,7 @@ def create_pipeline_app(pipeline: Any, app_config: AppConfig) -> "FastAPI":
|
|
|
)
|
|
)
|
|
|
async def _add_images_to_index(
|
|
async def _add_images_to_index(
|
|
|
request: schema.AddImagesToIndexRequest,
|
|
request: schema.AddImagesToIndexRequest,
|
|
|
- ) -> ResultResponse[schema.AddImagesToIndexResult]:
|
|
|
|
|
|
|
+ ) -> AIStudioResultResponse[schema.AddImagesToIndexResult]:
|
|
|
pipeline = ctx.pipeline
|
|
pipeline = ctx.pipeline
|
|
|
aiohttp_session = ctx.aiohttp_session
|
|
aiohttp_session = ctx.aiohttp_session
|
|
|
|
|
|
|
@@ -114,7 +114,7 @@ def create_pipeline_app(pipeline: Any, app_config: AppConfig) -> "FastAPI":
|
|
|
index_storage.set, request.indexKey, index_data_bytes
|
|
index_storage.set, request.indexKey, index_data_bytes
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
- return ResultResponse[schema.AddImagesToIndexResult](
|
|
|
|
|
|
|
+ return AIStudioResultResponse[schema.AddImagesToIndexResult](
|
|
|
logId=serving_utils.generate_log_id(),
|
|
logId=serving_utils.generate_log_id(),
|
|
|
result=schema.AddImagesToIndexResult(imageCount=len(index_data.id_map)),
|
|
result=schema.AddImagesToIndexResult(imageCount=len(index_data.id_map)),
|
|
|
)
|
|
)
|
|
@@ -126,7 +126,7 @@ def create_pipeline_app(pipeline: Any, app_config: AppConfig) -> "FastAPI":
|
|
|
)
|
|
)
|
|
|
async def _remove_images_from_index(
|
|
async def _remove_images_from_index(
|
|
|
request: schema.RemoveImagesFromIndexRequest,
|
|
request: schema.RemoveImagesFromIndexRequest,
|
|
|
- ) -> ResultResponse[schema.RemoveImagesFromIndexResult]:
|
|
|
|
|
|
|
+ ) -> AIStudioResultResponse[schema.RemoveImagesFromIndexResult]:
|
|
|
pipeline = ctx.pipeline
|
|
pipeline = ctx.pipeline
|
|
|
|
|
|
|
|
index_storage = ctx.extra["index_storage"]
|
|
index_storage = ctx.extra["index_storage"]
|
|
@@ -144,7 +144,7 @@ def create_pipeline_app(pipeline: Any, app_config: AppConfig) -> "FastAPI":
|
|
|
index_storage.set, request.indexKey, index_data_bytes
|
|
index_storage.set, request.indexKey, index_data_bytes
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
- return ResultResponse[schema.RemoveImagesFromIndexResult](
|
|
|
|
|
|
|
+ return AIStudioResultResponse[schema.RemoveImagesFromIndexResult](
|
|
|
logId=serving_utils.generate_log_id(),
|
|
logId=serving_utils.generate_log_id(),
|
|
|
result=schema.RemoveImagesFromIndexResult(
|
|
result=schema.RemoveImagesFromIndexResult(
|
|
|
imageCount=len(index_data.id_map)
|
|
imageCount=len(index_data.id_map)
|
|
@@ -158,7 +158,7 @@ def create_pipeline_app(pipeline: Any, app_config: AppConfig) -> "FastAPI":
|
|
|
)
|
|
)
|
|
|
async def _infer(
|
|
async def _infer(
|
|
|
request: schema.InferRequest,
|
|
request: schema.InferRequest,
|
|
|
- ) -> ResultResponse[schema.InferResult]:
|
|
|
|
|
|
|
+ ) -> AIStudioResultResponse[schema.InferResult]:
|
|
|
pipeline = ctx.pipeline
|
|
pipeline = ctx.pipeline
|
|
|
aiohttp_session = ctx.aiohttp_session
|
|
aiohttp_session = ctx.aiohttp_session
|
|
|
|
|
|
|
@@ -213,7 +213,7 @@ def create_pipeline_app(pipeline: Any, app_config: AppConfig) -> "FastAPI":
|
|
|
else:
|
|
else:
|
|
|
output_image_base64 = None
|
|
output_image_base64 = None
|
|
|
|
|
|
|
|
- return ResultResponse[schema.InferResult](
|
|
|
|
|
|
|
+ return AIStudioResultResponse[schema.InferResult](
|
|
|
logId=serving_utils.generate_log_id(),
|
|
logId=serving_utils.generate_log_id(),
|
|
|
result=schema.InferResult(detectedObjects=objs, image=output_image_base64),
|
|
result=schema.InferResult(detectedObjects=objs, image=output_image_base64),
|
|
|
)
|
|
)
|