feat 新增接口描述 docs页面 ,新增S3 图片get upload 操作,整理代码
fix
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
|
import random
|
||||||
|
|
||||||
from .builder import ITEMS
|
from .builder import ITEMS
|
||||||
from .clothing import Clothing
|
from .clothing import Clothing
|
||||||
import random
|
|
||||||
|
|
||||||
|
|
||||||
@ITEMS.register_module()
|
@ITEMS.register_module()
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import cv2
|
import cv2
|
||||||
|
|
||||||
from .builder import ITEMS
|
from .builder import ITEMS
|
||||||
from .pipelines import Compose
|
from .pipelines import Compose
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import logging
|
|
||||||
|
|
||||||
from ..builder import PIPELINES
|
|
||||||
import cv2
|
import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
from ..builder import PIPELINES
|
||||||
|
|
||||||
|
|
||||||
@PIPELINES.register_module()
|
@PIPELINES.register_module()
|
||||||
class ContourDetection(object):
|
class ContourDetection(object):
|
||||||
@@ -11,7 +10,7 @@ class ContourDetection(object):
|
|||||||
# logging.info("ContourDetection run ")
|
# logging.info("ContourDetection run ")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#@ RunTime
|
# @ RunTime
|
||||||
def __call__(self, result):
|
def __call__(self, result):
|
||||||
# shoe diff
|
# shoe diff
|
||||||
if result['name'] == 'shoes':
|
if result['name'] == 'shoes':
|
||||||
|
|||||||
@@ -1,12 +1,5 @@
|
|||||||
import io
|
|
||||||
import logging
|
|
||||||
|
|
||||||
import cv2
|
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 app.service.utils.oss_client import oss_get_image
|
||||||
from ..builder import PIPELINES
|
from ..builder import PIPELINES
|
||||||
|
|
||||||
@@ -17,11 +10,7 @@ class LoadImageFromFile(object):
|
|||||||
self.path = path
|
self.path = path
|
||||||
self.color = color
|
self.color = color
|
||||||
self.print_dict = print_dict
|
self.print_dict = print_dict
|
||||||
self.minio_client = Minio(
|
# self.minio_client = Minio(f"{MINIO_URL}", access_key=MINIO_ACCESS, secret_key=MINIO_SECRET, secure=MINIO_SECURE)
|
||||||
f"{MINIO_URL}",
|
|
||||||
access_key=MINIO_ACCESS,
|
|
||||||
secret_key=MINIO_SECRET,
|
|
||||||
secure=MINIO_SECURE)
|
|
||||||
|
|
||||||
def __call__(self, result):
|
def __call__(self, result):
|
||||||
result['image'], result['pre_mask'] = self.read_image(self.path)
|
result['image'], result['pre_mask'] = self.read_image(self.path)
|
||||||
@@ -53,11 +42,13 @@ class LoadImageFromFile(object):
|
|||||||
f"bag, shoes, hairstyle, earring.")
|
f"bag, shoes, hairstyle, earring.")
|
||||||
return keypoint
|
return keypoint
|
||||||
|
|
||||||
def read_image(self, image_path):
|
@staticmethod
|
||||||
|
def read_image(image_path):
|
||||||
image_mask = None
|
image_mask = None
|
||||||
file = self.minio_client.get_object(image_path.split("/", 1)[0], image_path.split("/", 1)[1]).data
|
# 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 = 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:
|
if len(image.shape) == 2:
|
||||||
image = cv2.cvtColor(image, cv2.COLOR_GRAY2RGB)
|
image = cv2.cvtColor(image, cv2.COLOR_GRAY2RGB)
|
||||||
if image.shape[2] == 4: # 如果是四通道 mask
|
if image.shape[2] == 4: # 如果是四通道 mask
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import random
|
import random
|
||||||
|
|
||||||
# import boto3
|
|
||||||
import cv2
|
import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
@@ -9,12 +8,6 @@ from app.service.utils.oss_client import oss_get_image
|
|||||||
from ..builder import PIPELINES
|
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()
|
@PIPELINES.register_module()
|
||||||
class Painting(object):
|
class Painting(object):
|
||||||
def __init__(self, painting_flag=True):
|
def __init__(self, painting_flag=True):
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
from ..builder import PIPELINES
|
|
||||||
import math
|
import math
|
||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
|
|
||||||
|
from ..builder import PIPELINES
|
||||||
|
|
||||||
|
|
||||||
@PIPELINES.register_module()
|
@PIPELINES.register_module()
|
||||||
class Scaling(object):
|
class Scaling(object):
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
from PIL import Image
|
||||||
from cv2 import cvtColor, COLOR_BGR2RGBA
|
from cv2 import cvtColor, COLOR_BGR2RGBA
|
||||||
|
|
||||||
from app.service.utils.generate_uuid import generate_uuid
|
from app.service.utils.generate_uuid import generate_uuid
|
||||||
from ..builder import PIPELINES
|
from ..builder import PIPELINES
|
||||||
from PIL import Image
|
|
||||||
from ...utils.conversion_image import rgb_to_rgba
|
from ...utils.conversion_image import rgb_to_rgba
|
||||||
from ...utils.upload_image import upload_png_mask
|
from ...utils.upload_image import upload_png_mask
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,9 @@
|
|||||||
import io
|
|
||||||
import logging
|
|
||||||
import time
|
|
||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
from .builder import ITEMS
|
from .builder import ITEMS
|
||||||
from .clothing import Clothing
|
from .clothing import Clothing
|
||||||
from PIL import Image
|
|
||||||
|
|
||||||
from ..utils.conversion_image import rgb_to_rgba
|
from ..utils.conversion_image import rgb_to_rgba
|
||||||
from ..utils.upload_image import upload_png_mask
|
from ..utils.upload_image import upload_png_mask
|
||||||
from ...utils.generate_uuid import generate_uuid
|
from ...utils.generate_uuid import generate_uuid
|
||||||
|
|||||||
@@ -19,5 +19,6 @@ def rgb_to_rgba(rgb_size, rgb_image, mask):
|
|||||||
rgba_image[:, :, 3] = alpha_channel
|
rgba_image[:, :, 3] = alpha_channel
|
||||||
return rgba_image
|
return rgba_image
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
image = open("")
|
image = open("")
|
||||||
|
|||||||
@@ -8,12 +8,14 @@
|
|||||||
@detail :发起请求 获取推理结果
|
@detail :发起请求 获取推理结果
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
import mmcv
|
import mmcv
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import tritonclient.http as httpclient
|
|
||||||
import torch
|
import torch
|
||||||
import torch.nn.functional as F
|
import torch.nn.functional as F
|
||||||
|
import tritonclient.http as httpclient
|
||||||
|
|
||||||
from app.core.config import *
|
from app.core.config import *
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -10,30 +10,13 @@
|
|||||||
import io
|
import io
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
# import boto3
|
|
||||||
import cv2
|
import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from minio import Minio
|
|
||||||
|
|
||||||
from app.core.config import *
|
|
||||||
from app.service.utils.generate_uuid import generate_uuid
|
from app.service.utils.generate_uuid import generate_uuid
|
||||||
from app.service.utils.oss_client import oss_upload_image
|
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
|
|
||||||
# )
|
|
||||||
|
|
||||||
|
|
||||||
def positioning(all_mask_shape, mask_shape, offset):
|
def positioning(all_mask_shape, mask_shape, offset):
|
||||||
all_start = 0
|
all_start = 0
|
||||||
@@ -176,4 +159,9 @@ def synthesis_single(front_image, back_image):
|
|||||||
result_image.save(image_data, format='PNG')
|
result_image.save(image_data, format='PNG')
|
||||||
image_data.seek(0)
|
image_data.seek(0)
|
||||||
image_bytes = image_data.read()
|
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}"
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ if __name__ == '__main__':
|
|||||||
# url = "aida-users/87/print/956614a2-7e75-4fbe-9ed0-c1831e37a2c9-4-87.png"
|
# 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/single_logo/123-89.png"
|
||||||
# url = "aida-users/89/product_image/string-89.png"
|
# url = "aida-users/89/product_image/string-89.png"
|
||||||
url = "aida-users/10/models/female/9c788f5b-b8c7-424c-b149-025aeb0bda51model.png"
|
url = "aida-clothing/mask/mask_773e270b-3369-11ef-abe4-b0dcefbff887.png"
|
||||||
read_type = "PIL"
|
read_type = "PIL"
|
||||||
if read_type == "cv2":
|
if read_type == "cv2":
|
||||||
img = oss_get_image(bucket=url.split('/')[0], object_name=url[url.find('/') + 1:], data_type=read_type)
|
img = oss_get_image(bucket=url.split('/')[0], object_name=url[url.find('/') + 1:], data_type=read_type)
|
||||||
|
|||||||
Reference in New Issue
Block a user