Ver Fonte

AI混合使用识别模型

zhangdongming há 1 semana atrás
pai
commit
688877d520
1 ficheiros alterados com 13 adições e 8 exclusões
  1. 13 8
      Controller/AiController.py

+ 13 - 8
Controller/AiController.py

@@ -120,13 +120,13 @@ class AiView(View):
             file_post_one = request_dict.get('fileOne', None)
             file_post_two = request_dict.get('fileTwo', None)
             file_post_three = request_dict.get('fileThree', None)
-            TIME_LOGGER.info(f'uid:{uid},图1:{file_post_one[:30]},图2:{file_post_two[:30]},图3:{file_post_three[:30]}')
 
             file_list = [file_post_one, file_post_two, file_post_three]
             del file_post_one, file_post_two, file_post_three
             if not all(file_list):
                 for k, val in enumerate(file_list):
                     if not val:
+                        TIME_LOGGER.error('{}缺少图片{}'.format(uid, k))
                         return response.json(444, '缺少第{k}张图'.format(k=k + 1))
             redis_obj = RedisObject(db=6)
             ai_key = f'PUSH:AI:{uid}:{channel}'
@@ -148,8 +148,10 @@ class AiView(View):
             if AiServiceQuery[0]['orders__payType'] == 10:  # AI首次体验前半个月调Rekognition
                 now_time = int(time.time())
                 add_time = AiServiceQuery[0]['addTime']
-                if (now_time - add_time) <= (3600 * 24 * 3):
+                if (now_time - add_time) <= (3600 * 24 * 2):
                     ai_server = 'rekognition'
+                elif (now_time - add_time) <= (3600 * 24 * 3):
+                    ai_server = 'novaLite'
 
             APP_NOTIFY_KEY = f'ASJ:NOTIFY:PUSH:{uid}:{channel}'  # 推送间隔缓存KEY
             push_cache_data = redis_obj.get_data(APP_NOTIFY_KEY)
@@ -159,9 +161,9 @@ class AiView(View):
 
             # APP推送提醒状态
             notify = self.is_ai_push(uid, notify_data) if is_push else is_push
-            nova_key = f'PUSH:NOVA:LITE:{uid}'
-            nova = redis_obj.get_data(nova_key)
-            if nova:  # AWS AI模型
+            # nova_key = f'PUSH:NOVA:LITE:{uid}'
+            # nova = redis_obj.get_data(nova_key)
+            if ai_server == 'novaLite':  # AWS AI模型
                 sage_maker = SageMakerAiObject()
 
                 # AI nova识别异步存表&推送
@@ -749,13 +751,16 @@ class AiView(View):
             return False
 
     @staticmethod
-    def async_detection_image_label(sage_maker,uid, n_time, uid_push_qs,
-                            channel, file_list, notify,detect_group):
+    def async_detection_image_label(sage_maker, uid, n_time, uid_push_qs,
+                                    channel, file_list, notify, detect_group):
+        images = file_list
         final_results = AiView.get_nova_tag_recognition(file_list, uid)
         if not final_results:
             return
         res = sage_maker.get_table_name(uid, final_results, detect_group)
-        sage_maker.save_push_message(uid, n_time, uid_push_qs, channel, res, file_list, notify)
+        for i in range(len(images)):
+            images[i] = images[i].replace(' ', '+')
+        sage_maker.save_push_message(uid, n_time, uid_push_qs, channel, res, images, notify)