Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/300.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 预处理图像后将图像写入s3fs.S3文件系统_Python_Amazon S3_Python Imaging Library_Python S3fs - Fatal编程技术网

Python 预处理图像后将图像写入s3fs.S3文件系统

Python 预处理图像后将图像写入s3fs.S3文件系统,python,amazon-s3,python-imaging-library,python-s3fs,Python,Amazon S3,Python Imaging Library,Python S3fs,我目前正在从我的学校系统访问一个s3存储桶 为了连接,我使用了以下方法: import s3fs from skimage import exposure from PIL import Image, ImageStat s3 = s3fs.S3FileSystem(client_kwargs={'endpoint_url': 'XXX'}, key='XXX', secret='XXX') 我可以从

我目前正在从我的学校系统访问一个s3存储桶
为了连接,我使用了以下方法:

import s3fs
from skimage import exposure
from PIL import Image, ImageStat

s3 = s3fs.S3FileSystem(client_kwargs={'endpoint_url': 'XXX'},
                       key='XXX',
                       secret='XXX')
我可以从上面定义的s3 bucket中检索图像,并使用

infile = s3.open('test.jpg',"rb")
image = Image.open(infile)
img = np.asarray(image) #numpy.ndarray
img_eq = exposure.equalize_adapthist(img,clip_limit=0.03) #CLAHE
image_eq = Image.fromarray((img_eq * 255).astype(np.uint8)) #Convert back to image
要在本地保存生成的图像,只需

image_eq.save("hello.jpg")

但是,如何将生成的映像保存/写入s3fs文件系统?

在Pillow中保存
。你可以做:

 image_eq.save(fs.open('s3://bucket/file.png', 'wb'), 'PNG')

你必须写一个二进制文件。我认为最好是强制使用文件类型,例如在本例中为PNG。

在枕头中保存
也接受文件。你可以做:

 image_eq.save(fs.open('s3://bucket/file.png', 'wb'), 'PNG')

你必须写一个二进制文件。我认为最好是强制使用文件类型,例如,在本例中为PNG。

您找到解决方案了吗?@Simone遗憾的是,没有。我已经不再讨论这个问题了。很抱歉。你找到解决办法了吗?@Simone遗憾的是没有。我已经离开这个问题了。很抱歉。