rambo hace 11 meses
padre
commit
bb1864b73b
Se han modificado 2 ficheros con 7 adiciones y 11 borrados
  1. 3 7
      python/api.py
  2. 4 4
      python/services/deal_cutout.py

+ 3 - 7
python/api.py

@@ -47,25 +47,21 @@ async def segmentImages(params: SegmentImages):
     if image_type == 1 and segment_type == 1:
         raise UnicornException("服装暂不支持精细化抠图")
     elif image_type == 1 and segment_type == 0:
-        deal_cutout_cloth = DealCloths()
-        deal_cutout_cloth.token = token
+        deal_cutout_cloth = DealCloths(token)
         # 服装抠图
         # need_cutout_images = service.check_need_cutout_images(file_path)
         deal_cutout_cloth.need_cutout_images = need_cutout_images
         deal_cutout_cloth.output_type = output_type
         result = deal_cutout_cloth.startDispose()
     elif image_type == 0 and segment_type == 1:
-        deal_cutout_mode = DealCutout()
-        deal_cutout_mode.token = token
+        deal_cutout_mode = DealCutout(token)
         # 通用-精细化抠图
         deal_cutout_mode.need_cutout_images = need_cutout_images
         deal_cutout_mode.output_type = output_type
         result = deal_cutout_mode.startDispose()
     elif image_type == 0 and segment_type == 0:
         # 通用-普通抠图
-        deal_cutout_mode = DealCutout()
-        deal_cutout_mode.token = token
-        deal_cutout_mode.need_cutout_images = need_cutout_images
+        deal_cutout_mode = DealCutout(token)
         deal_cutout_mode.output_type = output_type
         result = deal_cutout_mode.normalMode()
     return success({"result": result})

+ 4 - 4
python/services/deal_cutout.py

@@ -9,16 +9,16 @@ from .other.log import MyLogger
 
 class DealCutout:
 
-    def __init__(self):
+    def __init__(self, token):
         super().__init__()
         self.lock = threading.Lock()
         self.need_cutout_images = {}
+        self.token = token
         self.state = 2  # 1进行中 2停止
         self.get_online_data = GetOnlineData(self.token)
         self.is_upload_pic_num = 0
         self.is_deal_num = 0
         self.output_type = 0
-        self.token = None
         # 图片列表
         self.upload_pic_dict = {}
         self.logger = MyLogger().logger
@@ -67,11 +67,11 @@ class DealCutout:
 
 class DealCloths:
 
-    def __init__(self):
+    def __init__(self, token):
         super().__init__()
         self.lock = threading.Lock()
         self.need_cutout_images = {}
-        self.token = None
+        self.token = token
         self.output_type = 0
         self.state = 2  # 1进行中 2停止
         self.get_online_data = GetOnlineData(self.token)