![](/img/trans.png)
[英]Can I use ffmpeg to output jpgs to a numpy array in python without writing the files to disk etc?
[英]How can I load a numpy byte array that is stored in an S3 without writing it to disk?
我在S3中有一個numpy數組,我想將其加載到python腳本中。 使用boto3以以下方式上傳陣列:
s3.put_object(
Body=np.array(array).tobytes(),
Bucket='bucketname',
Key='filename'
)
我知道這是一個形狀為(1,356)的數組,並且具有dtype = float。
如何在不手動下載文件然后將其加載到numpy中的情況下,將其從S3放入python腳本中?
即使我手動下載文件,如何將其加載到numpy中?
我最終使它像這樣工作:
obj = s3.Bucket('bucketname').Object('key')
obj = obj.get()['Body']
f = np.frombuffer(obj.read())
其中s3是boto3.resource('s3')對象
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.