Ver código fonte

update video rank

linfan 1 ano atrás
pai
commit
1931136e15
2 arquivos alterados com 21 adições e 10 exclusões
  1. 2 2
      rank_service.py
  2. 19 8
      video_rank.py

+ 2 - 2
rank_service.py

@@ -247,10 +247,10 @@ def get_tf_serving_sores(feature_dict):
     request_data_dict["inputs"] = inputs_data
     #print(request_data_dict)
     request_data= json.dumps(request_data_dict)
-    print(request_data)
+    #print(request_data)
     # 调用http接口
     result = request_post_data(config_.TF_SERVING_URL,request_data, timeout=(0.1, 1))
-    print("result:", result)
+    #print("result:", result)
     if result is None:
         print("result is None")
         log_.info('call tf serving error,types: {}')

+ 19 - 8
video_rank.py

@@ -637,7 +637,7 @@ def video_new_rank2(data, size, top_K, flow_pool_P, ab_code, mid, exp_config=Non
     if (ab_code == 60066 or ab_code == 60069 or ab_code == 60070 or ab_code == 60071) and len(rec_recall_vid_list)>0:
         video_static_info = redisObj.get_batch_key(day_vidKeys)
         video_hour_static_info = redisObj.get_batch_key(hour_vidKeys)
-        print("env_dict:", env_dict)
+        #print("env_dict:", env_dict)
         feature_dict = get_featurs(mid, data, size, top_K, flow_pool_P, rec_recall_vid_list,env_dict, video_static_info, video_hour_static_info)
         score_result = get_tf_serving_sores(feature_dict)
         if video_scores and len(video_scores)>0  and rec_recall_item_list and score_result and len(score_result) > 0\
@@ -646,19 +646,30 @@ def video_new_rank2(data, size, top_K, flow_pool_P, ab_code, mid, exp_config=Non
                 try:
                     if video_scores[i] is None and len(score_result[i])>0:
                         return_score = 0.000000001
-                        total_score = return_score * score_result[i][0]
+                        # sore_index :10 = model score
+                        if sort_index == 10:
+                            total_score = score_result[i][0]
+                        else:
+                            total_score = return_score * score_result[i][0]
                         rec_recall_item_list[i]['sort_score'] = total_score
                     else:
                         video_score_str = json.loads(video_scores[i])
-                        if len(video_score_str)>= sort_index and  len(video_score_str)>0:
-                            return_score = video_score_str[sort_index]
+                        # sore_index :10 = model score
+                        if sort_index == 10:
+                            total_score = score_result[i][0]
                         else:
-                            return_score = 0.000000001
-                        total_score = return_score * score_result[i][0]
+                            if len(video_score_str)>= sort_index and  len(video_score_str)>0:
+                                return_score = video_score_str[sort_index]
+                            else:
+                                return_score = 0.000000001
+                            total_score = return_score * score_result[i][0]
                         rec_recall_item_list[i]['sort_score'] = total_score
                 except Exception:
-                    return_score = 0.000000001
-                    total_score = return_score * 0.00000001
+                    if sort_index == 10:
+                        total_score = 0.00000001
+                    else:
+                        return_score = 0.000000001
+                        total_score = return_score * 0.00000001
                     rec_recall_item_list[i]['sort_score'] = total_score
                 rec_recall_item_list[i]['flag_call_service'] = 1
             rov_recall_rank = sorted(rec_recall_item_list, key=lambda k: k.get('sort_score', 0), reverse=True)