feat 产品图打光模型部署
fix
This commit is contained in:
@@ -16,8 +16,11 @@ from PIL import Image
|
||||
from minio import Minio
|
||||
|
||||
from app.core.config import *
|
||||
from app.service.utils.oss_client import oss_upload_image
|
||||
|
||||
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)
|
||||
|
||||
|
||||
@@ -34,36 +37,34 @@ minio_client = Minio(MINIO_URL, access_key=MINIO_ACCESS, secret_key=MINIO_SECRET
|
||||
# except Exception as e:
|
||||
# print(f'上传到 S3 失败: {e}')
|
||||
|
||||
def upload_SDXL_image(image, user_id, category, object_name):
|
||||
def upload_SDXL_image(image, user_id, category, file_name):
|
||||
try:
|
||||
image_data = io.BytesIO()
|
||||
image.save(image_data, format='PNG')
|
||||
image_data.seek(0)
|
||||
image_bytes = image_data.read()
|
||||
minio_req = minio_client.put_object(
|
||||
GI_MINIO_BUCKET,
|
||||
f'{user_id}/{category}/{object_name}',
|
||||
io.BytesIO(image_bytes),
|
||||
len(image_bytes),
|
||||
content_type='image/jpeg'
|
||||
)
|
||||
image_url = f"aida-users/{minio_req.object_name}"
|
||||
|
||||
# minio_req = minio_client.put_object(
|
||||
# GI_MINIO_BUCKET,
|
||||
# f'{user_id}/{category}/{file_name}',
|
||||
# io.BytesIO(image_bytes),
|
||||
# len(image_bytes),
|
||||
# content_type='image/jpeg'
|
||||
# )
|
||||
object_name = f'{user_id}/{category}/{file_name}'
|
||||
req = oss_upload_image(bucket=GI_MINIO_BUCKET, object_name=object_name, image_bytes=image_bytes)
|
||||
image_url = f"aida-users/{object_name}"
|
||||
return image_url
|
||||
except Exception as e:
|
||||
logging.warning(f"upload_png_mask runtime exception : {e}")
|
||||
|
||||
|
||||
def upload_png_sd(image, user_id, category, object_name):
|
||||
def upload_png_sd(image, user_id, category, file_name):
|
||||
try:
|
||||
_, img_byte_array = cv2.imencode('.jpg', image)
|
||||
minio_req = minio_client.put_object(
|
||||
GI_MINIO_BUCKET,
|
||||
f'{user_id}/{category}/{object_name}',
|
||||
io.BytesIO(img_byte_array),
|
||||
len(img_byte_array),
|
||||
content_type='image/jpeg'
|
||||
)
|
||||
image_url = f"aida-users/{minio_req.object_name}"
|
||||
object_name = f'{user_id}/{category}/{file_name}'
|
||||
req = oss_upload_image(bucket=GI_MINIO_BUCKET, object_name=object_name, image_bytes=img_byte_array)
|
||||
image_url = f"aida-users/{object_name}"
|
||||
return image_url
|
||||
except Exception as e:
|
||||
logging.warning(f"upload_png_mask runtime exception : {e}")
|
||||
|
||||
Reference in New Issue
Block a user