Skip to content

Commit

Permalink
动植物识别、图片内容理解修改返回结果 (#199)
Browse files Browse the repository at this point in the history
* 动植物识别、图片内容理解修改返回结果

* 修改代码规范

---------

Co-authored-by: zhongsonghui <[email protected]>
  • Loading branch information
birham-red-bd and zhongsonghui authored Mar 20, 2024
1 parent aa1114a commit 1248add
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
7 changes: 5 additions & 2 deletions appbuilder/core/components/animal_recognize/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
from appbuilder.core._exception import AppBuilderServerException
from typing import Generator, Union

TOP_NUM = 1
BAIKE_NUM = 0


class AnimalRecognition(Component):
r"""
Expand Down Expand Up @@ -169,8 +172,8 @@ def _recognize_w_post_process(self, img_path, img_url, file_urls) -> str:
if img_url in file_urls:
img_url = file_urls['img_url']
req.url = img_url
req.top_num = 6
req.baike_num = 0
req.top_num = TOP_NUM
req.baike_num = BAIKE_NUM
result = self._recognize(req)
result_dict = proto.Message.to_dict(result)
rec_res = "模型识别结果为:\n"
Expand Down
11 changes: 10 additions & 1 deletion appbuilder/core/components/image_understand/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,16 @@ def tool_eval(self, name: str, streaming: bool,
file_urls = kwargs.get("file_urls", {})
rec_res = self._recognize_w_post_process(img_path, img_url, file_urls)
if streaming:
yield rec_res
yield {
"type": "text",
"text": rec_res,
"visible_scope": 'llm',
}
yield {
"type": "text",
"text": "",
"visible_scope": 'user',
}
else:
return rec_res

Expand Down
7 changes: 5 additions & 2 deletions appbuilder/core/components/plant_recognize/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
from appbuilder.core.components.plant_recognize.model import *
from typing import Generator, Union

TOP_NUM = 1
BAIKE_NUM = 0


class PlantRecognition(Component):
r"""
Expand Down Expand Up @@ -174,8 +177,8 @@ def _recognize_w_post_process(self, img_path, img_url, file_urls):
if img_url in file_urls:
img_url = file_urls['img_url']
req.url = img_url
req.top_num = 6
req.baike_num = 0
req.top_num = TOP_NUM
req.baike_num = BAIKE_NUM
result = self.__recognize(req)
result_dict = proto.Message.to_dict(result)
rec_res = "模型识别结果为:\n"
Expand Down

0 comments on commit 1248add

Please sign in to comment.