feat 代码整理

fix
This commit is contained in:
zhouchengrong
2024-09-26 14:19:32 +08:00
parent 6a93f89f0d
commit 84d207087b
6 changed files with 2 additions and 1152 deletions

View File

@@ -6,9 +6,8 @@ from fastapi import APIRouter, HTTPException, UploadFile, File, Form
from app.schemas.design import DesignModel, DesignProgressModel, ModelProgressModel, DBGConfigModel
from app.schemas.response_template import ResponseModel
from app.service.design.model_process_service import model_transpose
from app.service.design_batch.service import start_design_batch_generate
# from app.service.design.model_process_service import model_transpose
# from app.service.design.service_design_batch_generate import start_design_batch_generate
from app.service.design_fast.design_generate import design_generate
from app.service.design_fast.utils.redis_utils import Redis
@@ -237,7 +236,7 @@ def model_process(request_data: ModelProgressModel):
try:
logger.info(f"model_process request item is : @@@@@@:{json.dumps(request_data.dict())}")
# data = model_transpose(image_path=request_data.model_path)
data = model_transpose(image_path=request_data.model_path)
logger.info(f"model_process response @@@@@@:{json.dumps(data)}")
except Exception as e:
logger.warning(f"model_process Run Exception @@@@@@:{e}")

View File

@@ -1,281 +0,0 @@
import time
from concurrent.futures import ThreadPoolExecutor
from pprint import pprint
import cv2
from app.core.config import PRIORITY_DICT
from app.service.design.design_batch.items.pipeline import LoadImage, KeyPoint, Segmentation, Color, PrintPainting, Scaling, Split, ContourDetection, LoadBodyImage
from app.service.design.utils.synthesis_item import synthesis, synthesis_single
class BaseItem:
def __init__(self, data, basic):
self.result = data.copy()
self.result['name'] = data['type'].lower()
self.result.pop("type")
self.result.update(basic)
class TopItem(BaseItem):
def __init__(self, data, basic):
super().__init__(data, basic)
self.top_pipeline = [
LoadImage(),
KeyPoint(),
Segmentation(),
Color(),
PrintPainting(),
Scaling(),
Split()
]
def process(self):
for item in self.top_pipeline:
self.result = item(self.result)
return self.result
class BottomItem(BaseItem):
def __init__(self, data, basic):
super().__init__(data, basic)
self.bottom_pipeline = [
LoadImage(),
KeyPoint(),
ContourDetection(),
# Segmentation(),
Color(),
PrintPainting(),
Scaling(),
Split()
]
def process(self):
for item in self.bottom_pipeline:
self.result = item(self.result)
return self.result
class BodyItem(BaseItem):
def __init__(self, data, basic):
super().__init__(data, basic)
self.top_pipeline = [
LoadBodyImage(),
]
def process(self):
for item in self.top_pipeline:
self.result = item(self.result)
return self.result
def process_item(item, basic):
if item['type'] == "Body":
body_server = BodyItem(data=item, basic=basic)
item_data = body_server.process()
elif item['type'].lower() in ['blouse', 'outwear', 'dress', 'tops']:
top_server = TopItem(data=item, basic=basic)
item_data = top_server.process()
else:
bottom_server = BottomItem(data=item, basic=basic)
item_data = bottom_server.process()
return item_data
def calculate_start_point(keypoint_type, scale, clothes_point, body_point, offset, resize_scale):
"""
Align left
Args:
keypoint_type: string, "waistband" | "shoulder" | "ear_point"
scale: float
clothes_point: dict{'left': [x1, y1, z1], 'right': [x2, y2, z2]}
body_point: dict, containing keypoint data of body figure
Returns:
start_point: tuple (x', y')
x' = y_body - y1 * scale + offset
y' = x_body - x1 * scale + offset
"""
side_indicator = f'{keypoint_type}_left'
start_point = (
int(body_point[side_indicator][1] + offset[1] - int(clothes_point[side_indicator][0]) * scale), # y
int(body_point[side_indicator][0] + offset[0] - int(clothes_point[side_indicator][1]) * scale) # x
)
return start_point
# 服装图层给数据组装
def organize_clothing(layer):
# 起始坐标
start_point = calculate_start_point(layer['keypoint'], layer['scale'], layer['clothes_keypoint'], layer['body_point_test'], layer["offset"], layer["resize_scale"])
# 前片数据
front_layer = dict(priority=layer['priority'] if layer.get("layer_order", False) else PRIORITY_DICT.get(f'{layer["name"].lower()}_front', None),
name=f'{layer["name"].lower()}_front',
image=layer["front_image"],
# mask_image=layer['front_mask_image'],
image_url=layer['front_image_url'],
mask_url=layer['mask_url'],
sacle=layer['scale'],
clothes_keypoint=layer['clothes_keypoint'],
position=start_point,
resize_scale=layer["resize_scale"],
mask=cv2.resize(layer['mask'], layer["front_image"].size),
gradient_string=layer['gradient_string'] if 'gradient_string' in layer.keys() else "",
pattern_image_url=layer['pattern_image_url'],
pattern_image=layer['pattern_image']
)
# 后片数据
back_layer = dict(priority=-layer.get("priority", 0) if layer.get("layer_order", False) else PRIORITY_DICT.get(f'{layer["name"].lower()}_back', None),
name=f'{layer["name"].lower()}_back',
image=layer["back_image"],
# mask_image=layer['back_mask_image'],
image_url=layer['back_image_url'],
mask_url=layer['mask_url'],
sacle=layer['scale'],
clothes_keypoint=layer['clothes_keypoint'],
position=start_point,
resize_scale=layer["resize_scale"],
mask=cv2.resize(layer['mask'], layer["front_image"].size),
gradient_string=layer['gradient_string'] if 'gradient_string' in layer.keys() else "",
pattern_image_url=layer['pattern_image_url'],
)
return front_layer, back_layer
# 模特图层给数据组装
def organize_body(layer):
body_layer = dict(priority=0,
name=layer["name"].lower(),
image=layer['body_image'],
image_url=layer['body_path'],
mask_image=None,
mask_url=None,
sacle=1,
# mask=layer['body_mask'],
position=(0, 0))
return body_layer
def process_layer(item, layers):
if item['name'] == "mannequin":
body_layer = organize_body(item)
layers.append(body_layer)
return item['body_image'].size
else:
front_layer, back_layer = organize_clothing(item)
layers.append(front_layer)
layers.append(back_layer)
def process_object(object_data):
basic = object_data['basic']
items_response = {'layers': []}
if basic['single_overall'] == "overall":
item_results = [process_item(item, basic) for item in object_data['items']]
layers = []
futures = []
body_size = None
for item in item_results:
futures = [process_layer(item, layers)]
for future in futures:
if future is not None:
body_size = future
layers = sorted(layers, key=lambda s: s.get("priority", float('inf')))
layers, new_size = update_base_size_priority(layers, body_size)
for lay in layers:
items_response['layers'].append({
'image_category': lay['name'],
'position': lay['position'],
'priority': lay.get("priority", None),
'resize_scale': lay['resize_scale'] if "resize_scale" in lay.keys() else None,
'image_size': lay['image'] if lay['image'] is None else lay['image'].size,
'gradient_string': lay['gradient_string'] if 'gradient_string' in lay.keys() else "",
'mask_url': lay['mask_url'],
'image_url': lay['image_url'] if 'image_url' in lay.keys() else None,
'pattern_image_url': lay['pattern_image_url'] if 'pattern_image_url' in lay.keys() else None,
# 'image': lay['image'],
# 'mask_image': lay['mask_image'],
})
items_response['synthesis_url'] = synthesis(layers, new_size, basic)
else:
item_results = process_item(object_data['items'][0], basic)
items_response['layers'].append({
'image_category': f"{item_results['name']}_front",
'image_size': item_results['back_image'].size if item_results['back_image'] else None,
'position': None,
'priority': 0,
'image_url': item_results['front_image_url'],
'mask_url': item_results['mask_url'],
"gradient_string": item_results['gradient_string'] if 'gradient_string' in item_results.keys() else "",
'pattern_image_url': item_results['pattern_image_url'] if 'pattern_image_url' in item_results.keys() else None,
})
items_response['layers'].append({
'image_category': f"{item_results['name']}_back",
'image_size': item_results['front_image'].size if item_results['front_image'] else None,
'position': None,
'priority': 0,
'image_url': item_results['back_image_url'],
'mask_url': item_results['mask_url'],
"gradient_string": item_results['gradient_string'] if 'gradient_string' in item_results.keys() else "",
'pattern_image_url': item_results['pattern_image_url'] if 'pattern_image_url' in item_results.keys() else None,
})
items_response['synthesis_url'] = synthesis_single(item_results['front_image'], item_results['back_image'])
return items_response
def update_base_size_priority(layers, size):
# 计算透明背景图片的宽度
min_x = min(info['position'][1] for info in layers)
x_list = []
for info in layers:
if info['image'] is not None:
x_list.append(info['position'][1] + info['image'].width)
max_x = max(x_list)
new_width = max_x - min_x
new_height = 700
# 更新坐标
for info in layers:
info['adaptive_position'] = (info['position'][0], info['position'][1] - min_x)
return layers, (new_width, new_height)
def run():
object = {"objects": [{"basic": {"body_point_test": {"waistband_right": [199, 239], "hand_point_right": [220, 308], "waistband_left": [113, 239], "hand_point_left": [92, 310], "shoulder_left": [99, 111], "shoulder_right": [214, 111]}, "layer_order": False, "scale_bag": 0.7, "scale_earrings": 0.16, "self_template": True, "single_overall": "single", "switch_category": "Outwear"}, "items": [
{"color": "189 112 112", "icon": "none", "image_id": 116441, "offset": [1, 1], "path": "aida-sys-image/images/female/outwear/outwear_p3139.jpg", "print": {"element": {"element_angle_list": [], "element_path_list": [], "element_scale_list": [], "location": []}, "overall": {"location": [[0.0, 0.0]], "print_angle_list": [0.0, 0.0], "print_path_list": [], "print_scale_list": [0.0, 0.0]}, "single": {"location": [], "print_angle_list": [], "print_path_list": [], "print_scale_list": []}},
"resize_scale": [1.0, 1.0], "type": "Outwear"}]}, {"basic": {"body_point_test": {"waistband_right": [199, 239], "hand_point_right": [220, 308], "waistband_left": [113, 239], "hand_point_left": [92, 310], "shoulder_left": [99, 111], "shoulder_right": [214, 111]}, "layer_order": False, "scale_bag": 0.7, "scale_earrings": 0.16, "self_template": True, "single_overall": "single", "switch_category": "Outwear"}, "items": [
{"color": "189 112 112", "icon": "none", "image_id": 81518, "offset": [1, 1], "path": "aida-sys-image/images/female/outwear/0628000071.jpg", "print": {"element": {"element_angle_list": [], "element_path_list": [], "element_scale_list": [], "location": []}, "overall": {"location": [[0.0, 0.0]], "print_angle_list": [0.0, 0.0], "print_path_list": [], "print_scale_list": [0.0, 0.0]}, "single": {"location": [], "print_angle_list": [], "print_path_list": [], "print_scale_list": []}},
"resize_scale": [1.0, 1.0], "type": "Outwear"}]}, {"basic": {"body_point_test": {"waistband_right": [199, 239], "hand_point_right": [220, 308], "waistband_left": [113, 239], "hand_point_left": [92, 310], "shoulder_left": [99, 111], "shoulder_right": [214, 111]}, "layer_order": False, "scale_bag": 0.7, "scale_earrings": 0.16, "self_template": True, "single_overall": "single", "switch_category": "Outwear"}, "items": [
{"color": "189 112 112", "icon": "none", "image_id": 65687, "offset": [1, 1], "path": "aida-sys-image/images/female/outwear/outwear_746.jpg", "print": {"element": {"element_angle_list": [], "element_path_list": [], "element_scale_list": [], "location": []}, "overall": {"location": [[0.0, 0.0]], "print_angle_list": [0.0, 0.0], "print_path_list": [], "print_scale_list": [0.0, 0.0]}, "single": {"location": [], "print_angle_list": [], "print_path_list": [], "print_scale_list": []}},
"resize_scale": [1.0, 1.0], "type": "Outwear"}]}, {"basic": {"body_point_test": {"waistband_right": [199, 239], "hand_point_right": [220, 308], "waistband_left": [113, 239], "hand_point_left": [92, 310], "shoulder_left": [99, 111], "shoulder_right": [214, 111]}, "layer_order": False, "scale_bag": 0.7, "scale_earrings": 0.16, "self_template": True, "single_overall": "single", "switch_category": "Outwear"}, "items": [
{"color": "189 112 112", "icon": "none", "image_id": 90051, "offset": [1, 1], "path": "aida-sys-image/images/female/outwear/0628000864.jpg", "print": {"element": {"element_angle_list": [], "element_path_list": [], "element_scale_list": [], "location": []}, "overall": {"location": [[0.0, 0.0]], "print_angle_list": [0.0, 0.0], "print_path_list": [], "print_scale_list": [0.0, 0.0]}, "single": {"location": [], "print_angle_list": [], "print_path_list": [], "print_scale_list": []}},
"resize_scale": [1.0, 1.0], "type": "Outwear"}]}, {"basic": {"body_point_test": {"waistband_right": [199, 239], "hand_point_right": [220, 308], "waistband_left": [113, 239], "hand_point_left": [92, 310], "shoulder_left": [99, 111], "shoulder_right": [214, 111]}, "layer_order": False, "scale_bag": 0.7, "scale_earrings": 0.16, "self_template": True, "single_overall": "single", "switch_category": "Outwear"}, "items": [
{"color": "189 112 112", "icon": "none", "image_id": 67420, "offset": [1, 1], "path": "aida-sys-image/images/female/outwear/0825001648.jpg", "print": {"element": {"element_angle_list": [], "element_path_list": [], "element_scale_list": [], "location": []}, "overall": {"location": [[0.0, 0.0]], "print_angle_list": [0.0, 0.0], "print_path_list": [], "print_scale_list": [0.0, 0.0]}, "single": {"location": [], "print_angle_list": [], "print_path_list": [], "print_scale_list": []}},
"resize_scale": [1.0, 1.0], "type": "Outwear"}]}, {"basic": {"body_point_test": {"waistband_right": [199, 239], "hand_point_right": [220, 308], "waistband_left": [113, 239], "hand_point_left": [92, 310], "shoulder_left": [99, 111], "shoulder_right": [214, 111]}, "layer_order": False, "scale_bag": 0.7, "scale_earrings": 0.16, "self_template": True, "single_overall": "single", "switch_category": "Outwear"}, "items": [
{"color": "189 112 112", "icon": "none", "image_id": 90354, "offset": [1, 1], "path": "aida-sys-image/images/female/outwear/0628001300.jpg", "print": {"element": {"element_angle_list": [], "element_path_list": [], "element_scale_list": [], "location": []}, "overall": {"location": [[0.0, 0.0]], "print_angle_list": [0.0, 0.0], "print_path_list": [], "print_scale_list": [0.0, 0.0]}, "single": {"location": [], "print_angle_list": [], "print_path_list": [], "print_scale_list": []}},
"resize_scale": [1.0, 1.0], "type": "Outwear"}]}, {"basic": {"body_point_test": {"waistband_right": [199, 239], "hand_point_right": [220, 308], "waistband_left": [113, 239], "hand_point_left": [92, 310], "shoulder_left": [99, 111], "shoulder_right": [214, 111]}, "layer_order": False, "scale_bag": 0.7, "scale_earrings": 0.16, "self_template": True, "single_overall": "single", "switch_category": "Outwear"}, "items": [
{"color": "189 112 112", "icon": "none", "image_id": 67420, "offset": [1, 1], "path": "aida-sys-image/images/female/outwear/0825001648.jpg", "print": {"element": {"element_angle_list": [], "element_path_list": [], "element_scale_list": [], "location": []}, "overall": {"location": [[0.0, 0.0]], "print_angle_list": [0.0, 0.0], "print_path_list": [], "print_scale_list": [0.0, 0.0]}, "single": {"location": [], "print_angle_list": [], "print_path_list": [], "print_scale_list": []}},
"resize_scale": [1.0, 1.0], "type": "Outwear"}]}, {"basic": {"body_point_test": {"waistband_right": [199, 239], "hand_point_right": [220, 308], "waistband_left": [113, 239], "hand_point_left": [92, 310], "shoulder_left": [99, 111], "shoulder_right": [214, 111]}, "layer_order": False, "scale_bag": 0.7, "scale_earrings": 0.16, "self_template": True, "single_overall": "single", "switch_category": "Outwear"}, "items": [
{"color": "189 112 112", "icon": "none", "image_id": 101477, "offset": [1, 1], "path": "aida-sys-image/images/female/outwear/903000063.jpg", "print": {"element": {"element_angle_list": [], "element_path_list": [], "element_scale_list": [], "location": []}, "overall": {"location": [[0.0, 0.0]], "print_angle_list": [0.0, 0.0], "print_path_list": [], "print_scale_list": [0.0, 0.0]}, "single": {"location": [], "print_angle_list": [], "print_path_list": [], "print_scale_list": []}},
"resize_scale": [1.0, 1.0], "type": "Outwear"}]}], "process_id": "3615898424593104"}
object_result = {}
with ThreadPoolExecutor() as executor:
results = list(executor.map(process_object, object['objects']))
for i, result in enumerate(results):
object_result[i] = result
pprint(object_result)
if __name__ == '__main__':
start_time = time.time()
run()
print(time.time() - start_time)

View File

@@ -1,55 +0,0 @@
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project trinity_client
@File upload_image.py
@Author :周成融
@Date 2023/8/28 13:49:20
@detail
"""
import io
import logging
import cv2
from app.core.config import *
from app.service.utils.decorator import RunTime
from app.service.utils.oss_client import oss_upload_image
# @RunTime
def upload_png_mask(front_image, object_name, mask=None):
try:
mask_url = None
if mask is not None:
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}"
# 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}"
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_png_mask(front_image, object_name, mask=None):
# mask_url = None
# if mask is not None:
# mask_url = f"{AIDA_CLOTHING}/mask/mask_{object_name}.png"
# image_url = f"{AIDA_CLOTHING}/image/image_{object_name}.png"
# return front_image, image_url, mask_url

View File

@@ -1,771 +0,0 @@
{
"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"
}

View File

@@ -1,27 +0,0 @@
import json
import pika
from app.service.design_batch.design_batch import batch_design
def publish_status(task_id, progress, result):
connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
channel = connection.channel()
channel.queue_declare(queue='DesignBatch', durable=True)
message = {'task_id': task_id, 'progress': progress, "result": result}
print(message)
channel.basic_publish(exchange='',
routing_key='DesignBatch',
body=json.dumps(message),
properties=pika.BasicProperties(
delivery_mode=2,
))
connection.close()
async def start_design_batch_generate(data, file):
generate_clothes_task = batch_design.delay(json.loads(file.decode())['objects'], data.total, data.tasks_id)
print(generate_clothes_task)
publish_status(data.tasks_id, "0/100", "")
return {"task_id": data.tasks_id}

View File

@@ -1,15 +0,0 @@
from app.service.design.service_design_batch_generate import design_batch_generate
if __name__ == '__main__':
data = {"objects": [{"basic": {"body_point_test": {"waistband_right": [200, 241], "hand_point_right": [223, 297], "waistband_left": [112, 241], "hand_point_left": [92, 305], "shoulder_left": [99, 116], "shoulder_right": [215, 116]}, "layer_order": True, "scale_bag": 0.7, "scale_earrings": 0.16, "self_template": True, "single_overall": "overall", "switch_category": ""}, "items": [
{"businessId": 270372, "color": "30 28 28", "image_id": 69780, "offset": [0, 0], "path": "aida-sys-image/images/female/trousers/0825000630.jpg", "seg_mask_url": "test/result.png",
"print": {"element": {"element_angle_list": [], "element_path_list": [], "element_scale_list": [], "location": []}, "overall": {"location": [], "print_angle_list": [], "print_path_list": [], "print_scale_list": []}, "single": {"location": [], "print_angle_list": [], "print_path_list": [], "print_scale_list": []}}, "priority": 10, "resize_scale": [1.0, 1.0], "type": "Trousers"},
{"businessId": 270373, "color": "30 28 28", "image_id": 98243, "offset": [0, 0], "path": "aida-sys-image/images/female/blouse/0902003811.jpg", "seg_mask_url": "test/result.png",
"print": {"element": {"element_angle_list": [], "element_path_list": [], "element_scale_list": [], "location": []}, "overall": {"location": [], "print_angle_list": [], "print_path_list": [], "print_scale_list": []}, "single": {"location": [], "print_angle_list": [], "print_path_list": [], "print_scale_list": []}}, "priority": 11, "resize_scale": [1.0, 1.0], "type": "Blouse"},
{"businessId": 270374, "color": "172 68 68", "image_id": 98244, "offset": [0, 0], "path": "aida-sys-image/images/female/outwear/0825000410.jpg", "seg_mask_url": "test/result.png",
"print": {"element": {"element_angle_list": [], "element_path_list": [], "element_scale_list": [], "location": []}, "overall": {"location": [], "print_angle_list": [], "print_path_list": [], "print_scale_list": []}, "single": {"location": [], "print_angle_list": [], "print_path_list": [], "print_scale_list": []}}, "priority": 12, "resize_scale": [1.0, 1.0], "type": "Outwear"},
{"body_path": "aida-sys-image/models/female/5bdfe7ca-64eb-44e4-b03d-8e517520c795.png", "image_id": 96090, "type": "Body"}]}], "process_id": "83"}
total_steps = 1
task_id = 1
design_batch_generate.delay(data['objects'], total_steps, task_id)
# publish_status(task_id="0/100", progress=100)