Skip to content

Commit 1fafb34

Browse files
authored
[cherry-pick] remove useless codes & fix save_to_json (#3376)
* remove useless codes * fix JsonMixin to support indent and ensure_ascii
1 parent 3d7b450 commit 1fafb34

File tree

21 files changed

+10
-1917
lines changed

21 files changed

+10
-1917
lines changed

paddlex/inference/common/result/mixin.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,24 +144,29 @@ def _is_json_file(file_path):
144144
mime_type, _ = mimetypes.guess_type(file_path)
145145
return mime_type is not None and mime_type == "application/json"
146146

147-
json = self._to_json()
147+
json_data = self._to_json()
148148
if not _is_json_file(save_path):
149149
fn = Path(self._get_input_fn())
150150
stem = fn.stem
151151
base_save_path = Path(save_path)
152-
for key in json:
152+
for key in json_data:
153153
save_path = base_save_path / f"{stem}_{key}.json"
154154
self._json_writer.write(
155-
save_path.as_posix(), json[key], *args, **kwargs
155+
save_path.as_posix(),
156+
json_data[key],
157+
indent=indent,
158+
ensure_ascii=ensure_ascii,
159+
*args,
160+
**kwargs,
156161
)
157162
else:
158-
if len(json) > 1:
163+
if len(json_data) > 1:
159164
logging.warning(
160165
f"The result has multiple json files need to be saved. But the `save_path` has been specfied as `{save_path}`!"
161166
)
162167
self._json_writer.write(
163168
save_path,
164-
json[list(json.keys())[0]],
169+
json_data[list(json_data.keys())[0]],
165170
indent=indent,
166171
ensure_ascii=ensure_ascii,
167172
*args,

paddlex/inference/results/__init__.py

Lines changed: 0 additions & 31 deletions
This file was deleted.

paddlex/inference/results/attribute_rec.py

Lines changed: 0 additions & 89 deletions
This file was deleted.

paddlex/inference/results/base.py

Lines changed: 0 additions & 43 deletions
This file was deleted.

paddlex/inference/results/chat_ocr.py

Lines changed: 0 additions & 158 deletions
This file was deleted.

0 commit comments

Comments
 (0)