Skip to content

Commit 0c9b1fa

Browse files
committed
[Feat] Support result visualization for time-series pipeline apps and rename layout_parsing_v2 (#3543)
* Fix serving apps * Convert to RGB * Fix schema * Rename layout_parsing_v2 to pp_structurev3 * Update doc
1 parent 4ee030f commit 0c9b1fa

File tree

10 files changed

+32
-11
lines changed

10 files changed

+32
-11
lines changed

docs/pipeline_deploy/serving.en.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ Find the high-stability serving SDK corresponding to the pipeline in the table b
207207
<td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/deploy/paddlex_hps/public/sdks/v3.0.0rc0/paddlex_hps_layout_parsing_sdk.tar.gz">paddlex_hps_layout_parsing_sdk.tar.gz</a></td>
208208
</tr>
209209
<tr>
210-
<td>General layout parsing v2</td>
211-
<td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/deploy/paddlex_hps/public/sdks/v3.0.0rc0/paddlex_hps_layout_parsing_v2_sdk.tar.gz">paddlex_hps_layout_parsing_v2_sdk.tar.gz</a></td>
210+
<td>PP-StructureV3</td>
211+
<td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/deploy/paddlex_hps/public/sdks/v3.0.0rc0/paddlex_hps_PP-StructureV3_sdk.tar.gz">paddlex_hps_PP-StructureV3_sdk.tar.gz</a></td>
212212
</tr>
213213
<tr>
214214
<td>Formula recognition</td>

docs/pipeline_deploy/serving.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ paddlex --serve --pipeline image_classification --use_hpip
207207
<td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/deploy/paddlex_hps/public/sdks/v3.0.0rc0/paddlex_hps_layout_parsing_sdk.tar.gz">paddlex_hps_layout_parsing_sdk.tar.gz</a></td>
208208
</tr>
209209
<tr>
210-
<td>通用版面解析 v2</td>
211-
<td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/deploy/paddlex_hps/public/sdks/v3.0.0rc0/paddlex_hps_layout_parsing_v2_sdk.tar.gz">paddlex_hps_layout_parsing_v2_sdk.tar.gz</a></td>
210+
<td>通用版面解析 v3</td>
211+
<td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/deploy/paddlex_hps/public/sdks/v3.0.0rc0/paddlex_hps_PP-StructureV3_sdk.tar.gz">paddlex_hps_PP-StructureV3_sdk.tar.gz</a></td>
212212
</tr>
213213
<tr>
214214
<td>公式识别</td>

paddlex/inference/serving/basic_serving/_pipeline_apps/layout_parsing_v2.py renamed to paddlex/inference/serving/basic_serving/_pipeline_apps/pp_structurev3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from ...infra import utils as serving_utils
2020
from ...infra.config import AppConfig
2121
from ...infra.models import ResultResponse
22-
from ...schemas.layout_parsing_v2 import INFER_ENDPOINT, InferRequest, InferResult
22+
from ...schemas.pp_structurev3 import INFER_ENDPOINT, InferRequest, InferResult
2323
from .._app import create_app, primary_operation
2424
from ._common import common
2525
from ._common import ocr as ocr_common

paddlex/inference/serving/basic_serving/_pipeline_apps/ts_anomaly_detection.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,16 @@ async def _infer(request: InferRequest) -> ResultResponse[InferResult]:
4747
output_csv = serving_utils.base64_encode(
4848
serving_utils.data_frame_to_bytes(result["anomaly"])
4949
)
50+
if ctx.config.visualize:
51+
output_image = serving_utils.base64_encode(
52+
serving_utils.image_to_bytes(result.img["res"].convert("RGB"))
53+
)
54+
else:
55+
output_image = None
5056

5157
return ResultResponse[InferResult](
5258
logId=serving_utils.generate_log_id(),
53-
result=InferResult(csv=output_csv),
59+
result=InferResult(csv=output_csv, image=output_image),
5460
)
5561

5662
return app

paddlex/inference/serving/basic_serving/_pipeline_apps/ts_classification.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,16 @@ async def _infer(request: InferRequest) -> ResultResponse[InferResult]:
4646

4747
label = str(result["classification"].at[0, "classid"])
4848
score = float(result["classification"].at[0, "score"])
49+
if ctx.config.visualize:
50+
output_image = serving_utils.base64_encode(
51+
serving_utils.image_to_bytes(result.img["res"].convert("RGB"))
52+
)
53+
else:
54+
output_image = None
4955

5056
return ResultResponse[InferResult](
5157
logId=serving_utils.generate_log_id(),
52-
result=InferResult(label=label, score=score),
58+
result=InferResult(label=label, score=score, image=output_image),
5359
)
5460

5561
return app

paddlex/inference/serving/basic_serving/_pipeline_apps/ts_forecast.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,16 @@ async def _infer(request: InferRequest) -> ResultResponse[InferResult]:
4747
output_csv = serving_utils.base64_encode(
4848
serving_utils.data_frame_to_bytes(result["forecast"])
4949
)
50+
if ctx.config.visualize:
51+
output_image = serving_utils.base64_encode(
52+
serving_utils.image_to_bytes(result.img["res"].convert("RGB"))
53+
)
54+
else:
55+
output_image = None
5056

5157
return ResultResponse[InferResult](
5258
logId=serving_utils.generate_log_id(),
53-
result=InferResult(csv=output_csv),
59+
result=InferResult(csv=output_csv, image=output_image),
5460
)
5561

5662
return app
File renamed without changes.

paddlex/inference/serving/schemas/ts_anomaly_detection.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from typing import Final
15+
from typing import Final, Optional
1616

1717
from pydantic import BaseModel
1818

@@ -29,6 +29,7 @@ class InferRequest(BaseModel):
2929

3030
class InferResult(BaseModel):
3131
csv: str
32+
image: Optional[str] = None
3233

3334

3435
PRIMARY_OPERATIONS: Final[PrimaryOperations] = {

paddlex/inference/serving/schemas/ts_classification.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from typing import Final
15+
from typing import Final, Optional
1616

1717
from pydantic import BaseModel
1818

@@ -30,6 +30,7 @@ class InferRequest(BaseModel):
3030
class InferResult(BaseModel):
3131
label: str
3232
score: float
33+
image: Optional[str] = None
3334

3435

3536
PRIMARY_OPERATIONS: Final[PrimaryOperations] = {

paddlex/inference/serving/schemas/ts_forecast.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from typing import Final
15+
from typing import Final, Optional
1616

1717
from pydantic import BaseModel
1818

@@ -29,6 +29,7 @@ class InferRequest(BaseModel):
2929

3030
class InferResult(BaseModel):
3131
csv: str
32+
image: Optional[str] = None
3233

3334

3435
PRIMARY_OPERATIONS: Final[PrimaryOperations] = {

0 commit comments

Comments
 (0)