diff --git a/app/api/api_attribute_retrieve.py b/app/api/api_attribute_retrieve.py index 7a14e9d..d9b210c 100644 --- a/app/api/api_attribute_retrieve.py +++ b/app/api/api_attribute_retrieve.py @@ -1,5 +1,6 @@ import json import logging + from fastapi import APIRouter, HTTPException from app.core.config import DEBUG @@ -16,6 +17,22 @@ logger = logging.getLogger() # 属性识别 @router.post("/attribute_recognition", response_model=ResponseModel) def attribute_recognition(request_item: list[AttributeRecognitionModel]): + """ + 获取sketch的属性,collar sleeve_length 等等 + 创建一个具有以下参数的请求体: + - **category**: sketch的类别 ,Dress + - **colony**: 服装类别,男装或女装 + - **sketch_img_url**: 被提取属性的S3或minio url地址 + + 示例参数: + [ + { + "category": "Dress", + "colony": "Female", + "sketch_img_url": "aida-users/89/sketchboard/female/Dress/ae976103-d7ec-4eed-b5d1-3e5f04d8be26.jpg" + } + ] + """ try: logger.info(f"attribute_recognition request item is : @@@@@@:{request_item}") if DEBUG: @@ -33,6 +50,20 @@ def attribute_recognition(request_item: list[AttributeRecognitionModel]): # 类别识别 @router.post("/category_recognition") def category_recognition(request_item: list[CategoryRecognitionModel]): + """ + 获取sketch的类别,dress blouse 等等 + 创建一个具有以下参数的请求体: + - **colony**: 服装类别,male或Female + - **sketch_img_url**: 被提取sketch类别的S3或minio url地址 + + 示例参数: + [ + { + "colony": "Female", + "sketch_img_url": "aida-users/89/sketchboard/female/Dress/ae976103-d7ec-4eed-b5d1-3e5f04d8be26.jpg" + } + ] + """ try: logger.info(f"category_recognition request item is : @@@@@@:{request_item}") service = CategoryRecognition(request_data=request_item) diff --git a/app/api/api_chat_robot.py b/app/api/api_chat_robot.py index dccba9a..6f3da16 100644 --- a/app/api/api_chat_robot.py +++ b/app/api/api_chat_robot.py @@ -1,6 +1,6 @@ import json import logging -import time + from fastapi import APIRouter, HTTPException from app.schemas.chat_robot import ChatRobotModel @@ -13,6 +13,22 @@ logger = logging.getLogger() @router.post("/chat_robot") def chat_robot(request_data: ChatRobotModel): + """ + 对话机器人 + 创建一个具有以下参数的请求体: + - **gender**: 服装类别 + - **message**: 消息 + - **session_id**: 会话id + - **user_id**: 用户id + + 示例参数: + { + "gender": "male", + "message": "你好", + "session_id": "string-89", + "user_id": 89 + } + """ try: logger.info(f"chat_robot request item is : @@@@@@:{request_data}") data = chat(post_data=request_data) diff --git a/app/api/api_design.py b/app/api/api_design.py index ef0e085..ec618cc 100644 --- a/app/api/api_design.py +++ b/app/api/api_design.py @@ -15,6 +15,92 @@ logger = logging.getLogger() @router.post("/design") def design(request_data: DesignModel): + """ + 创建一个具有以下参数的请求体: + 示例参数: + { + "objects": [ + { + "basic": { + "body_point_test": { + "waistband_right": [ + 203, + 249 + ], + "hand_point_right": [ + 229, + 343 + ], + "waistband_left": [ + 119, + 248 + ], + "hand_point_left": [ + 97, + 343 + ], + "shoulder_left": [ + 108, + 107 + ], + "shoulder_right": [ + 212, + 107 + ] + }, + "layer_order": true, + "scale_bag": 0.7, + "scale_earrings": 0.16, + "self_template": true, + "single_overall": "overall", + "switch_category": "" + }, + "items": [ + { + "businessId": 255303, + "color": "139 148 156", + "image_id": 95159, + "offset": [ + 0, + 0 + ], + "path": "aida-users/89/sketch/c89d75f3-581f-4edd-9f8e-b08e84a2cbe7-3-89.png", + "print": { + "IfSingle": false, + "location": [ + [ + 512.0, + 512.0 + ] + ], + "print_angle_list": [ + 0.0 + ], + "print_path_list": [ + "aida-users/89/print/468643b4-bc2d-41b2-9a16-79766606a2db-3-89.png" + ], + "print_scale_list": [ + 1.0 + ] + }, + "priority": 10, + "resize_scale": [ + 1.0, + 1.0 + ], + "type": "Dress" + }, + { + "body_path": "aida-sys-image/models/female/2e4815b9-1191-419d-94ed-5771239ca4a5.png", + "image_id": 67277, + "type": "Body" + } + ] + } + ], + "process_id": "89" + } + """ try: logger.info(f"design request item is : @@@@@@:{request_data.dict()}") data = generate(request_data=request_data) @@ -27,6 +113,16 @@ def design(request_data: DesignModel): @router.post('/get_progress') def get_progress(request_data: DesignProgressModel): + """ + 获取design 进度 + 创建一个具有以下参数的请求体: + - **process_id**: 进度id + + 示例参数: + { + "process_id": "6878547032381675" + } + """ try: logger.info(f"get_progress request item is : @@@@@@:{request_data.dict()}") process_id = request_data.process_id @@ -43,6 +139,16 @@ def get_progress(request_data: DesignProgressModel): @router.post('/model_process') def model_process(request_data: ModelProgressModel): + """ + 获取模特图片预处理 + 创建一个具有以下参数的请求体: + - **model_path**: 模特图片的minio或s3 url地址 + + 示例参数: + { + "model_path": "aida-users/10/models/female/9c788f5b-b8c7-424c-b149-025aeb0bda51model.jpg" + } + """ try: logger.info(f"model_process request item is : @@@@@@:{request_data.dict()}") diff --git a/app/api/api_design_pre_processing.py b/app/api/api_design_pre_processing.py index bd87e00..f6946dc 100644 --- a/app/api/api_design_pre_processing.py +++ b/app/api/api_design_pre_processing.py @@ -1,6 +1,8 @@ import json import logging + from fastapi import APIRouter, HTTPException + from app.schemas.pre_processing import DesignPreProcessingModel from app.schemas.response_template import ResponseModel from app.service.design_pre_processing.service import DesignPreprocessing @@ -11,6 +13,22 @@ logger = logging.getLogger() @router.post("/design_pre_processing") def design_pre_processing(request_data: DesignPreProcessingModel): + """ + design 预处理 获取sketch的基本信息 + 创建一个具有以下参数的请求体: + - **sketches**: sketch url等信息 + + 示例参数: + { + "sketches": [ + { + "image_category": "dress", + "image_id": "107903", + "image_url": "aida-sys-image/images/female/dress/0628000000.jpg" + } + ] + } + """ try: logger.info(f"design_pre_processing request item is : @@@@@@:{request_data}") server = DesignPreprocessing() diff --git a/app/api/api_generate_image.py b/app/api/api_generate_image.py index 23fbb7f..3f3646f 100644 --- a/app/api/api_generate_image.py +++ b/app/api/api_generate_image.py @@ -18,6 +18,25 @@ logger = logging.getLogger() @router.post("/generate_image") def generate_image(request_item: GenerateImageModel, background_tasks: BackgroundTasks): + """ + 创建一个具有以下参数的请求体: + - **tasks_id**: 任务id 用于取消生成任务和获取生成结果 + - **prompt**: 想要生成图片的描述词 + - **image_url**: 图生图的输入,minio或S3 url 地址 + - **mode**: 生成模式,img2img或者txt2img + - **category**: 生成图片的类别,sketch print 等等 + - **gender**: 生成sketch专用,服装类别 + + 示例参数: + { + "tasks_id": "123-89", + "prompt": "skeleton sitting by the side of a river looking soulful, concert poster, 4k, artistic", + "image_url": "aida-collection-element/87/Printboard/842c09cf-7297-42d9-9e6e-9c17d4a13cb5.jpg", + "mode": "img2img", + "category": "sketch", + "gender": "male" + } + """ try: logger.info(f"generate_image request item is : @@@@@@:{request_item}") service = GenerateImage(request_item) @@ -45,6 +64,19 @@ def generate_image(tasks_id: str): @router.post("/generate_single_logo") def generate_single_logo(request_item: GenerateSingleLogoImageModel, background_tasks: BackgroundTasks): + """ + 创建一个具有以下参数的请求体: + - **tasks_id**: 任务id 用于取消生成任务和获取生成结果 + - **prompt**: 想要生成图片的描述词 + - **seed**: 固定的prompt和固定的seed 每次的生成结果都是一样的 + + 示例参数: + { + "tasks_id": "123-89", + "prompt": "an apple", + "seed": "2" + } + """ try: logger.info(f"generate_single_logo request item is : @@@@@@:{request_item}") service = GenerateSingleLogoImage(request_item) @@ -72,6 +104,19 @@ def generate_single_logo_image(tasks_id: str): @router.post("/generate_product_image") def generate_product_image(request_item: GenerateProductImageModel, background_tasks: BackgroundTasks): + """ + 创建一个具有以下参数的请求体: + - **tasks_id**: 任务id 用于取消生成任务和获取生成结果 + - **prompt**: 想要生成图片的描述词 + - **image_url**: 被生成图片的S3或minio url地址 + + 示例参数: + { + "tasks_id": "123-89", + "prompt": "the best quality, masterpiece. detailed, high-res, simple background, studio photography, extremely detailed, updo, detailed face, face, close-up, HDR, UHD, 8K realistic, Highly detailed, simple background, Studio lighting", + "image_url": "aida-results/result_00097282-ebb2-11ee-a822-b48351119060.png" + } + """ try: logger.info(f"generate_product_image request item is : @@@@@@:{request_item}") service = GenerateProductImage(request_item) @@ -99,6 +144,19 @@ def generate_product_image(tasks_id: str): @router.post("/generate_relight_image") def generate_relight_image(request_item: GenerateProductImageModel, background_tasks: BackgroundTasks): + """ + 创建一个具有以下参数的请求体: + - **tasks_id**: 任务id 用于取消生成任务和获取生成结果 + - **prompt**: 想要生成图片的描述词 + - **image_url**: 被生成图片的S3或minio url地址 + + 示例参数: + { + "tasks_id": "123-89", + "prompt": "beautiful woman, detailed face, sunshine, outdoor, warm atmosphere", + "image_url": "aida-results/result_0000b606-1902-11ef-9424-0242ac180002.png" + } + """ try: logger.info(f"generate_relight_image request item is : @@@@@@:{request_item}") service = GenerateRelightImage(request_item) diff --git a/app/api/api_prompt_generation.py b/app/api/api_prompt_generation.py index 292ad2e..c7bcbcd 100644 --- a/app/api/api_prompt_generation.py +++ b/app/api/api_prompt_generation.py @@ -14,6 +14,16 @@ logger = logging.getLogger() @router.post("/translateToEN") def prompt_generation(request_data: PromptGenerationImageModel): + """ + 翻译prompt接口 + 创建一个具有以下参数的请求体: + - **text**: 待翻译语句 + + 示例参数: + { + "text": "你好" + } + """ try: logger.info(f"prompt_generation request item is : @@@@@@:{request_data}") data = translate_to_en(request_data.text) diff --git a/app/api/api_super_resolution.py b/app/api/api_super_resolution.py index 7928309..82b58f4 100644 --- a/app/api/api_super_resolution.py +++ b/app/api/api_super_resolution.py @@ -13,6 +13,19 @@ logger = logging.getLogger() @router.post("/super_resolution") def super_resolution(request_item: SuperResolutionModel, background_tasks: BackgroundTasks): + """ + 创建一个具有以下参数的请求体: + - **sr_image_url**: 超分图片的minio或s3 url地址 + - **sr_xn**: 超分的倍数,只接受2或4 + - **sr_tasks_id**: 任务id 用于取消超分任务和获取超分结果 + + 示例参数: + { + "sr_image_url": "aida-sys-image/images/female/blouse/0628000098.jpg", + "sr_xn": 2, + "sr_tasks_id": "12341556-89" + } + """ try: logger.info(f"super_resolution request item is : @@@@@@:{request_item}") service = SuperResolution(request_item) diff --git a/app/core/config.py b/app/core/config.py index cfc04f5..9e89e47 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -19,7 +19,7 @@ class Settings(BaseSettings): LOGGING_CONFIG_FILE = os.path.join(BASE_DIR, 'logging_env.py') -OSS = "minio" +OSS = "S3" DEBUG = False if DEBUG: LOGS_PATH = "logs/" diff --git a/app/service/design/design_request.json b/app/service/design/design_request.json deleted file mode 100644 index 5551b82..0000000 --- a/app/service/design/design_request.json +++ /dev/null @@ -1,101 +0,0 @@ -{ - "objects": [ - { - "basic": { - "body_point": { - "waistband_right": [ - 1081, - 1318 - ], - "hand_point_right": [ - 1200, - 1857 - ], - "waistband_left": [ - 639, - 1315 - ], - "hand_point_left": [ - 493, - 1808 - ], - "shoulder_left": [ - 556, - 582 - ], - "shoulder_right": [ - 1130, - 576 - ] - }, - "layer_order": false, - "scale_bag": 0.7, - "scale_earrings": 0.16, - "self_template": true, - "single_overall": "overall", - "switch_category": "" - }, - "items": [ - { - "color": "151 78 78", - "icon": "none", - "image_id": 67315, - "offset": [ - 1, - 1 - ], - "path": "aida-sys-image/images/female/trousers/0628000325.jpg", - "print": { - "IfSingle": false, - "print_path_list": [] - }, - "resize_scale": 1.0, - "type": "Trousers" - }, - { - "color": "151 78 78", - "icon": "none", - "image_id": 92912, - "offset": [ - 1, - 1 - ], - "path": "aida-sys-image/images/female/blouse/0825001943.jpg", - "print": { - "IfSingle": false, - "print_path_list": [] - }, - "resize_scale": 1.0, - "type": "Blouse" - }, - { - "color": "151 78 78", - "icon": "none", - "image_id": 91430, - "offset": [ - 1, - 1 - ], - "path": "aida-sys-image/images/female/outwear/0825000856.jpg", - "print": { - "IfSingle": false, - "print_path_list": [] - }, - "resize_scale": 1.0, - "type": "Outwear" - }, - { - "body_path": "aida-users/89/models/female/5d39394e-9809-43c2-80b8-4e96497b1974.png", - "image_id": 69331, - "offset": [ - 1, - 1 - ], - "resize_scale": 1.0, - "type": "Body" - } - ] - } - ], - "process_id": "7296013643475027" -} \ No newline at end of file diff --git a/app/service/design/design_request_2.json b/app/service/design/design_request_2.json deleted file mode 100644 index 51b607a..0000000 --- a/app/service/design/design_request_2.json +++ /dev/null @@ -1,684 +0,0 @@ -{ - "objects": [ - { - "basic": { - "body_point_test": { - "waistband_right": [ - 1081, - 1318 - ], - "hand_point_right": [ - 1200, - 1857 - ], - "waistband_left": [ - 639, - 1315 - ], - "hand_point_left": [ - 493, - 1808 - ], - "shoulder_left": [ - 556, - 582 - ], - "shoulder_right": [ - 1130, - 576 - ] - }, - "layer_order": false, - "scale_bag": 0.7, - "scale_earrings": 0.16, - "self_template": true, - "single_overall": "overall", - "switch_category": "" - }, - "items": [ - { - "color": "151 78 78", - "icon": "none", - "image_id": 67315, - "offset": [ - 1, - 1 - ], - "path": "aida-sys-image/images/female/trousers/0628000325.jpg", - "print": { - "IfSingle": false, - "print_path_list": [] - }, - "resize_scale": 1.0, - "type": "Trousers" - }, - { - "color": "151 78 78", - "icon": "none", - "image_id": 92912, - "offset": [ - 1, - 1 - ], - "path": "aida-sys-image/images/female/blouse/0825001943.jpg", - "print": { - "IfSingle": false, - "print_path_list": [] - }, - "resize_scale": 1.0, - "type": "Blouse" - }, - { - "color": "151 78 78", - "icon": "none", - "image_id": 91430, - "offset": [ - 1, - 1 - ], - "path": "aida-sys-image/images/female/outwear/0825000856.jpg", - "print": { - "IfSingle": false, - "print_path_list": [] - }, - "resize_scale": 1.0, - "type": "Outwear" - }, - { - "body_path": "aida-users/89/models/female/5d39394e-9809-43c2-80b8-4e96497b1974.png", - "image_id": 69331, - "offset": [ - 1, - 1 - ], - "resize_scale": 1.0, - "type": "Body" - } - ] - } - , - { - "basic": { - "body_point_test": { - "waistband_right": [ - 1081, - 1318 - ], - "hand_point_right": [ - 1200, - 1857 - ], - "waistband_left": [ - 639, - 1315 - ], - "hand_point_left": [ - 493, - 1808 - ], - "shoulder_left": [ - 556, - 582 - ], - "shoulder_right": [ - 1130, - 576 - ] - }, - "layer_order": false, - "scale_bag": 0.7, - "scale_earrings": 0.16, - "self_template": true, - "single_overall": "overall", - "switch_category": "" - }, - "items": [ - { - "color": "151 78 78", - "icon": "none", - "image_id": 92913, - "offset": [ - 1, - 1 - ], - "path": "aida-sys-image/images/female/dress/826000033.jpg", - "print": { - "IfSingle": false, - "print_path_list": [] - }, - "resize_scale": 1.0, - "type": "Dress" - }, - { - "body_path": "aida-users/89/models/female/5d39394e-9809-43c2-80b8-4e96497b1974.png", - "image_id": 69331, - "offset": [ - 1, - 1 - ], - "resize_scale": 1.0, - "type": "Body" - } - ] - } - , - { - "basic": { - "body_point_test": { - "waistband_right": [ - 1081, - 1318 - ], - "hand_point_right": [ - 1200, - 1857 - ], - "waistband_left": [ - 639, - 1315 - ], - "hand_point_left": [ - 493, - 1808 - ], - "shoulder_left": [ - 556, - 582 - ], - "shoulder_right": [ - 1130, - 576 - ] - }, - "layer_order": false, - "scale_bag": 0.7, - "scale_earrings": 0.16, - "self_template": true, - "single_overall": "overall", - "switch_category": "" - }, - "items": [ - { - "color": "151 78 78", - "icon": "none", - "image_id": 92914, - "offset": [ - 1, - 1 - ], - "path": "aida-sys-image/images/female/skirt/0902001788.jpg", - "print": { - "IfSingle": false, - "print_path_list": [] - }, - "resize_scale": 1.0, - "type": "Skirt" - }, - { - "color": "151 78 78", - "icon": "none", - "image_id": 92915, - "offset": [ - 1, - 1 - ], - "path": "aida-sys-image/images/female/blouse/0902003817.jpg", - "print": { - "IfSingle": false, - "print_path_list": [] - }, - "resize_scale": 1.0, - "type": "Blouse" - }, - { - "body_path": "aida-users/89/models/female/5d39394e-9809-43c2-80b8-4e96497b1974.png", - "image_id": 69331, - "offset": [ - 1, - 1 - ], - "resize_scale": 1.0, - "type": "Body" - } - ] - } - , - { - "basic": { - "body_point_test": { - "waistband_right": [ - 1081, - 1318 - ], - "hand_point_right": [ - 1200, - 1857 - ], - "waistband_left": [ - 639, - 1315 - ], - "hand_point_left": [ - 493, - 1808 - ], - "shoulder_left": [ - 556, - 582 - ], - "shoulder_right": [ - 1130, - 576 - ] - }, - "layer_order": false, - "scale_bag": 0.7, - "scale_earrings": 0.16, - "self_template": true, - "single_overall": "overall", - "switch_category": "" - }, - "items": [ - { - "color": "151 78 78", - "icon": "none", - "image_id": 92916, - "offset": [ - 1, - 1 - ], - "path": "aida-sys-image/images/female/skirt/skirt_p4_838.jpg", - "print": { - "IfSingle": false, - "print_path_list": [] - }, - "resize_scale": 1.0, - "type": "Skirt" - }, - { - "color": "151 78 78", - "icon": "none", - "image_id": 84210, - "offset": [ - 1, - 1 - ], - "path": "aida-sys-image/images/female/blouse/0916000703.jpg", - "print": { - "IfSingle": false, - "print_path_list": [] - }, - "resize_scale": 1.0, - "type": "Blouse" - }, - { - "body_path": "aida-users/89/models/female/5d39394e-9809-43c2-80b8-4e96497b1974.png", - "image_id": 69331, - "offset": [ - 1, - 1 - ], - "resize_scale": 1.0, - "type": "Body" - } - ] - } - , - { - "basic": { - "body_point_test": { - "waistband_right": [ - 1081, - 1318 - ], - "hand_point_right": [ - 1200, - 1857 - ], - "waistband_left": [ - 639, - 1315 - ], - "hand_point_left": [ - 493, - 1808 - ], - "shoulder_left": [ - 556, - 582 - ], - "shoulder_right": [ - 1130, - 576 - ] - }, - "layer_order": false, - "scale_bag": 0.7, - "scale_earrings": 0.16, - "self_template": true, - "single_overall": "overall", - "switch_category": "" - }, - "items": [ - { - "color": "151 78 78", - "icon": "none", - "image_id": 62041, - "offset": [ - 1, - 1 - ], - "path": "aida-sys-image/images/female/outwear/0902000232.jpg", - "print": { - "IfSingle": false, - "print_path_list": [] - }, - "resize_scale": 1.0, - "type": "Outwear" - }, - { - "color": "151 78 78", - "icon": "none", - "image_id": 67039, - "offset": [ - 1, - 1 - ], - "path": "aida-sys-image/images/female/blouse/0902002591.jpg", - "print": { - "IfSingle": false, - "print_path_list": [] - }, - "resize_scale": 1.0, - "type": "Blouse" - }, - { - "color": "151 78 78", - "icon": "none", - "image_id": 78016, - "offset": [ - 1, - 1 - ], - "path": "aida-sys-image/images/female/trousers/trousers_p4_302.jpg", - "print": { - "IfSingle": false, - "print_path_list": [] - }, - "resize_scale": 1.0, - "type": "Trousers" - }, - { - "body_path": "aida-users/89/models/female/5d39394e-9809-43c2-80b8-4e96497b1974.png", - "image_id": 69331, - "offset": [ - 1, - 1 - ], - "resize_scale": 1.0, - "type": "Body" - } - ] - } - , - { - "basic": { - "body_point_test": { - "waistband_right": [ - 1081, - 1318 - ], - "hand_point_right": [ - 1200, - 1857 - ], - "waistband_left": [ - 639, - 1315 - ], - "hand_point_left": [ - 493, - 1808 - ], - "shoulder_left": [ - 556, - 582 - ], - "shoulder_right": [ - 1130, - 576 - ] - }, - "layer_order": false, - "scale_bag": 0.7, - "scale_earrings": 0.16, - "self_template": true, - "single_overall": "overall", - "switch_category": "" - }, - "items": [ - { - "color": "151 78 78", - "icon": "none", - "image_id": 92917, - "offset": [ - 1, - 1 - ], - "path": "aida-sys-image/images/female/trousers/0902001403.jpg", - "print": { - "IfSingle": false, - "print_path_list": [] - }, - "resize_scale": 1.0, - "type": "Trousers" - }, - { - "color": "151 78 78", - "icon": "none", - "image_id": 92306, - "offset": [ - 1, - 1 - ], - "path": "aida-sys-image/images/female/blouse/0902001766.jpg", - "print": { - "IfSingle": false, - "print_path_list": [] - }, - "resize_scale": 1.0, - "type": "Blouse" - }, - { - "body_path": "aida-users/89/models/female/5d39394e-9809-43c2-80b8-4e96497b1974.png", - "image_id": 69331, - "offset": [ - 1, - 1 - ], - "resize_scale": 1.0, - "type": "Body" - } - ] - } - , - { - "basic": { - "body_point_test": { - "waistband_right": [ - 1081, - 1318 - ], - "hand_point_right": [ - 1200, - 1857 - ], - "waistband_left": [ - 639, - 1315 - ], - "hand_point_left": [ - 493, - 1808 - ], - "shoulder_left": [ - 556, - 582 - ], - "shoulder_right": [ - 1130, - 576 - ] - }, - "layer_order": false, - "scale_bag": 0.7, - "scale_earrings": 0.16, - "self_template": true, - "single_overall": "overall", - "switch_category": "" - }, - "items": [ - { - "color": "151 78 78", - "icon": "none", - "image_id": 86564, - "offset": [ - 1, - 1 - ], - "path": "aida-sys-image/images/female/blouse/0916000038.jpg", - "print": { - "IfSingle": false, - "print_path_list": [] - }, - "resize_scale": 1.0, - "type": "Blouse" - }, - { - "color": "151 78 78", - "icon": "none", - "image_id": 92918, - "offset": [ - 1, - 1 - ], - "path": "aida-sys-image/images/female/trousers/0628001561.jpeg", - "print": { - "IfSingle": false, - "print_path_list": [] - }, - "resize_scale": 1.0, - "type": "Trousers" - }, - { - "color": "151 78 78", - "icon": "none", - "image_id": 92919, - "offset": [ - 1, - 1 - ], - "path": "aida-sys-image/images/female/outwear/outwear_p3186.jpg", - "print": { - "IfSingle": false, - "print_path_list": [] - }, - "resize_scale": 1.0, - "type": "Outwear" - }, - { - "body_path": "aida-users/89/models/female/5d39394e-9809-43c2-80b8-4e96497b1974.png", - "image_id": 69331, - "offset": [ - 1, - 1 - ], - "resize_scale": 1.0, - "type": "Body" - } - ] - } - , - { - "basic": { - "body_point_test": { - "waistband_right": [ - 1081, - 1318 - ], - "hand_point_right": [ - 1200, - 1857 - ], - "waistband_left": [ - 639, - 1315 - ], - "hand_point_left": [ - 493, - 1808 - ], - "shoulder_left": [ - 556, - 582 - ], - "shoulder_right": [ - 1130, - 576 - ] - }, - "layer_order": false, - "scale_bag": 0.7, - "scale_earrings": 0.16, - "self_template": true, - "single_overall": "overall", - "switch_category": "" - }, - "items": [ - { - "color": "151 78 78", - "icon": "none", - "image_id": 67009, - "offset": [ - 1, - 1 - ], - "path": "aida-sys-image/images/female/blouse/0902002051.jpg", - "print": { - "IfSingle": false, - "print_path_list": [] - }, - "resize_scale": 1.0, - "type": "Blouse" - }, - { - "color": "151 78 78", - "icon": "none", - "image_id": 85028, - "offset": [ - 1, - 1 - ], - "path": "aida-sys-image/images/female/skirt/903000142.jpg", - "print": { - "IfSingle": false, - "print_path_list": [] - }, - "resize_scale": 1.0, - "type": "Skirt" - }, - { - "body_path": "aida-users/89/models/female/5d39394e-9809-43c2-80b8-4e96497b1974.png", - "image_id": 69331, - "offset": [ - 1, - 1 - ], - "resize_scale": 1.0, - "type": "Body" - } - ] - } - ], - "process_id": "7296013643475027" -} \ No newline at end of file diff --git a/app/service/design/fastapi_request.json b/app/service/design/fastapi_request.json index f578079..8c27a56 100644 --- a/app/service/design/fastapi_request.json +++ b/app/service/design/fastapi_request.json @@ -1,69 +1,771 @@ { - "basic": { - "body_point": { - "waistband_right": [ - 1081, - 1318 - ], - "hand_point_right": [ - 1200, - 1857 - ], - "waistband_left": [ - 639, - 1315 - ], - "hand_point_left": [ - 493, - 1808 - ], - "shoulder_left": [ - 556, - 582 - ], - "shoulder_right": [ - 1130, - 576 - ] - }, - "layer_order": false, - "scale_bag": 0.7, - "scale_earrings": 0.16, - "self_template": true, - "single_overall": "single", - "switch_category": "Trousers", - "body_path": "aida-users/89/models/female/5d39394e-9809-43c2-80b8-4e96497b1974.png" - }, - "item": [ - { - "color": "151 78 78", - "image_id": "67315", - "offset": [ - 1, - 1 - ], - "path": "aida-sys-image/images/female/trousers/0628000325.jpg", - "print": { - "if_single": false, - "print_path_list": [] - }, - "resize_scale": 1.0, - "type": "Trousers" - }, - { - "color": "151 78 78", - "path": "aida-users/89/models/female/5d39394e-9809-43c2-80b8-4e96497b1974.png", - "image_id": 69331, - "offset": [ - 1, - 1 - ], - "print": { - "if_single": false, - "print_path_list": [] - }, - "resize_scale": 1.0, - "type": "Body" - } - ] + "objects": [ + { + "basic": { + "body_point_test": { + "waistband_right": [ + 336, + 264 + ], + "hand_point_right": [ + 350, + 303 + ], + "waistband_left": [ + 245, + 274 + ], + "hand_point_left": [ + 219, + 315 + ], + "shoulder_left": [ + 227, + 155 + ], + "shoulder_right": [ + 338, + 149 + ] + }, + "layer_order": false, + "scale_bag": 0.7, + "scale_earrings": 0.16, + "self_template": true, + "single_overall": "overall", + "switch_category": "" + }, + "items": [ + { + "businessId": 493827, + "color": "127 61 21", + "elementId": 493827, + "icon": "none", + "image_id": 110201, + "offset": [ + 1, + 1 + ], + "path": "aida-users/31/sketch/62302527-2910-4740-808d-2cb8221daa34-3-31.png", + "print": { + "IfSingle": false, + "print_path_list": [] + }, + "resize_scale": [ + 1.0, + 1.0 + ], + "type": "Dress" + }, + { + "body_path": "aida-users/31/models/female/845046c7-4f62-4f54-a4a9-c26d49c6969335b5b3a9-d335-4871-a46c-3cc3caf07da259629dfd1f1f555a2e2a9def7e719366.png", + "image_id": 82966, + "offset": [ + 1, + 1 + ], + "resize_scale": [ + 1.0, + 1.0 + ], + "type": "Body" + } + ] + }, + { + "basic": { + "body_point_test": { + "waistband_right": [ + 336, + 264 + ], + "hand_point_right": [ + 350, + 303 + ], + "waistband_left": [ + 245, + 274 + ], + "hand_point_left": [ + 219, + 315 + ], + "shoulder_left": [ + 227, + 155 + ], + "shoulder_right": [ + 338, + 149 + ] + }, + "layer_order": false, + "scale_bag": 0.7, + "scale_earrings": 0.16, + "self_template": true, + "single_overall": "overall", + "switch_category": "" + }, + "items": [ + { + "color": "27 25 23", + "icon": "none", + "image_id": 110202, + "offset": [ + 1, + 1 + ], + "path": "aida-sys-image/images/female/skirt/0916000602.jpg", + "print": { + "IfSingle": false, + "print_path_list": [] + }, + "resize_scale": [ + 1.0, + 1.0 + ], + "type": "Skirt" + }, + { + "businessId": 493825, + "color": "229 214 200", + "elementId": 493825, + "icon": "none", + "image_id": 107101, + "offset": [ + 1, + 1 + ], + "path": "aida-users/31/sketchboard/female/Blouse/de8f5656-d7ae-4642-bc90-f7f9d85da09b.jpg", + "print": { + "IfSingle": false, + "print_path_list": [] + }, + "resize_scale": [ + 1.0, + 1.0 + ], + "type": "Blouse" + }, + { + "businessId": 493824, + "color": "76 124 124", + "elementId": 493824, + "icon": "none", + "image_id": 104522, + "offset": [ + 1, + 1 + ], + "path": "aida-users/31/sketch/3e82214a-0191-11ef-96d2-b48351119060_1.png", + "print": { + "IfSingle": false, + "print_path_list": [] + }, + "resize_scale": [ + 1.0, + 1.0 + ], + "type": "Outwear" + }, + { + "body_path": "aida-users/31/models/female/845046c7-4f62-4f54-a4a9-c26d49c6969335b5b3a9-d335-4871-a46c-3cc3caf07da259629dfd1f1f555a2e2a9def7e719366.png", + "image_id": 82966, + "offset": [ + 1, + 1 + ], + "resize_scale": [ + 1.0, + 1.0 + ], + "type": "Body" + } + ] + }, + { + "basic": { + "body_point_test": { + "waistband_right": [ + 336, + 264 + ], + "hand_point_right": [ + 350, + 303 + ], + "waistband_left": [ + 245, + 274 + ], + "hand_point_left": [ + 219, + 315 + ], + "shoulder_left": [ + 227, + 155 + ], + "shoulder_right": [ + 338, + 149 + ] + }, + "layer_order": false, + "scale_bag": 0.7, + "scale_earrings": 0.16, + "self_template": true, + "single_overall": "overall", + "switch_category": "" + }, + "items": [ + { + "color": "229 214 200", + "icon": "none", + "image_id": 110203, + "offset": [ + 1, + 1 + ], + "path": "aida-sys-image/images/female/blouse/0825001576.jpg", + "print": { + "IfSingle": false, + "print_path_list": [] + }, + "resize_scale": [ + 1.0, + 1.0 + ], + "type": "Blouse" + }, + { + "color": "76 124 124", + "icon": "none", + "image_id": 96071, + "offset": [ + 1, + 1 + ], + "path": "aida-sys-image/images/female/skirt/903000097.jpg", + "print": { + "IfSingle": false, + "print_path_list": [] + }, + "resize_scale": [ + 1.0, + 1.0 + ], + "type": "Skirt" + }, + { + "color": "209 125 29", + "icon": "none", + "image_id": 93798, + "offset": [ + 1, + 1 + ], + "path": "aida-sys-image/images/female/outwear/outwear_p4_561.jpg", + "print": { + "IfSingle": false, + "print_path_list": [] + }, + "resize_scale": [ + 1.0, + 1.0 + ], + "type": "Outwear" + }, + { + "body_path": "aida-users/31/models/female/845046c7-4f62-4f54-a4a9-c26d49c6969335b5b3a9-d335-4871-a46c-3cc3caf07da259629dfd1f1f555a2e2a9def7e719366.png", + "image_id": 82966, + "offset": [ + 1, + 1 + ], + "resize_scale": [ + 1.0, + 1.0 + ], + "type": "Body" + } + ] + }, + { + "basic": { + "body_point_test": { + "waistband_right": [ + 336, + 264 + ], + "hand_point_right": [ + 350, + 303 + ], + "waistband_left": [ + 245, + 274 + ], + "hand_point_left": [ + 219, + 315 + ], + "shoulder_left": [ + 227, + 155 + ], + "shoulder_right": [ + 338, + 149 + ] + }, + "layer_order": false, + "scale_bag": 0.7, + "scale_earrings": 0.16, + "self_template": true, + "single_overall": "overall", + "switch_category": "" + }, + "items": [ + { + "businessId": 493824, + "color": "209 125 29", + "elementId": 493824, + "icon": "none", + "image_id": 104522, + "offset": [ + 1, + 1 + ], + "path": "aida-users/31/sketch/3e82214a-0191-11ef-96d2-b48351119060_1.png", + "print": { + "IfSingle": false, + "print_path_list": [] + }, + "resize_scale": [ + 1.0, + 1.0 + ], + "type": "Outwear" + }, + { + "color": "118 123 115", + "icon": "none", + "image_id": 110204, + "offset": [ + 1, + 1 + ], + "path": "aida-sys-image/images/female/blouse/0902000457.jpg", + "print": { + "IfSingle": false, + "print_path_list": [] + }, + "resize_scale": [ + 1.0, + 1.0 + ], + "type": "Blouse" + }, + { + "color": "118 123 115", + "icon": "none", + "image_id": 79259, + "offset": [ + 1, + 1 + ], + "path": "aida-sys-image/images/female/trousers/826000094.jpg", + "print": { + "IfSingle": false, + "print_path_list": [] + }, + "resize_scale": [ + 1.0, + 1.0 + ], + "type": "Trousers" + }, + { + "body_path": "aida-users/31/models/female/845046c7-4f62-4f54-a4a9-c26d49c6969335b5b3a9-d335-4871-a46c-3cc3caf07da259629dfd1f1f555a2e2a9def7e719366.png", + "image_id": 82966, + "offset": [ + 1, + 1 + ], + "resize_scale": [ + 1.0, + 1.0 + ], + "type": "Body" + } + ] + }, + { + "basic": { + "body_point_test": { + "waistband_right": [ + 336, + 264 + ], + "hand_point_right": [ + 350, + 303 + ], + "waistband_left": [ + 245, + 274 + ], + "hand_point_left": [ + 219, + 315 + ], + "shoulder_left": [ + 227, + 155 + ], + "shoulder_right": [ + 338, + 149 + ] + }, + "layer_order": false, + "scale_bag": 0.7, + "scale_earrings": 0.16, + "self_template": true, + "single_overall": "overall", + "switch_category": "" + }, + "items": [ + { + "color": "127 61 21", + "icon": "none", + "image_id": 96038, + "offset": [ + 1, + 1 + ], + "path": "aida-sys-image/images/female/dress/0902003549.jpg", + "print": { + "IfSingle": false, + "print_path_list": [] + }, + "resize_scale": [ + 1.0, + 1.0 + ], + "type": "Dress" + }, + { + "body_path": "aida-users/31/models/female/845046c7-4f62-4f54-a4a9-c26d49c6969335b5b3a9-d335-4871-a46c-3cc3caf07da259629dfd1f1f555a2e2a9def7e719366.png", + "image_id": 82966, + "offset": [ + 1, + 1 + ], + "resize_scale": [ + 1.0, + 1.0 + ], + "type": "Body" + } + ] + }, + { + "basic": { + "body_point_test": { + "waistband_right": [ + 336, + 264 + ], + "hand_point_right": [ + 350, + 303 + ], + "waistband_left": [ + 245, + 274 + ], + "hand_point_left": [ + 219, + 315 + ], + "shoulder_left": [ + 227, + 155 + ], + "shoulder_right": [ + 338, + 149 + ] + }, + "layer_order": false, + "scale_bag": 0.7, + "scale_earrings": 0.16, + "self_template": true, + "single_overall": "overall", + "switch_category": "" + }, + "items": [ + { + "businessId": 493822, + "color": "127 61 21", + "elementId": 493822, + "icon": "none", + "image_id": 62309, + "offset": [ + 1, + 1 + ], + "path": "aida-users/31/sketchboard/female/trousers/c37c2ea6-8955-4b40-8339-c737e672ca3d.jpg", + "print": { + "IfSingle": false, + "print_path_list": [] + }, + "resize_scale": [ + 1.0, + 1.0 + ], + "type": "Trousers" + }, + { + "businessId": 493825, + "color": "118 123 115", + "elementId": 493825, + "icon": "none", + "image_id": 107101, + "offset": [ + 1, + 1 + ], + "path": "aida-users/31/sketchboard/female/Blouse/de8f5656-d7ae-4642-bc90-f7f9d85da09b.jpg", + "print": { + "IfSingle": false, + "print_path_list": [] + }, + "resize_scale": [ + 1.0, + 1.0 + ], + "type": "Blouse" + }, + { + "body_path": "aida-users/31/models/female/845046c7-4f62-4f54-a4a9-c26d49c6969335b5b3a9-d335-4871-a46c-3cc3caf07da259629dfd1f1f555a2e2a9def7e719366.png", + "image_id": 82966, + "offset": [ + 1, + 1 + ], + "resize_scale": [ + 1.0, + 1.0 + ], + "type": "Body" + } + ] + }, + { + "basic": { + "body_point_test": { + "waistband_right": [ + 336, + 264 + ], + "hand_point_right": [ + 350, + 303 + ], + "waistband_left": [ + 245, + 274 + ], + "hand_point_left": [ + 219, + 315 + ], + "shoulder_left": [ + 227, + 155 + ], + "shoulder_right": [ + 338, + 149 + ] + }, + "layer_order": false, + "scale_bag": 0.7, + "scale_earrings": 0.16, + "self_template": true, + "single_overall": "overall", + "switch_category": "" + }, + "items": [ + { + "businessId": 493826, + "color": "127 61 21", + "elementId": 493826, + "icon": "none", + "image_id": 107105, + "offset": [ + 1, + 1 + ], + "path": "aida-users/31/sketchboard/female/Skirt/58710352-6301-450d-b69a-fb2922b5429a.png", + "print": { + "IfSingle": false, + "print_path_list": [] + }, + "resize_scale": [ + 1.0, + 1.0 + ], + "type": "Skirt" + }, + { + "color": "118 123 115", + "icon": "none", + "image_id": 79114, + "offset": [ + 1, + 1 + ], + "path": "aida-sys-image/images/female/blouse/903000169.jpg", + "print": { + "IfSingle": false, + "print_path_list": [] + }, + "resize_scale": [ + 1.0, + 1.0 + ], + "type": "Blouse" + }, + { + "color": "229 214 200", + "icon": "none", + "image_id": 90573, + "offset": [ + 1, + 1 + ], + "path": "aida-sys-image/images/female/outwear/0628000541.jpg", + "print": { + "IfSingle": false, + "print_path_list": [] + }, + "resize_scale": [ + 1.0, + 1.0 + ], + "type": "Outwear" + }, + { + "body_path": "aida-users/31/models/female/845046c7-4f62-4f54-a4a9-c26d49c6969335b5b3a9-d335-4871-a46c-3cc3caf07da259629dfd1f1f555a2e2a9def7e719366.png", + "image_id": 82966, + "offset": [ + 1, + 1 + ], + "resize_scale": [ + 1.0, + 1.0 + ], + "type": "Body" + } + ] + }, + { + "basic": { + "body_point_test": { + "waistband_right": [ + 336, + 264 + ], + "hand_point_right": [ + 350, + 303 + ], + "waistband_left": [ + 245, + 274 + ], + "hand_point_left": [ + 219, + 315 + ], + "shoulder_left": [ + 227, + 155 + ], + "shoulder_right": [ + 338, + 149 + ] + }, + "layer_order": false, + "scale_bag": 0.7, + "scale_earrings": 0.16, + "self_template": true, + "single_overall": "overall", + "switch_category": "" + }, + "items": [ + { + "color": "229 214 200", + "icon": "none", + "image_id": 110205, + "offset": [ + 1, + 1 + ], + "path": "aida-sys-image/images/female/trousers/0916000217.jpg", + "print": { + "IfSingle": false, + "print_path_list": [] + }, + "resize_scale": [ + 1.0, + 1.0 + ], + "type": "Trousers" + }, + { + "businessId": 493825, + "color": "209 125 29", + "elementId": 493825, + "icon": "none", + "image_id": 107101, + "offset": [ + 1, + 1 + ], + "path": "aida-users/31/sketchboard/female/Blouse/de8f5656-d7ae-4642-bc90-f7f9d85da09b.jpg", + "print": { + "IfSingle": false, + "print_path_list": [] + }, + "resize_scale": [ + 1.0, + 1.0 + ], + "type": "Blouse" + }, + { + "body_path": "aida-users/31/models/female/845046c7-4f62-4f54-a4a9-c26d49c6969335b5b3a9-d335-4871-a46c-3cc3caf07da259629dfd1f1f555a2e2a9def7e719366.png", + "image_id": 82966, + "offset": [ + 1, + 1 + ], + "resize_scale": [ + 1.0, + 1.0 + ], + "type": "Body" + } + ] + } + ], + "process_id": "6878547032381675" } \ No newline at end of file diff --git a/app/service/design/items/bag.py b/app/service/design/items/bag.py index c171e75..12b4c68 100644 --- a/app/service/design/items/bag.py +++ b/app/service/design/items/bag.py @@ -1,6 +1,7 @@ +import random + from .builder import ITEMS from .clothing import Clothing -import random @ITEMS.register_module() diff --git a/app/service/design/items/body.py b/app/service/design/items/body.py index 69e8b36..c336ae9 100644 --- a/app/service/design/items/body.py +++ b/app/service/design/items/body.py @@ -1,4 +1,5 @@ import cv2 + from .builder import ITEMS from .pipelines import Compose diff --git a/app/service/design/items/pipelines/contour_detection.py b/app/service/design/items/pipelines/contour_detection.py index df6c7b2..018dbca 100644 --- a/app/service/design/items/pipelines/contour_detection.py +++ b/app/service/design/items/pipelines/contour_detection.py @@ -1,9 +1,8 @@ -import logging - -from ..builder import PIPELINES import cv2 import numpy as np +from ..builder import PIPELINES + @PIPELINES.register_module() class ContourDetection(object): @@ -11,7 +10,7 @@ class ContourDetection(object): # logging.info("ContourDetection run ") pass - #@ RunTime + # @ RunTime def __call__(self, result): # shoe diff if result['name'] == 'shoes': diff --git a/app/service/design/items/pipelines/loading.py b/app/service/design/items/pipelines/loading.py index a1a49a5..d792646 100644 --- a/app/service/design/items/pipelines/loading.py +++ b/app/service/design/items/pipelines/loading.py @@ -1,12 +1,5 @@ -import io -import logging - import cv2 -import numpy as np -from PIL import Image -from minio import Minio -from app.core.config import * from app.service.utils.oss_client import oss_get_image from ..builder import PIPELINES @@ -17,11 +10,7 @@ class LoadImageFromFile(object): self.path = path self.color = color self.print_dict = print_dict - self.minio_client = Minio( - f"{MINIO_URL}", - access_key=MINIO_ACCESS, - secret_key=MINIO_SECRET, - secure=MINIO_SECURE) + # self.minio_client = Minio(f"{MINIO_URL}", access_key=MINIO_ACCESS, secret_key=MINIO_SECRET, secure=MINIO_SECURE) def __call__(self, result): result['image'], result['pre_mask'] = self.read_image(self.path) @@ -53,11 +42,13 @@ class LoadImageFromFile(object): f"bag, shoes, hairstyle, earring.") return keypoint - def read_image(self, image_path): + @staticmethod + def read_image(image_path): image_mask = None - file = self.minio_client.get_object(image_path.split("/", 1)[0], image_path.split("/", 1)[1]).data - image = cv2.imdecode(np.frombuffer(file, np.uint8), 1) + # file = self.minio_client.get_object(image_path.split("/", 1)[0], image_path.split("/", 1)[1]).data + # image = cv2.imdecode(np.frombuffer(file, np.uint8), 1) + image = oss_get_image(bucket=image_path.split("/", 1)[0], object_name=image_path.split("/", 1)[1], data_type="cv2") if len(image.shape) == 2: image = cv2.cvtColor(image, cv2.COLOR_GRAY2RGB) if image.shape[2] == 4: # 如果是四通道 mask diff --git a/app/service/design/items/pipelines/painting.py b/app/service/design/items/pipelines/painting.py index 32e750c..a738455 100644 --- a/app/service/design/items/pipelines/painting.py +++ b/app/service/design/items/pipelines/painting.py @@ -1,6 +1,5 @@ import random -# import boto3 import cv2 import numpy as np from PIL import Image @@ -9,12 +8,6 @@ from app.service.utils.oss_client import oss_get_image from ..builder import PIPELINES -# minio_client = Minio(MINIO_URL, access_key=MINIO_ACCESS, secret_key=MINIO_SECRET, secure=MINIO_SECURE) - - -# s3 = boto3.client('s3', aws_access_key_id=S3_ACCESS_KEY, aws_secret_access_key=S3_AWS_SECRET_ACCESS_KEY, region_name=S3_REGION_NAME) - - @PIPELINES.register_module() class Painting(object): def __init__(self, painting_flag=True): @@ -65,6 +58,8 @@ class Painting(object): # 使用OpenCV解码图像数组 # image = cv2.imdecode(image_array, cv2.IMREAD_COLOR) image = oss_get_image(bucket=bucket_name, object_name=object_name, data_type="cv2") + if image.shape[2] == 4: + image = cv2.cvtColor(image, cv2.COLOR_BGRA2BGR) return image @staticmethod @@ -211,7 +206,16 @@ class PrintPainting(object): result['print_image'] = result['pattern_image'] # print else: - painting_dict = self.painting_collection(painting_dict, result, print_trigger=True) + if "print_angle_list" in result['print'].keys() and result['print']['print_angle_list'][0] != 0: + painting_dict = self.painting_collection(painting_dict, result, print_trigger=True) + painting_dict['tile_print'] = self.rotate_crop_image(img=painting_dict['tile_print'], angle=-result['print']['print_angle_list'][0], crop=True) + painting_dict['mask_inv_print'] = self.rotate_crop_image(img=painting_dict['mask_inv_print'], angle=-result['print']['print_angle_list'][0], crop=True) + + # resize 到sketch大小 + painting_dict['tile_print'] = self.resize_and_crop(img=painting_dict['tile_print'], target_width=painting_dict['dim_image_w'], target_height=painting_dict['dim_image_h']) + painting_dict['mask_inv_print'] = self.resize_and_crop(img=painting_dict['mask_inv_print'], target_width=painting_dict['dim_image_w'], target_height=painting_dict['dim_image_h']) + else: + painting_dict = self.painting_collection(painting_dict, result, print_trigger=True) result['print_image'] = self.printpaint(result, painting_dict, print_=True) result['final_image'] = result['print_image'] canvas = np.full_like(result['final_image'], 255) @@ -358,8 +362,13 @@ class PrintPainting(object): dim_pattern = (int(dim_max * print_['scale'] / 5), int(dim_max * print_['scale'] / 5)) if not print_['IfSingle']: self.random_seed = random.randint(0, 1000) - painting_dict['mask_inv_print'] = self.tile_image(single_mask_inv_print, dim_pattern, print_['scale'], painting_dict['dim_image_h'], painting_dict['dim_image_w'], painting_dict['location'], trigger=True) - painting_dict['tile_print'] = self.tile_image(print_['image'], dim_pattern, print_['scale'], painting_dict['dim_image_h'], painting_dict['dim_image_w'], painting_dict['location'], trigger=True) + # 如果print 模式为overall 且 有角度的话 , 组合的print为正方形,方便裁剪 + if "print_angle_list" in result['print'].keys() and result['print']['print_angle_list'][0] != 0: + painting_dict['mask_inv_print'] = self.tile_image(single_mask_inv_print, dim_pattern, print_['scale'], dim_max, dim_max, painting_dict['location'], trigger=True) + painting_dict['tile_print'] = self.tile_image(print_['image'], dim_pattern, print_['scale'], dim_max, dim_max, painting_dict['location'], trigger=True) + else: + painting_dict['mask_inv_print'] = self.tile_image(single_mask_inv_print, dim_pattern, print_['scale'], painting_dict['dim_image_h'], painting_dict['dim_image_w'], painting_dict['location'], trigger=True) + painting_dict['tile_print'] = self.tile_image(print_['image'], dim_pattern, print_['scale'], painting_dict['dim_image_h'], painting_dict['dim_image_w'], painting_dict['location'], trigger=True) else: painting_dict['mask_inv_print'] = self.tile_image(single_mask_inv_print, dim_pattern, print_['scale'], painting_dict['dim_image_h'], painting_dict['dim_image_w'], painting_dict['location']) painting_dict['tile_print'] = self.tile_image(print_['image'], dim_pattern, print_['scale'], painting_dict['dim_image_h'], painting_dict['dim_image_w'], painting_dict['location']) @@ -540,6 +549,52 @@ class PrintPainting(object): return rotated_img, ((rotated_img.shape[1] - image.shape[1] * scale) // 2, (rotated_img.shape[0] - image.shape[0] * scale) // 2) # return rotated_img, (0, 0) + @staticmethod + def rotate_crop_image(img, angle, crop): + """ + angle: 旋转的角度 + crop: 是否需要进行裁剪,布尔向量 + """ + crop_image = lambda img, x0, y0, w, h: img[y0:y0 + h, x0:x0 + w] + w, h = img.shape[:2] + # 旋转角度的周期是360° + angle %= 360 + # 计算仿射变换矩阵 + M_rotation = cv2.getRotationMatrix2D((w / 2, h / 2), angle, 1) + # 得到旋转后的图像 + img_rotated = cv2.warpAffine(img, M_rotation, (w, h)) + + # 如果需要去除黑边 + if crop: + # 裁剪角度的等效周期是180° + angle_crop = angle % 180 + if angle > 90: + angle_crop = 180 - angle_crop + # 转化角度为弧度 + theta = angle_crop * np.pi / 180 + # 计算高宽比 + hw_ratio = float(h) / float(w) + # 计算裁剪边长系数的分子项 + tan_theta = np.tan(theta) + numerator = np.cos(theta) + np.sin(theta) * np.tan(theta) + + # 计算分母中和高宽比相关的项 + r = hw_ratio if h > w else 1 / hw_ratio + # 计算分母项 + denominator = r * tan_theta + 1 + # 最终的边长系数 + crop_mult = numerator / denominator + + # 得到裁剪区域 + w_crop = int(crop_mult * w) + h_crop = int(crop_mult * h) + x0 = int((w - w_crop) / 2) + y0 = int((h - h_crop) / 2) + + img_rotated = crop_image(img_rotated, x0, y0, w_crop, h_crop) + + return img_rotated + @staticmethod def read_image(image_url): image = oss_get_image(bucket=image_url.split("/", 1)[0], object_name=image_url.split("/", 1)[1], data_type="cv2") @@ -551,26 +606,33 @@ class PrintPainting(object): image_mode = "RGB" return image, image_mode - # data = minio_client.get_object(image_url.split("/", 1)[0], image_url.split("/", 1)[1]) - # # data = s3.get_object(Bucket=image_url.split("/", 1)[0], Key=image_url.split("/", 1)[1])['Body'] - # - # data_bytes = BytesIO(data.read()) - # image = Image.open(data_bytes) - # image_mode = image.mode - # # 判断图片格式,如果是RGBA 则贴在一张纯白图片上 防止透明转黑 - # if image_mode == "RGBA": - # # new_background = Image.new('RGB', image.size, (255, 255, 255)) - # # new_background.paste(image, mask=image.split()[3]) - # # image = new_background - # return image, image_mode - # image = cv2.cvtColor(np.asarray(image), cv2.COLOR_RGB2BGR) - # return image, "RGB" + @staticmethod + def resize_and_crop(img, target_width, target_height): + # 获取原始图像的尺寸 + original_height, original_width = img.shape[:2] - # @staticmethod - # def read_image(image_url): - # response = requests.get(image_url) - # image_data = np.frombuffer(response.content, np.uint8) - # - # # 解码图像 - # image = cv2.imdecode(image_data, 3) - # return image + # 计算目标尺寸的宽高比 + target_ratio = target_width / target_height + + # 计算原始图像的宽高比 + original_ratio = original_width / original_height + + # 调整尺寸 + if original_ratio > target_ratio: + # 原始图像更宽,按高度resize,然后裁剪宽度 + new_height = target_height + new_width = int(original_width * (target_height / original_height)) + resized_img = cv2.resize(img, (new_width, new_height)) + # 裁剪宽度 + start_x = (new_width - target_width) // 2 + cropped_img = resized_img[:, start_x:start_x + target_width] + else: + # 原始图像更高,按宽度resize,然后裁剪高度 + new_width = target_width + new_height = int(original_height * (target_width / original_width)) + resized_img = cv2.resize(img, (new_width, new_height)) + # 裁剪高度 + start_y = (new_height - target_height) // 2 + cropped_img = resized_img[start_y:start_y + target_height, :] + + return cropped_img diff --git a/app/service/design/items/pipelines/scale.py b/app/service/design/items/pipelines/scale.py index 80009e1..d101530 100644 --- a/app/service/design/items/pipelines/scale.py +++ b/app/service/design/items/pipelines/scale.py @@ -1,7 +1,9 @@ -from ..builder import PIPELINES import math + import cv2 +from ..builder import PIPELINES + @PIPELINES.register_module() class Scaling(object): diff --git a/app/service/design/items/pipelines/split.py b/app/service/design/items/pipelines/split.py index e46a3e1..155347a 100644 --- a/app/service/design/items/pipelines/split.py +++ b/app/service/design/items/pipelines/split.py @@ -1,11 +1,12 @@ import logging + import cv2 import numpy as np +from PIL import Image from cv2 import cvtColor, COLOR_BGR2RGBA from app.service.utils.generate_uuid import generate_uuid from ..builder import PIPELINES -from PIL import Image from ...utils.conversion_image import rgb_to_rgba from ...utils.upload_image import upload_png_mask @@ -48,7 +49,6 @@ class Split(object): result_front_image_pil = Image.fromarray(cvtColor(result_front_image, COLOR_BGR2RGBA)) front_new_size = (int(result_front_image_pil.width * result["scale"] * result["resize_scale"][0]), int(result_front_image_pil.height * result["scale"] * result["resize_scale"][1])) result_front_image_pil = result_front_image_pil.resize(front_new_size, Image.LANCZOS) - # TODO 多线程外部上传图片到minio # result['front_mask_image'] = cv2.resize(front_mask, front_new_size) # result['front_image'] = result_front_image_pil front_mask = cv2.resize(front_mask, front_new_size) @@ -61,7 +61,6 @@ class Split(object): result_back_image_pil = Image.fromarray(cvtColor(result_back_image, COLOR_BGR2RGBA)) back_new_size = (int(result_back_image_pil.width * result["scale"] * result["resize_scale"][0]), int(result_back_image_pil.height * result["scale"] * result["resize_scale"][1])) result_back_image_pil = result_back_image_pil.resize(back_new_size, Image.LANCZOS) - # TODO 多线程外部上传图片到minio # result['back_mask_image'] = cv2.resize(back_mask, back_new_size) # result['back_image'] = result_back_image_pil diff --git a/app/service/design/items/shoes.py b/app/service/design/items/shoes.py index f4e17f2..aa20d3c 100644 --- a/app/service/design/items/shoes.py +++ b/app/service/design/items/shoes.py @@ -1,14 +1,9 @@ -import io -import logging -import time - import cv2 import numpy as np +from PIL import Image from .builder import ITEMS from .clothing import Clothing -from PIL import Image - from ..utils.conversion_image import rgb_to_rgba from ..utils.upload_image import upload_png_mask from ...utils.generate_uuid import generate_uuid diff --git a/app/service/design/utils/conversion_image.py b/app/service/design/utils/conversion_image.py index 0915070..77848cc 100644 --- a/app/service/design/utils/conversion_image.py +++ b/app/service/design/utils/conversion_image.py @@ -19,5 +19,6 @@ def rgb_to_rgba(rgb_size, rgb_image, mask): rgba_image[:, :, 3] = alpha_channel return rgba_image + if __name__ == '__main__': - image = open("") \ No newline at end of file + image = open("") diff --git a/app/service/design/utils/design_ensemble.py b/app/service/design/utils/design_ensemble.py index a1021e9..00d391f 100644 --- a/app/service/design/utils/design_ensemble.py +++ b/app/service/design/utils/design_ensemble.py @@ -8,12 +8,14 @@ @detail :发起请求 获取推理结果 """ import logging + import cv2 import mmcv import numpy as np -import tritonclient.http as httpclient import torch import torch.nn.functional as F +import tritonclient.http as httpclient + from app.core.config import * """ diff --git a/app/service/design/utils/synthesis_item.py b/app/service/design/utils/synthesis_item.py index caf3fcb..dc8e427 100644 --- a/app/service/design/utils/synthesis_item.py +++ b/app/service/design/utils/synthesis_item.py @@ -9,30 +9,13 @@ """ import io import logging -import time -# import boto3 import cv2 import numpy as np from PIL import Image -from minio import Minio -from app.core.config import * -from app.service.utils.decorator import RunTime from app.service.utils.generate_uuid import generate_uuid - -minio_client = Minio( - MINIO_URL, - access_key=MINIO_ACCESS, - secret_key=MINIO_SECRET, - secure=MINIO_SECURE) - -# s3 = boto3.client( -# 's3', -# aws_access_key_id=S3_ACCESS_KEY, -# aws_secret_access_key=S3_AWS_SECRET_ACCESS_KEY, -# region_name=S3_REGION_NAME -# ) +from app.service.utils.oss_client import oss_upload_image def positioning(all_mask_shape, mask_shape, offset): @@ -134,8 +117,14 @@ def synthesis(data, size): image_data = io.BytesIO() result_image.save(image_data, format='PNG') image_data.seek(0) + + # oss upload image_bytes = image_data.read() - return f"aida-results/{minio_client.put_object('aida-results', f'result_{generate_uuid()}.png', io.BytesIO(image_bytes), len(image_bytes), content_type='image/png').object_name}" + bucket_name = 'aida-results' + object_name = f'result_{generate_uuid()}.png' + req = oss_upload_image(bucket=bucket_name, object_name=object_name, image_bytes=image_bytes) + return f"{bucket_name}/{object_name}" + # return f"aida-results/{minio_client.put_object('aida-results', f'result_{generate_uuid()}.png', io.BytesIO(image_bytes), len(image_bytes), content_type='image/png').object_name}" # object_name = f'result_{generate_uuid()}.png' # response = s3.put_object(Bucket="aida-results", Key=object_name, Body=data, ContentType='image/png') @@ -170,4 +159,9 @@ def synthesis_single(front_image, back_image): result_image.save(image_data, format='PNG') image_data.seek(0) image_bytes = image_data.read() - return f"aida-results/{minio_client.put_object('aida-results', f'result_{generate_uuid()}.png', io.BytesIO(image_bytes), len(image_bytes), content_type='image/png').object_name}" + # return f"aida-results/{minio_client.put_object('aida-results', f'result_{generate_uuid()}.png', io.BytesIO(image_bytes), len(image_bytes), content_type='image/png').object_name}" + # oss upload + bucket_name = 'aida-results' + object_name = f'result_{generate_uuid()}.png' + req = oss_upload_image(bucket=bucket_name, object_name=object_name, image_bytes=image_bytes) + return f"{bucket_name}/{object_name}" diff --git a/app/service/design/utils/upload_image.py b/app/service/design/utils/upload_image.py index a4195f7..3571816 100644 --- a/app/service/design/utils/upload_image.py +++ b/app/service/design/utils/upload_image.py @@ -9,99 +9,15 @@ """ import io import logging -import time -# import boto3 import cv2 -from minio import Minio from app.core.config import * -from app.service.utils.decorator import RunTime - -minio_client = Minio( - f"{MINIO_URL}", - access_key=MINIO_ACCESS, - secret_key=MINIO_SECRET, - secure=MINIO_SECURE) - -"""S3 上传""" -# s3 = boto3.client('s3', aws_access_key_id=S3_ACCESS_KEY, aws_secret_access_key=S3_AWS_SECRET_ACCESS_KEY, region_name=S3_REGION_NAME) - - -# -# @RunTime -# def upload_png_mask(front_image, object_name, mask=None): -# mask_url = None -# if mask is not None: -# # 反转掩模 -# mask_inverted = cv2.bitwise_not(mask) -# # 将掩模转换为 RGBA 格式 -# rgba_image = cv2.cvtColor(mask_inverted, cv2.COLOR_BGR2BGRA) -# rgba_image[rgba_image[:, :, 0] == 0] = [0, 0, 0, 0] -# # 将图像数据保存到内存中的 BytesIO 对象中 -# image_bytes = io.BytesIO() -# image_bytes.write(cv2.imencode('.png', rgba_image)[1].tobytes()) -# image_bytes.seek(0) -# try: -# key = f"mask/mask_{object_name}.png" -# mask_url = f"{AIDA_CLOTHING}/{key}" -# s3.put_object(Bucket=AIDA_CLOTHING, Key=key, Body=image_bytes, ContentType='image/png') -# except Exception as e: -# print(f'上传到 S3 失败: {e}') -# with io.BytesIO() as output: -# front_image.save(output, format='PNG') -# data = output.getvalue() -# # 创建一个 S3 客户端 -# try: -# key = f"image/image_{object_name}.png" -# image_url = f"{AIDA_CLOTHING}/{key}" -# s3.put_object(Bucket=AIDA_CLOTHING, Key=key, Body=data, ContentType='image/png') -# return front_image, image_url, mask_url -# except Exception as e: -# print(f'上传到 S3 失败: {e}') -# -# -# @RunTime -# def upload_layer_image(image, object_name): -# with io.BytesIO() as output: -# image.save(output, format='PNG') -# data = output.getvalue() -# # 创建一个 S3 客户端 -# try: -# key = f"image/image_{object_name}.png" -# image_url = f"{AIDA_CLOTHING}/{key}" -# s3.put_object(Bucket=AIDA_CLOTHING, Key=key, Body=data, ContentType='image/png') -# return image_url -# except Exception as e: -# print(f'上传到 S3 失败: {e}') -# -# -# @RunTime -# def upload_mask_image(mask, object_name): -# # 反转掩模 -# mask_inverted = cv2.bitwise_not(mask) -# # 将掩模转换为 RGBA 格式 -# rgba_image = cv2.cvtColor(mask_inverted, cv2.COLOR_BGR2BGRA) -# rgba_image[rgba_image[:, :, 0] == 0] = [0, 0, 0, 0] -# # 将图像数据保存到内存中的 BytesIO 对象中 -# image_bytes = io.BytesIO() -# image_bytes.write(cv2.imencode('.png', rgba_image)[1].tobytes()) -# image_bytes.seek(0) -# try: -# key = f"mask/mask_{object_name}.png" -# mask_url = f"{AIDA_CLOTHING}/{key}" -# s3.put_object(Bucket=AIDA_CLOTHING, Key=key, Body=image_bytes, ContentType='image/png') -# return mask_url -# except Exception as e: -# print(f'上传到 S3 失败: {e}') - - -"""minio 上传""" +from app.service.utils.oss_client import oss_upload_image # @RunTime def upload_png_mask(front_image, object_name, mask=None): - start_time = time.time() try: mask_url = None if mask is not None: @@ -109,48 +25,21 @@ def upload_png_mask(front_image, object_name, mask=None): # 将掩模的3通道转换为4通道,白色部分不透明,黑色部分透明 rgba_image = cv2.cvtColor(mask_inverted, cv2.COLOR_BGR2BGRA) rgba_image[rgba_image[:, :, 0] == 0] = [0, 0, 0, 0] - image_bytes = io.BytesIO() - image_bytes.write(cv2.imencode('.png', rgba_image)[1].tobytes()) - - image_bytes.seek(0) - mask_url = f"{AIDA_CLOTHING}/{minio_client.put_object('aida-clothing', f'mask/mask_{object_name}.png', image_bytes, len(image_bytes.getvalue()), content_type='image/png').object_name}" + # image_bytes = io.BytesIO() + # image_bytes.write(cv2.imencode('.png', rgba_image)[1].tobytes()) + # image_bytes.seek(0) + # mask_url = f"{AIDA_CLOTHING}/{minio_client.put_object('aida-clothing', f'mask/mask_{object_name}.png', image_bytes, len(image_bytes.getvalue()), content_type='image/png').object_name}" + # oss upload #################### + req = oss_upload_image(bucket=AIDA_CLOTHING, object_name=f"mask/mask_{object_name}.png", image_bytes=cv2.imencode('.png', rgba_image)[1]) + mask_url = f"{AIDA_CLOTHING}/mask/mask_{object_name}.png" image_data = io.BytesIO() front_image.save(image_data, format='PNG') image_data.seek(0) image_bytes = image_data.read() - image_url = f"{AIDA_CLOTHING}/{minio_client.put_object('aida-clothing', f'image/image_{object_name}.png', io.BytesIO(image_bytes), len(image_bytes), content_type='image/png').object_name}" - # print(f"upload_png_mask {object_name} = {time.time() - start_time}") + # image_url = f"{AIDA_CLOTHING}/{minio_client.put_object('aida-clothing', f'image/image_{object_name}.png', io.BytesIO(image_bytes), len(image_bytes), content_type='image/png').object_name}" + req = oss_upload_image(bucket=AIDA_CLOTHING, object_name=f"image/image_{object_name}.png", image_bytes=image_bytes) + image_url = f"{AIDA_CLOTHING}/image/image_{object_name}.png" return front_image, image_url, mask_url except Exception as e: logging.warning(f"upload_png_mask runtime exception : {e}") - - -@RunTime -def upload_layer_image(image, object_name): - try: - image_data = io.BytesIO() - image.save(image_data, format='PNG') - image_data.seek(0) - image_bytes = image_data.read() - image_url = f"{AIDA_CLOTHING}/{minio_client.put_object('aida-clothing', f'image/image_{object_name}.png', io.BytesIO(image_bytes), len(image_bytes), content_type='image/png').object_name}" - return image_url - except Exception as e: - logging.warning(f"upload_png_mask runtime exception : {e}") - - -@RunTime -def upload_mask_image(mask, object_name): - try: - mask_inverted = cv2.bitwise_not(mask) - # 将掩模的3通道转换为4通道,白色部分不透明,黑色部分透明 - rgba_image = cv2.cvtColor(mask_inverted, cv2.COLOR_BGR2BGRA) - rgba_image[rgba_image[:, :, 0] == 0] = [0, 0, 0, 0] - image_bytes = io.BytesIO() - image_bytes.write(cv2.imencode('.png', rgba_image)[1].tobytes()) - - image_bytes.seek(0) - mask_url = f"{AIDA_CLOTHING}/{minio_client.put_object('aida-clothing', f'mask/mask_{object_name}.png', image_bytes, len(image_bytes.getvalue()), content_type='image/png').object_name}" - return mask_url - except Exception as e: - logging.warning(f"upload_png_mask runtime exception : {e}") diff --git a/app/service/design_pre_processing/service.py b/app/service/design_pre_processing/service.py index f6f239a..f69c3ee 100644 --- a/app/service/design_pre_processing/service.py +++ b/app/service/design_pre_processing/service.py @@ -8,6 +8,7 @@ import tritonclient.grpc as grpcclient from urllib3.exceptions import ResponseError from app.core.config import * +from app.schemas.pre_processing import DesignPreProcessingModel from app.service.design.utils.design_ensemble import get_keypoint_result from app.service.utils.oss_client import oss_get_image, oss_upload_image @@ -355,3 +356,19 @@ class DesignPreprocessing: except Exception as e: logging.info(f"save keypoint cache milvus error : {e}") return dict(zip(KEYPOINT_RESULT_TABLE_FIELD_SET, result.reshape(12, 2).astype(int).tolist())) + + +if __name__ == '__main__': + data = { + "sketches": [ + { + "image_category": "dress", + "image_id": "107903", + "image_url": "aida-sys-image/images/female/dress/0628000000.jpg" + } + ] + } + request_data = DesignPreProcessingModel(sketches=data["sketches"]) + server = DesignPreprocessing() + data = server.pipeline(image_list=request_data.sketches) + print(data) diff --git a/app/service/generate_image/service_generate_image.py b/app/service/generate_image/service_generate_image.py index f3dff16..1bc1c91 100644 --- a/app/service/generate_image/service_generate_image.py +++ b/app/service/generate_image/service_generate_image.py @@ -10,15 +10,17 @@ import json import logging import time + import cv2 import minio +import numpy as np import redis import tritonclient.grpc as grpcclient -import numpy as np from tritonclient.utils import np_to_triton_dtype + from app.core.config import * from app.schemas.generate_image import GenerateImageModel -from app.service.generate_image.utils.image_processing import remove_background, stain_detection, generate_category_recognition, autoLevels, luminance_adjust, face_detect_pic +from app.service.generate_image.utils.image_processing import remove_background, stain_detection, generate_category_recognition, autoLevels, luminance_adjust from app.service.generate_image.utils.upload_sd_image import upload_png_sd from app.service.utils.oss_client import oss_get_image @@ -120,13 +122,6 @@ class GenerateImage: status_data = self.redis_client.get(self.tasks_id) return json.loads(status_data), status_data - def infer(self, inputs): - return self.grpc_client.async_infer( - model_name=GI_MODEL_NAME, - inputs=inputs, - callback=self.callback - ) - def get_result(self): try: prompts = [self.prompt] * self.batch_size @@ -146,7 +141,7 @@ class GenerateImage: input_mode.set_data_from_numpy(mode_obj) inputs = [input_text, input_image, input_mode] - ctx = self.infer(inputs) + ctx = self.grpc_client.async_infer(model_name=GI_MODEL_NAME, inputs=inputs, callback=self.callback) time_out = 600 generate_data = None while time_out > 0: @@ -186,10 +181,10 @@ if __name__ == '__main__': rd = GenerateImageModel( tasks_id="123-89", prompt='skeleton sitting by the side of a river looking soulful, concert poster, 4k, artistic', - image_url="", + image_url="aida-collection-element/87/Printboard/842c09cf-7297-42d9-9e6e-9c17d4a13cb5.jpg", mode='txt2img', category="test", gender="male" ) server = GenerateImage(rd) - print(server.get_result()) \ No newline at end of file + print(server.get_result()) diff --git a/app/service/generate_image/service_generate_relight_image.py b/app/service/generate_image/service_generate_relight_image.py index 8793c42..ca32c73 100644 --- a/app/service/generate_image/service_generate_relight_image.py +++ b/app/service/generate_image/service_generate_relight_image.py @@ -137,7 +137,7 @@ if __name__ == '__main__': tasks_id="123-89", # prompt="beautiful woman, detailed face, sunshine, outdoor, warm atmosphere", prompt="Colorful black", - image_url='aida-users/89/product_image/123-89.png' + image_url='aida-results/result_0000b606-1902-11ef-9424-0242ac180002.png' ) server = GenerateRelightImage(rd) print(server.get_result()) diff --git a/app/service/super_resolution/service.py b/app/service/super_resolution/service.py index 1dfe9dd..c2cf39d 100644 --- a/app/service/super_resolution/service.py +++ b/app/service/super_resolution/service.py @@ -64,7 +64,6 @@ class SuperResolution: if self.sr_xn == 2: new_shape = (sample.shape[0] // self.sr_xn, sample.shape[1] // self.sr_xn) sample = cv2.resize(sample, new_shape) - print(new_shape) sample = np.transpose(sample if sample.shape[2] == 1 else sample[:, :, [2, 1, 0]], (2, 0, 1)) sample = torch.from_numpy(sample).float().unsqueeze(0).numpy() inputs = [ diff --git a/app/service/utils/oss_client.py b/app/service/utils/oss_client.py index 7ebeb3f..c2bb82c 100644 --- a/app/service/utils/oss_client.py +++ b/app/service/utils/oss_client.py @@ -44,7 +44,7 @@ def oss_upload_image(bucket, object_name, image_bytes): req = oss_client.put_object(bucket_name=bucket, object_name=object_name, data=io.BytesIO(image_bytes), length=len(image_bytes), content_type='image/png') else: oss_client = boto3.client('s3', aws_access_key_id=S3_ACCESS_KEY, aws_secret_access_key=S3_AWS_SECRET_ACCESS_KEY, region_name=S3_REGION_NAME) - req = oss_client.put_object(Bucket=AIDA_CLOTHING, Key=object_name, Body=image_bytes, ContentType='image/png') + req = oss_client.put_object(Bucket=bucket, Key=object_name, Body=io.BytesIO(image_bytes), ContentType='image/png') except Exception as e: logger.warning(f"{OSS} | 上传图片出现异常 ######: {e}") return req @@ -55,12 +55,16 @@ if __name__ == '__main__': # url = "aida-collection-element/11523/Moodboard/f60af0d2-94c2-48f9-90ff-74b8e8a481b5.jpg" # url = "aida-sys-image/images/female/outwear/0628000054.jpg" # url = "aida-users/89/product_image/string-89.png" - url = "test/845046c7-4f62-4f54-a4a9-c26d49c6969335b5b3a9-d335-4871-a46c-3cc3caf07da259629dfd1f1f555a2e2a9def7e719366.png" + # url = "test/845046c7-4f62-4f54-a4a9-c26d49c6969335b5b3a9-d335-4871-a46c-3cc3caf07da259629dfd1f1f555a2e2a9def7e719366.png" # url = 'aida-users/89/relight_image/123-89.png' # url = 'aida-users/89/relight_image/123-89.png' # url = 'aida-users/89/relight_image/123-89.png' # url = "aida-users/89/sketchboard/female/Dress/e6724ab7-8d3f-4677-abe0-c3e42ab7af85.jpeg" - read_type = "PIL " + # url = "aida-users/87/print/956614a2-7e75-4fbe-9ed0-c1831e37a2c9-4-87.png" + # url = "aida-users/89/single_logo/123-89.png" + # url = "aida-users/89/product_image/string-89.png" + url = "aida-results/result_c6520ce7-33a1-11ef-a8d3-b0dcefbff887.png" + read_type = "PIL" if read_type == "cv2": img = oss_get_image(bucket=url.split('/')[0], object_name=url[url.find('/') + 1:], data_type=read_type) cv2.imshow("", img)