编程技术网

关注微信公众号,定时推送前沿、专业、深度的编程技术资料。

 找回密码
 立即注册

QQ登录

只需一步,快速开始

极客时间

在服务器上托管Python并从React Expo App调用:Host Python on server and call from React Expo App

Rahul Jha Python 2022-5-11 10:58 9人围观

腾讯云服务器
在服务器上托管Python并从React Expo App调用的处理方法

我正在开发一个使用机器学习的应用程序,最近遇到了问题.我发现Expo和Python并不能真正协同工作.

I am working on an app that uses machine learning, and recently run into a problem. I found out that Expo and Python do not really work together.

我认为一种解决方案是在服务器上托管并运行我的机器学习模型(Python),然后从我的JS Expo应用程序发出请求,并且我认为与之相比,这样做还具有更快处理速度的隐藏优势.只是在我的笔记本电脑上.

I thought that a solution would be to host and run my machine learning model (Python) on a server, and then make requests from my JS Expo app, and I thought this would also have the hidden bonus of faster processing compared to just on my laptop.

因此,人们是否可以首先确认是否可行(从JS Expo应用程序调用服务器上运行的python代码),如果可以,然后提供一些有关在何处托管此代码的建议?

So, can people confirm whether firstly this is possible (to call python code running on a server, from a JS Expo app) and if so, then provide some recommendations as to where I can host this?

这是一个大学项目,所以我希望能找到免费或便宜的东西,谢谢.

This is for a university project, so I am hoping to find something either free or cheap, thanks.

问题解答

我认为,与仅在笔记本电脑上相比,它还具有更快处理的隐藏优势.

I thought this would also have the hidden bonus of faster processing compared to just on my laptop.

如果您想免费使用它,那么任何云上最低层的实例将具有1个或2个核心以及1-2 GB的RAM,它将不会比您的本地设备更强大,并且将没有任何硬件加速,但是如果您打算在手机上运行它,那可能就足够了

If you want to do it for free then lowest tier instances on any cloud will have 1 or 2 cores plus 1-2 GB of RAM, it won't be stronger than your local device and it won't have any hardware acceleration, but if you planned to run that on your phone then it might be enough

因此,人们能否首先确认是否可行(从JS Expo应用程序调用服务器上运行的python代码)

So, can people confirm whether firstly this is possible (to call python code running on a server, from a JS Expo app)

简短的回答是,但是您提出此问题的方式确实表明您不知道这种交流将如何进行.您需要

Short answer yes, but The way you formulated this question does suggest that you don't know how this communication would work. You would need to

  • 将来自expo应用程序的http请求发送到服务器上的某个终结点
  • 可以接受该请求的实现服务器代码,在您的情况下,最好在python中完成(使用django或flask).
  • 在您的服务器代码中执行张量流代码
  • 如果tensorflow代码快速执行,则可以在响应中发送结果;否则,您将需要第二个端点来检查结果

这是一个大学项目,所以我希望能找到免费或便宜的东西,谢谢.

This is for a university project, so I am hoping to find something either free or cheap, thanks.

对于本地开发,您将需要以任何一种方式在本地托管它,对于大学项目来说应该足够了,但是如果您希望将其放在公共服务器上,则可以在几乎任何云服务上获得免费套餐或一些起始积分,例如数字海洋为学生提供100美元的信用额

for local development you will need to host it locally either way, for university project it should be enough, but if you want to have it on public server you can get free tier or some starting credits on almost any cloud service e.g. digital ocean gives 100$ credit for students

或者,您可以在react-native应用程序中使用tensorflow,只是无法在python中使用它, 查看全文

腾讯云服务器 阿里云服务器
关注微信
^