deal_cutout.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import time
  2. from concurrent.futures import as_completed, ThreadPoolExecutor, wait
  3. import threading
  4. from .remove_bg_pixian import RemoveBgPiXian
  5. from .other.module_online_data import GetOnlineData
  6. from .deal_one_image import DealOneImage, DealOneImageBeforehand
  7. from .other.log import MyLogger
  8. class DealCutout:
  9. def __init__(self):
  10. super().__init__()
  11. self.lock = threading.Lock()
  12. self.need_cutout_images = {}
  13. self.state = 2 # 1进行中 2停止
  14. self.get_online_data = GetOnlineData(self.token)
  15. self.is_upload_pic_num = 0
  16. self.is_deal_num = 0
  17. self.output_type = 0
  18. self.token = None
  19. # 图片列表
  20. self.upload_pic_dict = {}
  21. self.logger = MyLogger().logger
  22. def startDispose(self):
  23. self.get_online_data.refresh_headers()
  24. num = 0
  25. result_array = []
  26. for image_data in self.need_cutout_images:
  27. num += 1
  28. upload_pic_dict = {}
  29. upload_pic_dict = DealOneImageBeforehand(
  30. image_data=image_data,
  31. lock=self.lock,
  32. windows=self,
  33. num=num,
  34. token=self.token,
  35. ).run(upload_pic_dict)
  36. result = DealOneImage(
  37. image_data=image_data,
  38. lock=self.lock,
  39. windows=self,
  40. num=num,
  41. token=self.token,
  42. ).run(image_data, upload_pic_dict)
  43. result_array.append(result)
  44. return result_array
  45. def normalMode(self):
  46. """普通模式"""
  47. self.get_online_data.refresh_headers()
  48. num = 0
  49. result_array = []
  50. for image_data in self.need_cutout_images:
  51. num += 1
  52. result = DealOneImageBeforehand(
  53. image_data=image_data,
  54. lock=self.lock,
  55. windows=self,
  56. num=num,
  57. token=self.token,
  58. ).get_image_cut_noraml(image_data)
  59. result_array.append(result)
  60. return result_array
  61. class DealCloths:
  62. def __init__(self):
  63. super().__init__()
  64. self.lock = threading.Lock()
  65. self.need_cutout_images = {}
  66. self.token = None
  67. self.output_type = 0
  68. self.state = 2 # 1进行中 2停止
  69. self.get_online_data = GetOnlineData(self.token)
  70. self.is_upload_pic_num = 0
  71. self.is_deal_num = 0
  72. # 图片列表
  73. self.upload_pic_dict = {}
  74. self.logger = MyLogger().logger
  75. def startDispose(self):
  76. self.get_online_data.refresh_headers()
  77. num = 0
  78. result_array = []
  79. for image_data in self.need_cutout_images:
  80. num += 1
  81. upload_pic_dict = {}
  82. hand = DealOneImageBeforehand(
  83. image_data=image_data,
  84. lock=self.lock,
  85. windows=self,
  86. num=num,
  87. token=self.token,
  88. )
  89. upload_pic_dict = hand.get_image_cut_cloths(image_data)
  90. result_array.append(upload_pic_dict)
  91. return result_array