罗俊辉 1 éve
szülő
commit
eaa28fad0d
3 módosított fájl, 28 hozzáadás és 12 törlés
  1. 26 4
      applications/functions.py
  2. 1 8
      applications/routes.py
  3. 1 0
      async_app.py

+ 26 - 4
applications/functions.py

@@ -53,13 +53,35 @@ class ParamProcess(object):
             case "v1":
                 result = self.model_v1(features)
                 result = list(result)
-                return result
+                if result:
+                    obj = {
+                        "score": result[0],
+                        "benchmark": 0.06,
+                        "is_good_video": result[0] > 0.06
+                    }
+                else:
+                    obj = {
+                        "score": None,
+                        "benchmark": 0.06,
+                        "is_good_video": False
+                    }
+                return obj
             case "v2":
-                print("predict_data", features)
                 result = self.model_v2.predict(features)
-                print("predict", list(result))
                 result = list(result)
-                return result
+                if result:
+                    obj = {
+                        "score": result[0],
+                        "benchmark": 0.3,
+                        "is_good_video": result[0] > 0.3
+                    }
+                else:
+                    obj = {
+                        "score": None,
+                        "benchmark": 0.3,
+                        "is_good_video": False
+                    }
+                return obj
 
     async def process_label(self, params):
         """

+ 1 - 8
applications/routes.py

@@ -26,11 +26,4 @@ async def post_data():
     p = ParamProcess()
     data = await request.get_json()
     processed_data = await p.process(data)
-    if processed_data:
-        obj = processed_data[0]
-    else:
-        obj = None
-    r = {
-        'quality_score': obj
-    }
-    return jsonify(r)
+    return jsonify(processed_data)

+ 1 - 0
async_app.py

@@ -29,6 +29,7 @@ async def preload_jieba():
     :return:
     """
     jieba.initialize()
+    print("jieba 缓存加载完成")
 
 
 if __name__ == '__main__':