|
|
@@ -356,8 +356,12 @@ async def process_handle_detail(request: Request, params: HandlerDetail):
|
|
|
)
|
|
|
|
|
|
except UnicornException as e:
|
|
|
+ print("错误信息:", e)
|
|
|
+ print("错误发生在行号:", traceback.extract_tb(e.__traceback__)[0][1])
|
|
|
await _handle_exception(e.msg, handler_result_folder)
|
|
|
except Exception as e:
|
|
|
+ print("错误信息:", e)
|
|
|
+ print("错误发生在行号:", traceback.extract_tb(e.__traceback__)[0][1])
|
|
|
await _handle_exception(str(e), handler_result_folder)
|
|
|
|
|
|
return True
|
|
|
@@ -555,8 +559,8 @@ async def _process_scene_images(aigc_clazz, run_main, return_data_check_before_d
|
|
|
|
|
|
goods_dict = parserGoodsDict2Aigc(return_data_check_before_detail)
|
|
|
new_goods_dict = {}
|
|
|
-
|
|
|
- product_scene_total_progress = len(goods_dict.keys())
|
|
|
+ goods_art_counts ={key: len(value.get('货号资料', [])) for key, value in goods_dict.items()}
|
|
|
+ product_scene_total_progress = sum(goods_art_counts.values())
|
|
|
product_scene_finish_progress = 0
|
|
|
product_scene_error_progress = 0
|
|
|
|
|
|
@@ -574,37 +578,55 @@ async def _process_scene_images(aigc_clazz, run_main, return_data_check_before_d
|
|
|
msg_type="scene_progress",
|
|
|
progress=product_scene_progress
|
|
|
)
|
|
|
- for goods_art_no in goods_dict.keys():
|
|
|
- try:
|
|
|
- product_scene_finish_progress += 1
|
|
|
- folder = ""
|
|
|
- product_scene_progress = {
|
|
|
- "status": "正在处理",
|
|
|
- "goods_art_no": goods_art_no,
|
|
|
- "current": product_scene_finish_progress,
|
|
|
- "total": product_scene_total_progress,
|
|
|
- "error": product_scene_error_progress,
|
|
|
- "goods_art_no": goods_art_no,
|
|
|
- "folder": folder,
|
|
|
- }
|
|
|
-
|
|
|
- await sendAsyncMessage(
|
|
|
- msg="正在处理场景图",
|
|
|
- goods_arts=[goods_art_no],
|
|
|
- status="正在处理场景图",
|
|
|
- msg_type="scene_progress",
|
|
|
- progress=product_scene_progress
|
|
|
- )
|
|
|
- goods_art_dict_info = goods_dict[goods_art_no]
|
|
|
- first_goods_art_no_info = goods_art_dict_info.get("货号资料", [])[0]
|
|
|
- first_pics = first_goods_art_no_info.get("pics")
|
|
|
- ceshi_image_path = first_pics.get("侧视-抠图")
|
|
|
- save_root_path = ceshi_image_path.split("阴影图处理")[0]
|
|
|
- save_image_path = f"{save_root_path}场景图.jpg"
|
|
|
-
|
|
|
- if os.path.isfile(save_image_path):
|
|
|
- goods_art_dict_info["场景图"] = save_image_path
|
|
|
- new_goods_dict[goods_art_no] = goods_art_dict_info
|
|
|
+ for goods_art_no_info in goods_dict.keys():
|
|
|
+ goods_art_dict_info = goods_dict.get(goods_art_no_info,None)
|
|
|
+ new_goods_dict.setdefault(goods_art_no_info,goods_art_dict_info)
|
|
|
+ if goods_art_dict_info is None: continue
|
|
|
+ for idx_key,goods_art_dict_info_item in enumerate(goods_art_dict_info.get("货号资料", [])):
|
|
|
+ goods_art_no = goods_art_dict_info_item.get("货号")
|
|
|
+ try:
|
|
|
+ product_scene_finish_progress += 1
|
|
|
+ folder = ""
|
|
|
+ product_scene_progress = {
|
|
|
+ "status": "正在处理",
|
|
|
+ "goods_art_no": goods_art_no,
|
|
|
+ "current": product_scene_finish_progress,
|
|
|
+ "total": product_scene_total_progress,
|
|
|
+ "error": product_scene_error_progress,
|
|
|
+ "folder": folder,
|
|
|
+ }
|
|
|
+
|
|
|
+ await sendAsyncMessage(
|
|
|
+ msg="正在处理场景图",
|
|
|
+ goods_arts=[goods_art_no],
|
|
|
+ status="正在处理场景图",
|
|
|
+ msg_type="scene_progress",
|
|
|
+ progress=product_scene_progress
|
|
|
+ )
|
|
|
+ first_pics = goods_art_dict_info_item.get("pics")
|
|
|
+ ceshi_image_path = first_pics.get("侧视-抠图")
|
|
|
+ save_root_path = ceshi_image_path.split("阴影图处理")[0]
|
|
|
+ save_image_path = f"{save_root_path}场景图.jpg"
|
|
|
+ if os.path.isfile(save_image_path):
|
|
|
+ goods_art_dict_info_item["场景图"] = save_image_path
|
|
|
+ new_goods_dict[goods_art_no_info]["货号资料"][idx_key] = goods_art_dict_info_item
|
|
|
+ product_scene_progress["folder"] = save_image_path.replace("场景图.jpg", "")
|
|
|
+ await sendAsyncMessage(
|
|
|
+ msg="场景图处理完成",
|
|
|
+ goods_arts=[goods_art_no],
|
|
|
+ status="场景图处理完成",
|
|
|
+ msg_type="scene_progress",
|
|
|
+ progress=product_scene_progress
|
|
|
+ )
|
|
|
+ continue
|
|
|
+
|
|
|
+ aigc_clazz.center_paste_image(ceshi_image_path, save_image_path)
|
|
|
+ image_path = aigc_clazz.generateProductScene(
|
|
|
+ save_image_path, product_scene_prompt, save_image_path
|
|
|
+ )
|
|
|
+
|
|
|
+ goods_art_dict_info_item["场景图"] = image_path
|
|
|
+ new_goods_dict[goods_art_no_info]["货号资料"][idx_key] = goods_art_dict_info_item
|
|
|
product_scene_progress["folder"] = save_image_path.replace("场景图.jpg", "")
|
|
|
await sendAsyncMessage(
|
|
|
msg="场景图处理完成",
|
|
|
@@ -613,49 +635,31 @@ async def _process_scene_images(aigc_clazz, run_main, return_data_check_before_d
|
|
|
msg_type="scene_progress",
|
|
|
progress=product_scene_progress
|
|
|
)
|
|
|
- continue
|
|
|
|
|
|
- aigc_clazz.center_paste_image(ceshi_image_path, save_image_path)
|
|
|
- image_path = aigc_clazz.generateProductScene(
|
|
|
- save_image_path, product_scene_prompt, save_image_path
|
|
|
- )
|
|
|
-
|
|
|
- goods_art_dict_info["场景图"] = image_path
|
|
|
- new_goods_dict[goods_art_no] = goods_art_dict_info
|
|
|
- product_scene_progress["folder"] = save_image_path.replace("场景图.jpg", "")
|
|
|
- await sendAsyncMessage(
|
|
|
- msg="场景图处理完成",
|
|
|
- goods_arts=[goods_art_no],
|
|
|
- status="场景图处理完成",
|
|
|
- msg_type="scene_progress",
|
|
|
- progress=product_scene_progress
|
|
|
- )
|
|
|
-
|
|
|
- except Exception as e:
|
|
|
- goods_art_dict_info = goods_dict[goods_art_no]
|
|
|
- goods_art_dict_info["场景图"] = ""
|
|
|
- new_goods_dict[goods_art_no] = goods_art_dict_info
|
|
|
- print("场景图处理异常",e)
|
|
|
- os.remove(save_image_path)
|
|
|
- product_scene_finish_progress -= 1
|
|
|
- product_scene_error_progress += 1
|
|
|
-
|
|
|
- product_scene_progress = {
|
|
|
- "status": "处理失败",
|
|
|
- "goods_art_no": goods_art_no,
|
|
|
- "current": product_scene_finish_progress,
|
|
|
- "total": product_scene_total_progress,
|
|
|
- "error": product_scene_error_progress,
|
|
|
- "folder":""
|
|
|
- }
|
|
|
-
|
|
|
- await sendAsyncMessage(
|
|
|
- msg="场景图处理失败",
|
|
|
- goods_arts=[goods_art_no],
|
|
|
- status="场景图处理失败",
|
|
|
- msg_type="scene_progress",
|
|
|
- progress=product_scene_progress
|
|
|
- )
|
|
|
+ except Exception as e:
|
|
|
+ goods_art_dict_info_item["场景图"] = ""
|
|
|
+ new_goods_dict[goods_art_no_info]["货号资料"][idx_key] = goods_art_dict_info_item
|
|
|
+ print("场景图处理异常",e)
|
|
|
+ os.remove(save_image_path)
|
|
|
+ product_scene_finish_progress -= 1
|
|
|
+ product_scene_error_progress += 1
|
|
|
+
|
|
|
+ product_scene_progress = {
|
|
|
+ "status": "处理失败",
|
|
|
+ "goods_art_no": goods_art_no,
|
|
|
+ "current": product_scene_finish_progress,
|
|
|
+ "total": product_scene_total_progress,
|
|
|
+ "error": product_scene_error_progress,
|
|
|
+ "folder":""
|
|
|
+ }
|
|
|
+
|
|
|
+ await sendAsyncMessage(
|
|
|
+ msg="场景图处理失败",
|
|
|
+ goods_arts=[goods_art_no],
|
|
|
+ status="场景图处理失败",
|
|
|
+ msg_type="scene_progress",
|
|
|
+ progress=product_scene_progress
|
|
|
+ )
|
|
|
status_text = "处理完成" if product_scene_finish_progress > 0 else "处理失败"
|
|
|
product_scene_progress = {
|
|
|
"status": status_text,
|
|
|
@@ -671,7 +675,7 @@ async def _process_scene_images(aigc_clazz, run_main, return_data_check_before_d
|
|
|
msg_type="scene_progress",
|
|
|
progress=product_scene_progress
|
|
|
)
|
|
|
-
|
|
|
+ print("场景图 new_goods_dict",new_goods_dict)
|
|
|
if new_goods_dict:
|
|
|
return_data_check_before_detail["data"]["goods_no_dict"] = new_goods_dict
|
|
|
|
|
|
@@ -693,8 +697,8 @@ async def _process_model_images(aigc_clazz, run_main, return_data_check_before_d
|
|
|
|
|
|
goods_dict = parserGoodsDict2Aigc(return_data_check_before_detail)
|
|
|
new_goods_dict = {}
|
|
|
-
|
|
|
- upper_footer_total_progress = len(goods_dict.keys())
|
|
|
+ goods_art_counts ={key: len(value.get('货号资料', [])) for key, value in goods_dict.items()}
|
|
|
+ upper_footer_total_progress = sum(goods_art_counts.values())
|
|
|
upper_footer_finish_progress = 0
|
|
|
upper_footer_error_progress = 0
|
|
|
|
|
|
@@ -713,39 +717,67 @@ async def _process_model_images(aigc_clazz, run_main, return_data_check_before_d
|
|
|
progress=upper_footer_progress
|
|
|
)
|
|
|
|
|
|
- for goods_art_no in goods_dict.keys():
|
|
|
- upper_footer_finish_progress += 1
|
|
|
- folder = ""
|
|
|
- try:
|
|
|
- upper_footer_progress = {
|
|
|
- "status": "正在处理",
|
|
|
- "goods_art_no": goods_art_no,
|
|
|
- "current": upper_footer_finish_progress,
|
|
|
- "total": upper_footer_total_progress,
|
|
|
- "error": upper_footer_error_progress,
|
|
|
- "goods_art_no": goods_art_no,
|
|
|
- "folder": folder,
|
|
|
- }
|
|
|
-
|
|
|
- await sendAsyncMessage(
|
|
|
- msg="正在处理模特图",
|
|
|
- goods_arts=[goods_art_no],
|
|
|
- status="正在处理模特图",
|
|
|
- msg_type="upper_footer_progress",
|
|
|
- progress=upper_footer_progress
|
|
|
- )
|
|
|
- goods_art_dict_info = goods_dict[goods_art_no]
|
|
|
- first_goods_art_no_info = goods_art_dict_info.get("货号资料", [])[0]
|
|
|
- first_pics = first_goods_art_no_info.get("pics")
|
|
|
- gender = goods_art_dict_info.get("性别","女")
|
|
|
- model_id = man_id if "男" in gender else women_id
|
|
|
- ceshi_image_path = first_pics.get("侧视-抠图")
|
|
|
- save_root_path = ceshi_image_path.split("阴影图处理")[0]
|
|
|
- save_image_path = f"{save_root_path}模特图.jpg"
|
|
|
+ for goods_art_no_info in goods_dict.keys():
|
|
|
+ goods_art_dict_info = goods_dict.get(goods_art_no_info,None)
|
|
|
+ new_goods_dict.setdefault(goods_art_no_info,goods_art_dict_info)
|
|
|
+ if goods_art_dict_info is None: continue
|
|
|
+ for idx_key,goods_art_dict_info_item in enumerate(goods_art_dict_info.get("货号资料", [])):
|
|
|
+ goods_art_no = goods_art_dict_info_item.get("货号")
|
|
|
+ upper_footer_finish_progress += 1
|
|
|
+ folder = ""
|
|
|
+ try:
|
|
|
+ upper_footer_progress = {
|
|
|
+ "status": "正在处理",
|
|
|
+ "goods_art_no": goods_art_no,
|
|
|
+ "current": upper_footer_finish_progress,
|
|
|
+ "total": upper_footer_total_progress,
|
|
|
+ "error": upper_footer_error_progress,
|
|
|
+ "folder": folder,
|
|
|
+ }
|
|
|
+
|
|
|
+ await sendAsyncMessage(
|
|
|
+ msg="正在处理模特图",
|
|
|
+ goods_arts=[goods_art_no],
|
|
|
+ status="正在处理模特图",
|
|
|
+ msg_type="upper_footer_progress",
|
|
|
+ progress=upper_footer_progress
|
|
|
+ )
|
|
|
+ first_pics = goods_art_dict_info_item.get("pics")
|
|
|
+ ceshi_image_path = first_pics.get("侧视-抠图")
|
|
|
+ gender = goods_art_dict_info.get("性别","女")
|
|
|
+ model_id = man_id if "男" in gender else women_id
|
|
|
+ ceshi_image_path = first_pics.get("侧视-抠图")
|
|
|
+ save_root_path = ceshi_image_path.split("阴影图处理")[0]
|
|
|
+ save_image_path = f"{save_root_path}模特图.jpg"
|
|
|
+
|
|
|
+ if os.path.isfile(save_image_path):
|
|
|
+ goods_art_dict_info_item["模特图"] = save_image_path
|
|
|
+ new_goods_dict[goods_art_no_info]["货号资料"][idx_key] = goods_art_dict_info_item
|
|
|
+ upper_footer_progress["folder"] = save_image_path.replace("模特图.jpg", "")
|
|
|
+ await sendAsyncMessage(
|
|
|
+ msg="模特图处理成功",
|
|
|
+ goods_arts=[goods_art_no],
|
|
|
+ status="模特图处理成功",
|
|
|
+ msg_type="upper_footer_progress",
|
|
|
+ progress=upper_footer_progress
|
|
|
+ )
|
|
|
+ continue
|
|
|
+
|
|
|
+ shutil.copy(ceshi_image_path, save_image_path)
|
|
|
|
|
|
- if os.path.isfile(save_image_path):
|
|
|
- goods_art_dict_info["模特图"] = save_image_path
|
|
|
- new_goods_dict[goods_art_no] = goods_art_dict_info
|
|
|
+ # 添加超时控制
|
|
|
+ with concurrent.futures.ThreadPoolExecutor() as executor:
|
|
|
+ future = executor.submit(
|
|
|
+ aigc_clazz.generateUpperShoes,
|
|
|
+ save_image_path,
|
|
|
+ model_id,
|
|
|
+ save_image_path
|
|
|
+ )
|
|
|
+ # 设置70秒超时
|
|
|
+ image_path = future.result(timeout=70)
|
|
|
+
|
|
|
+ goods_art_dict_info_item["模特图"] = image_path
|
|
|
+ new_goods_dict[goods_art_no_info]["货号资料"][idx_key] = goods_art_dict_info_item
|
|
|
upper_footer_progress["folder"] = save_image_path.replace("模特图.jpg", "")
|
|
|
await sendAsyncMessage(
|
|
|
msg="模特图处理成功",
|
|
|
@@ -754,63 +786,29 @@ async def _process_model_images(aigc_clazz, run_main, return_data_check_before_d
|
|
|
msg_type="upper_footer_progress",
|
|
|
progress=upper_footer_progress
|
|
|
)
|
|
|
- continue
|
|
|
|
|
|
- shutil.copy(ceshi_image_path, save_image_path)
|
|
|
-
|
|
|
- # 添加超时控制
|
|
|
- with concurrent.futures.ThreadPoolExecutor() as executor:
|
|
|
- future = executor.submit(
|
|
|
- aigc_clazz.generateUpperShoes,
|
|
|
- save_image_path,
|
|
|
- model_id,
|
|
|
- save_image_path
|
|
|
+ except (concurrent.futures.TimeoutError, Exception) as e:
|
|
|
+ os.remove(save_image_path)
|
|
|
+ upper_footer_finish_progress-=1
|
|
|
+ upper_footer_error_progress += 1
|
|
|
+ goods_art_dict_info_item["模特图"] = ""
|
|
|
+ new_goods_dict[goods_art_no_info]["货号资料"][idx_key] = goods_art_dict_info_item
|
|
|
+ upper_footer_progress = {
|
|
|
+ "status": "处理失败",
|
|
|
+ "goods_art_no": goods_art_no,
|
|
|
+ "current": upper_footer_finish_progress,
|
|
|
+ "total": upper_footer_total_progress,
|
|
|
+ "error": upper_footer_error_progress,
|
|
|
+ "folder":""
|
|
|
+ }
|
|
|
+
|
|
|
+ await sendAsyncMessage(
|
|
|
+ msg="模特图处理失败",
|
|
|
+ goods_arts=[goods_art_no],
|
|
|
+ status="模特图处理失败",
|
|
|
+ msg_type="upper_footer_progress",
|
|
|
+ progress=upper_footer_progress
|
|
|
)
|
|
|
- # 设置70秒超时
|
|
|
- image_path = future.result(timeout=70)
|
|
|
-
|
|
|
- goods_art_dict_info["模特图"] = image_path
|
|
|
- new_goods_dict[goods_art_no] = goods_art_dict_info
|
|
|
-
|
|
|
- # upper_footer_progress = {
|
|
|
- # "status": "正在处理",
|
|
|
- # "goods_art_no": goods_art_no,
|
|
|
- # "current": upper_footer_finish_progress,
|
|
|
- # "total": upper_footer_total_progress,
|
|
|
- # "error": upper_footer_error_progress
|
|
|
- # }
|
|
|
- upper_footer_progress["folder"] = save_image_path.replace("模特图.jpg", "")
|
|
|
- await sendAsyncMessage(
|
|
|
- msg="模特图处理成功",
|
|
|
- goods_arts=[goods_art_no],
|
|
|
- status="模特图处理成功",
|
|
|
- msg_type="upper_footer_progress",
|
|
|
- progress=upper_footer_progress
|
|
|
- )
|
|
|
-
|
|
|
- except (concurrent.futures.TimeoutError, Exception) as e:
|
|
|
- os.remove(save_image_path)
|
|
|
- upper_footer_finish_progress-=1
|
|
|
- upper_footer_error_progress += 1
|
|
|
- goods_art_dict_info = goods_dict[goods_art_no]
|
|
|
- goods_art_dict_info["模特图"] = ""
|
|
|
- new_goods_dict[goods_art_no] = goods_art_dict_info
|
|
|
- upper_footer_progress = {
|
|
|
- "status": "处理失败",
|
|
|
- "goods_art_no": goods_art_no,
|
|
|
- "current": upper_footer_finish_progress,
|
|
|
- "total": upper_footer_total_progress,
|
|
|
- "error": upper_footer_error_progress,
|
|
|
- "folder":""
|
|
|
- }
|
|
|
-
|
|
|
- await sendAsyncMessage(
|
|
|
- msg="模特图处理失败",
|
|
|
- goods_arts=[goods_art_no],
|
|
|
- status="模特图处理失败",
|
|
|
- msg_type="upper_footer_progress",
|
|
|
- progress=upper_footer_progress
|
|
|
- )
|
|
|
status_text = "处理完成" if upper_footer_finish_progress > 0 else "处理失败"
|
|
|
upper_footer_progress = {
|
|
|
"status": status_text,
|