colab如何共享_如何在colab上运行和共享您的深度学习Web应用

colab如何共享

介绍 (Introduction)

In my previous work, I built a deep learning model using Fastai to colorize black and white photos and built a web app prototype using Streamlit. I wish to share it with my colleagues and friends to get some feedback, so I tried to deploy the web app to AWS and Heroku.

在我以前的工作中,我使用Fastai构建了一个深度学习模型来对黑白照片进行彩色处理,并使用Streamlit构建了一个Web应用程序原型。 我希望与同事和朋友分享它以获得一些反馈,因此我尝试将Web应用程序部署到AWS和Heroku。

I was able to deploy my app to these cloud service providers and run it, however, the free tier accounts of them do not provide enough memory for my app, it crashed all the time. To have at least something running online, I had to make the size of the photos small, resulting in very poor quality. I do not want to spend a lot of money on upgrading the account at this early stage. I just want a quick prototype running with full functionality so I can test it and get some feedback.

我能够将我的应用程序部署到这些云服务提供商并运行它,但是,它们的免费层帐户没有为我的应用程序提供足够的内存,并且一直崩溃。 为了至少使某些内容在线运行,我不得不缩小照片的尺寸,从而导致质量很差。 我不想在此初期花很多钱来升级帐户。 我只想运行一个具有完整功能的快速原型,以便我可以对其进行测试并获得一些反馈。

Since then, I have been looking for other solutions to deploy and share the app. One solution I found is to run the app on Google Colab, using its free and powerful computation service. In this short post, I will describe how I run the web app on Colab.

从那时起,我一直在寻找其他解决方案来部署和共享该应用程序。 我发现的一种解决方案是使用其免费且强大的计算服务在Google Colab上运行该应用程序。 在这篇简短的文章中,我将描述如何在Colab上运行Web应用程序。

Stremlit (Stremlit)

In case you are not familiar with Stremlit, it is a powerful tool to create simple web applications in Python. It is very convenient for people without web development background and skills like me.

如果您不熟悉Stremlit ,它是使用Python创建简单的Web应用程序的强大工具。 对于没有Web开发背景和技能的人来说,这非常方便。

They offer a nice tutorial for beginners.

他们为初学者提供了不错的教程。

I also documented my work building the web app using Stremlit in this post:

在这篇文章中,我还记录了我使用Stremlit构建Web应用程序的工作:

在Colab上运行应用 (Run the app on Colab)

Once you have the web app running locally successfully, you can try to run it on Google Colab

网络应用程序在本地成功运行后,您可以尝试在Google Colab上运行它

First, clone the app to colab and enter the directory.

首先,克隆应用以进行协作并输入目录。

!git clone http://github.com/xxx/xxxxx.git color
cd color

then install the requirements

然后安装需求

!pip install -r requirements_colab.txt

In my case, it contains stremlit, opencv, fastai, and scikit_image.

就我而言,它包含stremlit,opencv,fastai和scikit_image。

then we need to install pyngrok.

然后我们需要安装pyngrok。

!pip install pyngrok

To run and share the app by a public URL on Colab, we need to use ngrok, which is a secure tunneling solution. You can find the details here.

要通过Colab上的公共URL运行和共享应用程序,我们需要使用ngrok,这是一种安全的隧道解决方案。 您可以在此处找到详细信息。

After the installation, we can run the app in the background.

安装后,我们可以在后台运行该应用程序。

!streamlit run run.py &>/dev/null&

then create the public URL using ngrok.

然后使用ngrok创建公共URL。

from pyngrok import ngrok
# Setup a tunnel to the streamlit port 8501
public_url = ngrok.connect(port='8501')
public_url

you should get an URL like this “http://ea41c43860d1.ngrok.io”.

您应该获得像这样的URL“ http://ea41c43860d1.ngrok.io ”。

That is it! Really simple steps. Now the web app is available online utilizing the powerful Google Colab for free.

这就对了! 真的很简单的步骤。 现在可以免费使用强大的Google Colab在线使用该Web应用程序。

Photo by Aziz Acharki on Unsplash 阿齐兹·阿查 尔基 ( Aziz Acharki)在 Unsplash上 拍摄

The advantage of running a web app on Colab is that the app is not limited by the limited computation of free tier accounts, you can even have a runtime with GPU. However, the major drawback of it is the URL is only temporary, once the Colab is disconnected, the URL will be disabled. So you can only share the link for a short period (<12hrs). But I think it is still a good approach to quickly deploy, test, and share a web app prototype.

在Colab上运行Web应用程序的优势在于,该应用程序不受免费层帐户的有限计算限制,您甚至可以使用GPU来运行。 但是,它的主要缺点是URL只是临时的,一旦Colab断开连接,URL将被禁用。 因此,您只能在短时间内(<12小时)共享链接。 但是我认为这仍然是快速部署,测试和共享Web应用程序原型的好方法。

Thanks for reading. Suggestions and comments are welcome.

谢谢阅读。 欢迎提出建议和意见。

翻译自: https://towardsdatascience.com/how-to-run-and-share-your-deep-learning-web-app-on-colab-a13f9d2cbc4e

colab如何共享

你可能感兴趣的:(python,深度学习,java,机器学习,tensorflow)