feat product image 新增product type 参数 ,解决single item 无法检测头部的问题
fix
This commit is contained in:
@@ -34,13 +34,14 @@ def attribute_recognition(request_item: list[AttributeRecognitionModel]):
|
||||
]
|
||||
"""
|
||||
try:
|
||||
logger.info(f"attribute_recognition request item is : @@@@@@:{request_item}")
|
||||
for item in request_item:
|
||||
logger.info(f"attribute_recognition request item is : @@@@@@:{json.dumps(item.dict())}")
|
||||
if DEBUG:
|
||||
service = AttributeRecognition(const=local_debug_const, request_data=request_item)
|
||||
else:
|
||||
service = AttributeRecognition(const=const, request_data=request_item)
|
||||
data = service.get_result()
|
||||
logger.info(f"attribute_recognition response @@@@@@:{json.dumps(data, indent=4)}")
|
||||
logger.info(f"attribute_recognition response @@@@@@:{json.dumps(data)}")
|
||||
except Exception as e:
|
||||
logger.warning(f"attribute_recognition Run Exception @@@@@@:{e}")
|
||||
raise HTTPException(status_code=404, detail=str(e))
|
||||
@@ -65,10 +66,11 @@ def category_recognition(request_item: list[CategoryRecognitionModel]):
|
||||
]
|
||||
"""
|
||||
try:
|
||||
logger.info(f"category_recognition request item is : @@@@@@:{request_item}")
|
||||
for item in request_item:
|
||||
logger.info(f"category_recognition request item is : @@@@@@:{json.dumps(item.dict())}")
|
||||
service = CategoryRecognition(request_data=request_item)
|
||||
data = service.get_result()
|
||||
logger.info(f"category_recognition response @@@@@@:{json.dumps(data, indent=4)}")
|
||||
logger.info(f"category_recognition response @@@@@@:{json.dumps(data)}")
|
||||
except Exception as e:
|
||||
logger.warning(f"category_recognition Run Exception @@@@@@:{e}")
|
||||
raise HTTPException(status_code=404, detail=str(e))
|
||||
|
||||
@@ -30,9 +30,9 @@ def chat_robot(request_data: ChatRobotModel):
|
||||
}
|
||||
"""
|
||||
try:
|
||||
logger.info(f"chat_robot request item is : @@@@@@:{request_data}")
|
||||
logger.info(f"chat_robot request item is : @@@@@@:{json.dumps(request_data.dict())}")
|
||||
data = chat(post_data=request_data)
|
||||
logger.info(f"chat_robot response @@@@@@:{json.dumps(data, indent=4)}")
|
||||
logger.info(f"chat_robot response @@@@@@:{json.dumps(data)}")
|
||||
except Exception as e:
|
||||
logger.warning(f"chat_robot Run Exception @@@@@@:{e}")
|
||||
raise HTTPException(status_code=404, detail=str(e))
|
||||
|
||||
@@ -66,22 +66,57 @@ def design(request_data: DesignModel):
|
||||
],
|
||||
"path": "aida-users/89/sketch/c89d75f3-581f-4edd-9f8e-b08e84a2cbe7-3-89.png",
|
||||
"print": {
|
||||
"IfSingle": false,
|
||||
"location": [
|
||||
[
|
||||
512.0,
|
||||
512.0
|
||||
"single": {
|
||||
"location": [
|
||||
[
|
||||
200.0,
|
||||
200.0
|
||||
]
|
||||
],
|
||||
"print_angle_list": [
|
||||
0.0
|
||||
],
|
||||
"print_path_list": [
|
||||
"aida-users/89/slogan_image/ce0b2423-9e5a-466f-9611-c254940a7819-1-89.png"
|
||||
],
|
||||
"print_scale_list": [
|
||||
1.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
|
||||
]
|
||||
},
|
||||
"overall": {
|
||||
"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
|
||||
]
|
||||
},
|
||||
"element": {
|
||||
"element_angle_list": [
|
||||
0.0
|
||||
],
|
||||
"element_path_list": [
|
||||
"aida-users/88/designelements/Embroidery/a4d9605a-675e-4606-93e0-77ca6baaf55f.png"
|
||||
],
|
||||
"element_scale_list": [
|
||||
0.2731036750637755
|
||||
],
|
||||
"location": [
|
||||
[
|
||||
228.63694825464364,
|
||||
406.4843844199667
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"priority": 10,
|
||||
"resize_scale": [
|
||||
@@ -102,9 +137,9 @@ def design(request_data: DesignModel):
|
||||
}
|
||||
"""
|
||||
try:
|
||||
logger.info(f"design request item is : @@@@@@:{request_data.dict()}")
|
||||
logger.info(f"design request item is : @@@@@@:{json.dumps(request_data.dict())}")
|
||||
data = generate(request_data=request_data)
|
||||
logger.info(f"design response @@@@@@:{json.dumps(data, indent=4)}")
|
||||
logger.info(f"design response @@@@@@:{json.dumps(data)}")
|
||||
except Exception as e:
|
||||
logger.warning(f"design Run Exception @@@@@@:{e}")
|
||||
raise HTTPException(status_code=404, detail=str(e))
|
||||
@@ -124,13 +159,13 @@ def get_progress(request_data: DesignProgressModel):
|
||||
}
|
||||
"""
|
||||
try:
|
||||
logger.info(f"get_progress request item is : @@@@@@:{request_data.dict()}")
|
||||
logger.info(f"get_progress request item is : @@@@@@:{json.dumps(request_data.dict())}")
|
||||
process_id = request_data.process_id
|
||||
r = Redis()
|
||||
data = r.read(key=process_id)
|
||||
if data is None:
|
||||
raise ValueError(f"No progress ID: {process_id}")
|
||||
logging.info(f"get_progress process_id @@@@@@ : {process_id} , progress : {data}")
|
||||
logging.info(f"get_progress process_id @@@@@@ : {process_id} , progress : {json.dumps(data)}")
|
||||
except Exception as e:
|
||||
logger.warning(f"get_progress Run Exception @@@@@@:{e}")
|
||||
raise HTTPException(status_code=404, detail=str(e))
|
||||
@@ -150,10 +185,10 @@ def model_process(request_data: ModelProgressModel):
|
||||
}
|
||||
"""
|
||||
try:
|
||||
logger.info(f"model_process request item is : @@@@@@:{request_data.dict()}")
|
||||
logger.info(f"model_process request item is : @@@@@@:{json.dumps(request_data.dict())}")
|
||||
|
||||
data = model_transpose(image_path=request_data.model_path)
|
||||
logger.info(f"model_process response @@@@@@:{json.dumps(data, indent=4)}")
|
||||
logger.info(f"model_process response @@@@@@:{json.dumps(data)}")
|
||||
except Exception as e:
|
||||
logger.warning(f"model_process Run Exception @@@@@@:{e}")
|
||||
raise HTTPException(status_code=404, detail=str(e))
|
||||
|
||||
@@ -30,10 +30,10 @@ def design_pre_processing(request_data: DesignPreProcessingModel):
|
||||
}
|
||||
"""
|
||||
try:
|
||||
logger.info(f"design_pre_processing request item is : @@@@@@:{request_data}")
|
||||
logger.info(f"design_pre_processing request item is : @@@@@@:{json.dumps(request_data)}")
|
||||
server = DesignPreprocessing()
|
||||
data = server.pipeline(image_list=request_data.sketches)
|
||||
logger.info(f"design response @@@@@@:{json.dumps(data, indent=4)}")
|
||||
logger.info(f"design response @@@@@@:{json.dumps(data)}")
|
||||
except Exception as e:
|
||||
logger.warning(f"design Run Exception @@@@@@:{e}")
|
||||
raise HTTPException(status_code=404, detail=str(e))
|
||||
|
||||
@@ -38,7 +38,7 @@ def generate_image(request_item: GenerateImageModel, background_tasks: Backgroun
|
||||
}
|
||||
"""
|
||||
try:
|
||||
logger.info(f"generate_image request item is : @@@@@@:{request_item}")
|
||||
logger.info(f"generate_image request item is : @@@@@@:{json.dumps(request_item.dict())}")
|
||||
service = GenerateImage(request_item)
|
||||
background_tasks.add_task(service.get_result)
|
||||
except Exception as e:
|
||||
@@ -52,7 +52,7 @@ def generate_image(tasks_id: str):
|
||||
try:
|
||||
logger.info(f"generate_cancel request item is : @@@@@@:{tasks_id}")
|
||||
data = generate_image_infer_cancel(tasks_id)
|
||||
logger.info(f"generate_cancel response @@@@@@:{json.dumps(data, indent=4)}")
|
||||
logger.info(f"generate_cancel response @@@@@@:{data}")
|
||||
except Exception as e:
|
||||
logger.warning(f"generate_cancel Run Exception @@@@@@:{e}")
|
||||
raise HTTPException(status_code=404, detail=str(e))
|
||||
@@ -78,7 +78,7 @@ def generate_single_logo(request_item: GenerateSingleLogoImageModel, background_
|
||||
}
|
||||
"""
|
||||
try:
|
||||
logger.info(f"generate_single_logo request item is : @@@@@@:{request_item}")
|
||||
logger.info(f"generate_single_logo request item is : @@@@@@:{json.dumps(request_item.dict())}")
|
||||
service = GenerateSingleLogoImage(request_item)
|
||||
background_tasks.add_task(service.get_result)
|
||||
except Exception as e:
|
||||
@@ -92,7 +92,7 @@ def generate_single_logo_image(tasks_id: str):
|
||||
try:
|
||||
logger.info(f"generate_single_logo_cancel request item is : @@@@@@:{tasks_id}")
|
||||
data = generate_single_logo_cancel(tasks_id)
|
||||
logger.info(f"generate_single_logo_cancel response @@@@@@:{json.dumps(data, indent=4)}")
|
||||
logger.info(f"generate_single_logo_cancel response @@@@@@:{data}")
|
||||
except Exception as e:
|
||||
logger.warning(f"generate_single_logo_cancel Run Exception @@@@@@:{e}")
|
||||
raise HTTPException(status_code=404, detail=str(e))
|
||||
@@ -110,17 +110,20 @@ def generate_product_image(request_item: GenerateProductImageModel, background_t
|
||||
- **prompt**: 想要生成图片的描述词
|
||||
- **image_url**: 被生成图片的S3或minio url地址
|
||||
- **image_strength**: 生成强度,越低越接近原图
|
||||
- **product_type**: 输入single item 还是 overall item
|
||||
|
||||
|
||||
示例参数:
|
||||
{
|
||||
"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",
|
||||
"image_strength": 0.8
|
||||
"image_strength": 0.8,
|
||||
"product_type": "overall"
|
||||
}
|
||||
"""
|
||||
try:
|
||||
logger.info(f"generate_product_image request item is : @@@@@@:{request_item}")
|
||||
logger.info(f"generate_product_image request item is : @@@@@@:{json.dumps(request_item.dict())}")
|
||||
service = GenerateProductImage(request_item)
|
||||
background_tasks.add_task(service.get_result)
|
||||
except Exception as e:
|
||||
@@ -134,7 +137,7 @@ def generate_product_image(tasks_id: str):
|
||||
try:
|
||||
logger.info(f"generate_product_image_cancel_cancel request item is : @@@@@@:{tasks_id}")
|
||||
data = generate_product_image_cancel(tasks_id)
|
||||
logger.info(f"generate_product_image_cancel_cancel response @@@@@@:{json.dumps(data, indent=4)}")
|
||||
logger.info(f"generate_product_image_cancel_cancel response @@@@@@:{data}")
|
||||
except Exception as e:
|
||||
logger.warning(f"generate_product_image_cancel_cancel Run Exception @@@@@@:{e}")
|
||||
raise HTTPException(status_code=404, detail=str(e))
|
||||
@@ -162,7 +165,7 @@ def generate_relight_image(request_item: GenerateRelightImageModel, background_t
|
||||
}
|
||||
"""
|
||||
try:
|
||||
logger.info(f"generate_relight_image request item is : @@@@@@:{request_item}")
|
||||
logger.info(f"generate_relight_image request item is : @@@@@@:{json.dumps(request_item.dict())}")
|
||||
service = GenerateRelightImage(request_item)
|
||||
background_tasks.add_task(service.get_result)
|
||||
except Exception as e:
|
||||
@@ -176,7 +179,7 @@ def generate_relight_image(tasks_id: str):
|
||||
try:
|
||||
logger.info(f"generate_relight_image_cancel_cancel request item is : @@@@@@:{tasks_id}")
|
||||
data = generate_relight_image_cancel(tasks_id)
|
||||
logger.info(f"generate_relight_image_cancel_cancel response @@@@@@:{json.dumps(data, indent=4)}")
|
||||
logger.info(f"generate_relight_image_cancel_cancel response @@@@@@:{data}")
|
||||
except Exception as e:
|
||||
logger.warning(f"generate_relight_image_cancel_cancel Run Exception @@@@@@:{e}")
|
||||
raise HTTPException(status_code=404, detail=str(e))
|
||||
|
||||
@@ -27,7 +27,7 @@ def prompt_generation(request_data: PromptGenerationImageModel):
|
||||
try:
|
||||
logger.info(f"prompt_generation request item is : @@@@@@:{request_data}")
|
||||
data = translate_to_en(request_data.text)
|
||||
logger.info(f"prompt_generation response @@@@@@:{json.dumps(data, indent=4)}")
|
||||
logger.info(f"prompt_generation response @@@@@@:{data}")
|
||||
except Exception as e:
|
||||
logger.warning(f"prompt_generation Run Exception @@@@@@:{e}")
|
||||
raise HTTPException(status_code=404, detail=str(e))
|
||||
|
||||
@@ -27,7 +27,7 @@ def super_resolution(request_item: SuperResolutionModel, background_tasks: Backg
|
||||
}
|
||||
"""
|
||||
try:
|
||||
logger.info(f"super_resolution request item is : @@@@@@:{request_item}")
|
||||
logger.info(f"super_resolution request item is : @@@@@@:{json.dumps(request_item.dict())}")
|
||||
service = SuperResolution(request_item)
|
||||
background_tasks.add_task(service.sr_result)
|
||||
except Exception as e:
|
||||
@@ -41,7 +41,7 @@ def super_resolution(tasks_id: str):
|
||||
try:
|
||||
logger.info(f"sr_cancel request item is : @@@@@@:{tasks_id}")
|
||||
data = infer_cancel(tasks_id)
|
||||
logger.info(f"sr_cancel response @@@@@@:{json.dumps(data, indent=4)}")
|
||||
logger.info(f"sr_cancel response @@@@@@:{data}")
|
||||
except Exception as e:
|
||||
logger.warning(f"sr_cancel Run Exception @@@@@@:{e}")
|
||||
raise HTTPException(status_code=404, detail=str(e))
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import json
|
||||
import logging
|
||||
from fastapi import APIRouter
|
||||
from app.core.config import SR_RABBITMQ_QUEUES, GI_RABBITMQ_QUEUES, GPI_RABBITMQ_QUEUES, GRI_RABBITMQ_QUEUES, OSS
|
||||
from fastapi import FastAPI, HTTPException
|
||||
|
||||
from fastapi import APIRouter
|
||||
from fastapi import HTTPException
|
||||
|
||||
from app.core.config import SR_RABBITMQ_QUEUES, GI_RABBITMQ_QUEUES, GPI_RABBITMQ_QUEUES, GRI_RABBITMQ_QUEUES, OSS
|
||||
from app.schemas.response_template import ResponseModel
|
||||
|
||||
logger = logging.getLogger()
|
||||
@@ -18,7 +20,7 @@ def test(id: int):
|
||||
"GRI_RABBITMQ_QUEUES": GRI_RABBITMQ_QUEUES,
|
||||
"local_oss_server": OSS
|
||||
}
|
||||
logger.info(data)
|
||||
logger.info(json.dumps(data))
|
||||
if id == 1:
|
||||
raise HTTPException(status_code=404, detail="Item not found")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user