diff --git a/app/service/utils/oss_client.py b/app/service/utils/oss_client.py index c2bb82c..370cd7c 100644 --- a/app/service/utils/oss_client.py +++ b/app/service/utils/oss_client.py @@ -28,6 +28,8 @@ def oss_get_image(bucket, object_name, data_type): image_bytes = image_data.read() image_array = np.frombuffer(image_bytes, np.uint8) # 转成8位无符号整型 image_object = cv2.imdecode(image_array, cv2.IMREAD_UNCHANGED) + if image_object.dtype == np.uint16: + image_object = (image_object / 256).astype('uint8') else: data_bytes = BytesIO(image_data.read()) image_object = Image.open(data_bytes) @@ -63,8 +65,8 @@ if __name__ == '__main__': # 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" + url = "aida-collection-element/12148/Sketchboard/95ea577b-305b-4a62-b30a-39c0dd3ddb3f.png" + 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) cv2.imshow("", img)