From db55d35a90d50be002623b57ba57660a0e89981a Mon Sep 17 00:00:00 2001 From: zhongsonghui Date: Sat, 9 Mar 2024 12:33:06 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E6=8E=A5=E5=8F=A3=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- appbuilder/core/components/animal_recognize/component.py | 7 +------ appbuilder/core/components/image_understand/component.py | 7 +------ appbuilder/core/components/plant_recognize/component.py | 7 +------ 3 files changed, 3 insertions(+), 18 deletions(-) diff --git a/appbuilder/core/components/animal_recognize/component.py b/appbuilder/core/components/animal_recognize/component.py index e41bb3050..239711ad8 100644 --- a/appbuilder/core/components/animal_recognize/component.py +++ b/appbuilder/core/components/animal_recognize/component.py @@ -162,8 +162,6 @@ def _recognize_w_post_process(self, img_path, img_url, file_urls) -> str: 返回: str: 动物识别结果,包括识别出的动物类别和相应的置信度信息 """ - if not img_path and not img_url: - return "Image path and image url cannot be all empty" req = AnimalRecognitionRequest() if img_path in file_urls: req.url = file_urls[img_path] @@ -171,10 +169,7 @@ def _recognize_w_post_process(self, img_path, img_url, file_urls) -> str: req.url = img_url req.top_num = 6 req.baike_num = 0 - try: - result = self._recognize(req) - except Exception as ex: - return "API call failed: {}".format(str(ex)) + result = self._recognize(req) result_dict = proto.Message.to_dict(result) rec_res = "模型识别结果为:\n" for rec_info in result_dict['result']: diff --git a/appbuilder/core/components/image_understand/component.py b/appbuilder/core/components/image_understand/component.py index 629a1b0d2..66c9be424 100644 --- a/appbuilder/core/components/image_understand/component.py +++ b/appbuilder/core/components/image_understand/component.py @@ -183,18 +183,13 @@ def _recognize_w_post_process(self, img_path, img_url, file_urls, question="图 返回: str: 图片内容理解结果 """ - if question == "": - return "Question cannot be empty" req = ImageUnderstandRequest() req.question = question if img_path in file_urls: req.url = file_urls[img_path] if img_url: req.url = img_url - try: - response = self.__recognize(req) - except Exception as ex: - return "API call failed: {}".format(str(ex)) + response = self.__recognize(req) description_to_llm = response.result.description_to_llm description_processed = description_to_llm.rsplit("。", 2)[0] return description_processed diff --git a/appbuilder/core/components/plant_recognize/component.py b/appbuilder/core/components/plant_recognize/component.py index cc6d4165c..a503cf519 100644 --- a/appbuilder/core/components/plant_recognize/component.py +++ b/appbuilder/core/components/plant_recognize/component.py @@ -167,8 +167,6 @@ def _recognize_w_post_process(self, img_path, img_url, file_urls): 返回: str: 植物识别结果,包括识别出的动物类别和相应的置信度信息 """ - if not img_path and not img_url: - return "Image path and image url cannot be all empty" req = PlantRecognitionRequest() if img_path in file_urls: req.url = file_urls[img_path] @@ -176,10 +174,7 @@ def _recognize_w_post_process(self, img_path, img_url, file_urls): req.url = img_url req.top_num = 6 req.baike_num = 0 - try: - result = self.__recognize(req) - except Exception as ex: - return "API call failed: {}".format(str(ex)) + result = self.__recognize(req) result_dict = proto.Message.to_dict(result) rec_res = "模型识别结果为:\n" for rec_info in result_dict['result']: