作家
登录

面向机器智能的TensorFlow实践:产品环境中模型的部署

作者: 来源: 2017-04-26 16:02:39 阅读 我要评论

], 
  •  
  • )  
  • 借助这段代码,便可经由过程敕令bazel run :server 9999 /tmp/inception-v3/export/{timestamp}安闲器中运行揣摸办事器。

    客户端应用

    因为gRPC是基于HTTP/2的,将来可能会直接大年夜浏览器调用基于gRPC的办事,但除非主流的浏览器支撑所需的HTTP/2特点,且谷歌宣布浏览器端的JavaScript gRPC客户端法度榜样,大年夜webapp拜访揣摸办事都应当经由过程办事器端的组件进行。

    接下来将基于BaseHTTPServer搭建一个简单的Python Web办事器,BaseHTTPServer将处理上载的图像文件,并将其发送给揣摸办事进行处理,再将揣摸结不雅以纯文本情势返回。

    为了将图像发送到揣摸办事器进行分类,办事器将以一个简单的表单对GET请求做出响应。所应用的代码如下:

    1. From BaseHTTPServer import HTTPServer,BaseHTTPRequestHandler 
    2.  
    3. import cgi 
    4.  
    5. import classification_service_pb2 
    6.  
    7. From grpc.beta import implementations 
    8.  
    9.  
    10. class ClientApp (BaseHTTPRequestHandler); 
    11.  
    12.    def do_GET(self): 
    13.  
    14. self.respond_form() 
    15.  
    16.  
    17.    def respond_form(self, response=""): 
    18.  
    19.  
    20.       form = ""
    21.  
    22. <html><body> 
    23.  
    24. <h1>Image classification service</h1> 
    25.  
    26. <form enctype="multipart/form-data" method="post"
    27.  
    28. <div>Image: <input type="file" name="file" 
    29.  
    30. accept="image/jpeg"></div> 
    31.  
    32.       <div><input type="submit" value=http://ai.51cto.com/art/201704/"Upload"></div> 
    33.  
    34. </form> 
    35.  
    36. %s 
    37.  
    38. </body></html> 
    39.  
    40. ""
    41.  
    42.  
    43. response = form % response 
    44.  
    45.  
    46. self.send_response(200) 
    47.  
    48. self.send_header("Content-type""text/html"
    49.  
    50. self.send_header("Content-length", len(response)) 
    51.  
    52. self.end_headers() 
    53.  
    54. self.wfile.write(response)  

    为了大年夜Web App办事器调用揣摸功能,须要ClassificationService响应的Python protocol buffer客户端。为了生成它,须要运行Python的protocol buffer编译器:

    1. pip install grpcio cython grpcio-tools 
    2.  
    3. python -m grpc.tools.protoc -I. --python_out=. --

        推荐阅读

        传统存储市场正遭遇来自横向扩展SDS 的威胁

      传统的存储厂商正面对着前所未竽暌剐的压力。软件定义存储与公有云存储(也是基于横向扩大的SDS技巧)相浇忧⒛解决筹划正在蚕食传统的存储市场,如Dell EMC的VNX、HPE的Smart Array、NetApp的E系列和FAS。我同样认为>>>详细阅读


      本文标题:面向机器智能的TensorFlow实践:产品环境中模型的部署

      地址:http://www.17bianji.com/lsqh/34985.html

    关键词: 探索发现

    乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

    网友点评
    自媒体专栏

    评论

    热度

    精彩导读
    栏目ID=71的表不存在(操作类型=0)