Google App引擎部署
这是一种使用Google App Engine Custom Runtims部署培训的型号的快速指南。本指南附带了一个初学应用程序部署Jeremy的熊映像分类模型表格2。
抓取Google App Engine Starter Pack,用于模型部署
wget //github.com/fastai/course-v3/raw/master/docs/production/google-app-engine.zip
unzip google-app-engine.zip
cd google-app-engine/app
每个项目设置
上传培训的模型文件
Upload your trained model file (for example stage-2.pth) to a cloud service like Google Drive or Dropbox. Copy the download link for the file. Note: the download link is the one which starts the file download directly and is normally different than the share link which presents you with a view to download the file (use //rawdownload.now.sh/ if needed)
如果您想最初测试部署,可以使用Jeremy的Bear分类模型从第2课,您可以跳过此步骤,因为该模型的权重URL已填写在示例应用程序中。
为您的模型自定义应用程序
在App目录内打开文件Server.py并更新 model_file_url. 随下载URL复制的变量 在同一文件中,更新行
classes = ['black', 'grizzly', 'teddys']
使用您期望的课程。
将您的自定义应用程序上传到GitHub
将自定义的应用目录推到GitHub& 复制repo url
部署
首先,打开Google云仪表板,单击 创建项目 然后命名新的GCP项目。通过创建新的结算帐户或设置现有结算帐户或设置现有的新的GCP项目中的结算。您将在屏幕下显示:
创建一个新项目后,您将介绍GCP仪表板页面,转到页面的最右上角,然后单击 激活云壳.
注意:如果您只注册了新的Google云帐户,可能需要几分钟,以前 激活云壳 is enable.
终端窗口将在同一页面上打开。
在Shell终端中,创建Google App Engine应用程序:
gcloud app create
然后选择靠近您的地理区域,然后按几分钟后按Enter键,它将显示类似的东西 “成功!该应用程序现已创建。请使用'gcloud应用程序部署'部署您的第一个应用程序“
例如,从Github下载您的自定义Starter Pack App存储库,这里是Fast.ai Google Cloud Engine Starter Pack:
git clone //github.com/pankymathur/google-app-engine
导航到您的应用程序目录:
cd google-app-engine
将应用程序部署到Google App Engine:
gcloud app deploy
您将显示一个显示“部署服务”的屏幕,输入y
应用引擎需要8〜10分钟部署基于Docker的应用程序并为您提供应用程序URL。
测试工作应用程序的URL
To see your final app open http://YOUR_PROJECT_ID.appspot.com or run the following command in browser shell to launch your app in the browser:
gcloud app browse
本地测试
如果要本地运行应用程序服务器,或者对上述步骤进行任何更改:
python app/server.py serve
转到http:// localhost:8080 /测试您的应用程序。
感谢Pankaj Mathur为本指南,以及Simon Willison for Sample Code。