Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions deploy/hps/sdk/common/server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ rm -rf "${MODEL_REPO_DIR}"
cp -r model_repo "${MODEL_REPO_DIR}"

find "${MODEL_REPO_DIR}" -mindepth 1 -maxdepth 1 -type d -print0 | while IFS= read -r -d '' dir_; do
if [ "${PADDLEX_HPS_DEVICE_TYPE}" = 'gpu' ]; then
cp -f "${dir_}/config_gpu.pbtxt" "${dir_}/config.pbtxt"
else
cp -f "${dir_}/config_cpu.pbtxt" "${dir_}/config.pbtxt"
if [ ! -f "${dir_}/config.pbtxt" ]; then
if [ "${PADDLEX_HPS_DEVICE_TYPE:-gpu}" = 'gpu' ]; then
cp -f "${dir_}/config_gpu.pbtxt" "${dir_}/config.pbtxt"
else
cp -f "${dir_}/config_cpu.pbtxt" "${dir_}/config.pbtxt"
fi
fi
done

Expand Down
1 change: 1 addition & 0 deletions deploy/hps/sdk/pipelines/3d_bev_detection/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.1
32 changes: 22 additions & 10 deletions deploy/hps/sdk/pipelines/OCR/server/model_repo/ocr/1/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from paddlex_hps_server import (
BaseTritonPythonModel,
app_common,
logging,
protocol,
schemas,
utils,
Expand Down Expand Up @@ -167,10 +168,13 @@ def run_batch(self, inputs, log_ids, batch_id):

def _group_inputs(self, inputs):
def _to_hashable(obj):
if isinstance(obj, list):
return tuple(obj)
elif isinstance(obj, dict):
return tuple(sorted(obj.items()))
if isinstance(obj, dict):
return tuple(
(_to_hashable(k), _to_hashable(v))
for k, v in sorted(obj.items(), key=lambda x: repr(x[0]))
)
elif isinstance(obj, list):
return tuple(_to_hashable(x) for x in obj)
else:
return obj

Expand Down Expand Up @@ -231,12 +235,20 @@ def _preprocess(self, input, log_id):
else self.app_config.visualize
)

file_bytes = utils.get_raw_bytes(input.file)
images, data_info = utils.file_to_images(
file_bytes,
file_type,
max_num_imgs=self.context["max_num_input_imgs"],
)
try:
file_bytes = utils.get_raw_bytes(input.file)
images, data_info = utils.file_to_images(
file_bytes,
file_type,
max_num_imgs=self.context["max_num_input_imgs"],
)
except Exception as e:
logging.error("Failed to get input file bytes: %s", e)
return protocol.create_aistudio_output_without_result(
422,
"Input file is invalid",
log_id=log_id,
)

return images, data_info, visualize_enabled

Expand Down
1 change: 1 addition & 0 deletions deploy/hps/sdk/pipelines/OCR/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.2.5
1 change: 1 addition & 0 deletions deploy/hps/sdk/pipelines/PP-ChatOCRv3-doc/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.3.2
1 change: 1 addition & 0 deletions deploy/hps/sdk/pipelines/PP-ChatOCRv4-doc/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.4.2
1 change: 1 addition & 0 deletions deploy/hps/sdk/pipelines/PP-DocTranslation/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.2
1 change: 1 addition & 0 deletions deploy/hps/sdk/pipelines/PP-ShiTuV2/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.1
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from paddlex_hps_server import (
BaseTritonPythonModel,
app_common,
logging,
protocol,
schemas,
utils,
Expand Down Expand Up @@ -200,10 +201,13 @@ def run_batch(self, inputs, log_ids, batch_id):

def _group_inputs(self, inputs):
def _to_hashable(obj):
if isinstance(obj, list):
return tuple(obj)
elif isinstance(obj, dict):
return tuple(sorted(obj.items()))
if isinstance(obj, dict):
return tuple(
(_to_hashable(k), _to_hashable(v))
for k, v in sorted(obj.items(), key=lambda x: repr(x[0]))
)
elif isinstance(obj, list):
return tuple(_to_hashable(x) for x in obj)
else:
return obj

Expand Down Expand Up @@ -286,20 +290,32 @@ def _preprocess(self, input, log_id):
else self.app_config.visualize
)

file_bytes = utils.get_raw_bytes(input.file)
images, data_info = utils.file_to_images(
file_bytes,
file_type,
max_num_imgs=self.context["max_num_input_imgs"],
)
try:
file_bytes = utils.get_raw_bytes(input.file)
images, data_info = utils.file_to_images(
file_bytes,
file_type,
max_num_imgs=self.context["max_num_input_imgs"],
)
except Exception as e:
logging.error("Failed to get input file bytes: %s", e)
return protocol.create_aistudio_output_without_result(
422,
"Input file is invalid",
log_id=log_id,
)

return images, data_info, visualize_enabled

def _postprocess(self, images, data_info, visualize_enabled, preds, log_id, input):
layout_parsing_results: List[Dict[str, Any]] = []
for i, (img, item) in enumerate(zip(images, preds)):
pruned_res = app_common.prune_result(item.json["res"])
md_data = item.markdown
# XXX
md_data = item._to_markdown(
pretty=input.prettifyMarkdown,
show_formula_number=input.showFormulaNumber,
)
md_text = md_data["markdown_texts"]
md_imgs = app_common.postprocess_images(
md_data["markdown_images"],
Expand Down
1 change: 1 addition & 0 deletions deploy/hps/sdk/pipelines/PP-StructureV3/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.3.5
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Copyright (c) 2025 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from paddlex_hps_server import (
BaseTritonPythonModel,
app_common,
schemas,
)


class TritonPythonModel(BaseTritonPythonModel):
@property
def pipeline_creation_kwargs(self):
return {"initial_predictor": False}

def get_input_model_type(self):
return schemas.paddleocr_vl.ConcatenatePagesRequest

def get_result_model_type(self):
return schemas.paddleocr_vl.ConcatenatePagesResult

def run(self, input, log_id):
def _to_original_result(pruned_res):
orig_res = {"res": pruned_res}
return orig_res

original_results = []
markdown_images = {}
for i, page in enumerate(input.pages):
orig_res = _to_original_result(page.prunedResult)
original_results.append(orig_res)
markdown_images.update(page.markdownImages)

concatenated_result = self.pipeline.concatenate_pages(
original_results,
merge_table=input.mergeTable,
title_level=input.titleLevel,
)

layout_parsing_result = {}
layout_parsing_result["prunedResult"] = app_common.prune_result(
concatenated_result.json["res"]
)
# XXX
md_data = concatenated_result._to_markdown(
pretty=input.prettifyMarkdown,
show_formula_number=input.showFormulaNumber,
)
layout_parsing_result["markdown"] = dict(
text=md_data["markdown_texts"],
images=markdown_images,
)

return schemas.paddleocr_vl.ConcatenatePagesResult(
layoutParsingResult=layout_parsing_result,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
backend: "python"
max_batch_size: 1
input [
{
name: "input"
data_type: TYPE_STRING
dims: [ 1 ]
}
]
output [
{
name: "output"
data_type: TYPE_STRING
dims: [ 1 ]
}
]
instance_group [
{
count: 1
kind: KIND_CPU
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from paddlex_hps_server import (
BaseTritonPythonModel,
app_common,
logging,
protocol,
schemas,
utils,
Expand Down Expand Up @@ -123,7 +124,10 @@ def run_batch(self, inputs, log_ids, batch_id):
].useDocOrientationClassify,
use_doc_unwarping=inputs_g[0].useDocUnwarping,
use_layout_detection=inputs_g[0].useLayoutDetection,
use_polygon_points=inputs_g[0].usePolygonPoints,
use_chart_recognition=inputs_g[0].useChartRecognition,
use_seal_recognition=inputs_g[0].useSealRecognition,
use_ocr_for_image_block=inputs_g[0].useOcrForImageBlock,
layout_threshold=inputs_g[0].layoutThreshold,
layout_nms=inputs_g[0].layoutNms,
layout_unclip_ratio=inputs_g[0].layoutUnclipRatio,
Expand All @@ -138,6 +142,7 @@ def run_batch(self, inputs, log_ids, batch_id):
max_new_tokens=inputs_g[0].maxNewTokens,
merge_layout_blocks=inputs_g[0].mergeLayoutBlocks,
markdown_ignore_labels=inputs_g[0].markdownIgnoreLabels,
vlm_extra_args=inputs_g[0].vlmExtraArgs,
)
)

Expand Down Expand Up @@ -174,10 +179,13 @@ def run_batch(self, inputs, log_ids, batch_id):

def _group_inputs(self, inputs):
def _to_hashable(obj):
if isinstance(obj, list):
return tuple(obj)
elif isinstance(obj, dict):
return tuple(sorted(obj.items()))
if isinstance(obj, dict):
return tuple(
(_to_hashable(k), _to_hashable(v))
for k, v in sorted(obj.items(), key=lambda x: repr(x[0]))
)
elif isinstance(obj, list):
return tuple(_to_hashable(x) for x in obj)
else:
return obj

Expand All @@ -191,7 +199,10 @@ def _hash(input):
input.useDocOrientationClassify,
input.useDocUnwarping,
input.useLayoutDetection,
input.usePolygonPoints,
input.useChartRecognition,
input.useSealRecognition,
input.useOcrForImageBlock,
input.layoutThreshold,
input.layoutNms,
input.layoutUnclipRatio,
Expand All @@ -206,6 +217,7 @@ def _hash(input):
input.maxNewTokens,
input.mergeLayoutBlocks,
input.markdownIgnoreLabels,
input.vlmExtraArgs,
)
),
)
Expand Down Expand Up @@ -248,12 +260,20 @@ def _preprocess(self, input, log_id):
else self.app_config.visualize
)

file_bytes = utils.get_raw_bytes(input.file)
images, data_info = utils.file_to_images(
file_bytes,
file_type,
max_num_imgs=self.context["max_num_input_imgs"],
)
try:
file_bytes = utils.get_raw_bytes(input.file)
images, data_info = utils.file_to_images(
file_bytes,
file_type,
max_num_imgs=self.context["max_num_input_imgs"],
)
except Exception as e:
logging.error("Failed to get input file bytes: %s", e)
return protocol.create_aistudio_output_without_result(
422,
"Input file is invalid",
log_id=log_id,
)

return images, data_info, visualize_enabled

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ SubModules:
module_name: vl_recognition
model_name: PaddleOCR-VL-0.9B
model_dir: null
batch_size: 4096
batch_size: -1
genai_config:
backend: native

Expand Down
1 change: 1 addition & 0 deletions deploy/hps/sdk/pipelines/PaddleOCR-VL/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.2.0
1 change: 1 addition & 0 deletions deploy/hps/sdk/pipelines/anomaly_detection/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.1
1 change: 1 addition & 0 deletions deploy/hps/sdk/pipelines/doc_preprocessor/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.2.1
1 change: 1 addition & 0 deletions deploy/hps/sdk/pipelines/doc_understanding/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.2
1 change: 1 addition & 0 deletions deploy/hps/sdk/pipelines/face_recognition/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.1
1 change: 1 addition & 0 deletions deploy/hps/sdk/pipelines/formula_recognition/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.2.1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.1
1 change: 1 addition & 0 deletions deploy/hps/sdk/pipelines/image_classification/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.1
1 change: 1 addition & 0 deletions deploy/hps/sdk/pipelines/instance_segmentation/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.1
1 change: 1 addition & 0 deletions deploy/hps/sdk/pipelines/layout_parsing/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.3.1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.2.1
1 change: 1 addition & 0 deletions deploy/hps/sdk/pipelines/object_detection/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.1
1 change: 1 addition & 0 deletions deploy/hps/sdk/pipelines/seal_recognition/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.2.2
1 change: 1 addition & 0 deletions deploy/hps/sdk/pipelines/semantic_segmentation/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.1
1 change: 1 addition & 0 deletions deploy/hps/sdk/pipelines/table_recognition/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.4.1
1 change: 1 addition & 0 deletions deploy/hps/sdk/pipelines/table_recognition_v2/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.4.1
1 change: 1 addition & 0 deletions deploy/hps/sdk/pipelines/ts_anomaly_detection/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.1
1 change: 1 addition & 0 deletions deploy/hps/sdk/pipelines/ts_classification/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.1
1 change: 1 addition & 0 deletions deploy/hps/sdk/pipelines/ts_forecast/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.1
1 change: 1 addition & 0 deletions deploy/hps/sdk/pipelines/video_classification/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.2.1
1 change: 1 addition & 0 deletions deploy/hps/sdk/pipelines/video_detection/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.2.1
Loading