gpt4 book ai didi

python - 在Python Bluemix服务器中写入图像

转载 作者:行者123 更新时间:2023-12-02 17:42:03 26 4
gpt4 key购买 nike

我正在尝试在Python Blumix服务器中使用opencv处理后保存图像,但是发生错误。我正在读取推送应用程序时上传的本地镜像,但是无法在同一位置书写。

image = cv2.imread('static/images/image.jpg') #works

# do some process to the image...

cv2.imwrite('static/images/processed.jpg', processed_image) #works in local but not in server

我需要一些权限吗?特殊文件夹?服务器是只读的?

提前致谢

最佳答案

我可能希望将对象存储用于图像。如果您以后想要将代码拆分为微服务,这将为您提供更多选择。不建议使用本地存储:

Avoid Writing to the Local File System

Applications running on CloudFoundry should not write files to the local file system for thefollowing reasons:

  • Local file system storage is short-lived. When an application instancecrashes or stops, the resources assigned to that instance arereclaimed by the platform including any local disk changes made sincethe app started. When the instance is restarted, the application willstart with a new disk image. Although your application can write localfiles while it is running, the files will disappear after theapplication restarts.

  • Instances of the same application do not share alocal file system. Each application instance runs in its own isolatedcontainer. Thus a file written by one instance is not visible to otherinstances of the same application. If the files are temporary, thisshould not be a problem. However, if your application needs the datain the files to persist across application restarts, or the data needsto be shared across all running instances of the application, thelocal file system should not be used. We recommend using a shared dataservice like a database or blobstore for this purpose.

Source: https://docs.cloudfoundry.org/devguide/deploy-apps/prepare-to-deploy.html#filesystem

关于python - 在Python Bluemix服务器中写入图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43265308/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com